centos 7 lvs负载均衡配置命令记录

ifconfig eno16777736 192.168.1.16 broadcast 192.168.1.255 netmask 255.255.255.0 up


ifconfig eno16777736:0 192.168.1.109/24

增加ip,作为负载均衡的ip
route add -host 192.168.1.109 dev eno16777736:0 

清除配置:

ipvsadm -C

配置服务器A:
ipvsadm -A -t 192.168.1.109:10226 -s lc
ipvsadm -a -t 192.168.1.109:10226 -r 192.168.1.20:10226 -g -w 1
ipvsadm -a -t 192.168.1.109:10226 -r 192.168.1.16:10226 -g -w 1

配置服务器B:
ipvsadm -A -t 192.168.1.109:10227 -s lc
ipvsadm -a -t 192.168.1.109:10227 -r 192.168.1.17:10227 -g -w 1
ipvsadm -a -t 192.168.1.109:10227 -r 192.168.1.18:10227 -g -w 1

查看配置结果
ipvsadm -S

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


ifconfig lo:0 down
ifconfig lo:0 192.168.1.109 broadcast 192.168.1.109 netmask 255.255.255.255 up
route add -host 192.168.1.109 dev lo:0

你可能感兴趣的:(负载均衡)