lvs+keepalived 使用DR

2月 22, 2019 |

配置keepalived.conf
注意这个设置(负载均衡类型forwarding method)lb_kind DR

virtual_server 10.10.10.2 1358 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP

real_server 192.168.14.164 6379 {
weight 1
}
}

dummy 网卡的设置

modprobe dummy //加载modprobe模块
ip link add eth_dummy type dummy //添加dummy类型的网卡设备
ip addr add 192.168.14.3/24 dev eth_dummy //eth_dummy 绑定ip
ip link set dummy0 up

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce

echo 1 > /proc/sys/net/ipv4/conf/eth_dummy/arp_ignore
echo 2 >/proc/sys/net/ipv4/conf/eth_dummy/arp_announce

arp_ignore表示real server 不要响应VIP的arp 请求
arp_announce 表示发送arp请求时,源ip要填写报文发出的哪个网卡绑定的ip

参考文档
https://www.networks.guru/2018/01/27/creating-a-dummy-interface-on-a-linux-unix-based-systems/
https://www.jianshu.com/p/734640384fda

Posted in: Linux

Comments are closed.