一、LVS+Keepalived高可用部署
一、keepalived节点部署
1、安装keepalived
yum install keepalived ipvsadm -y mkdir -p /opt/ytd_scripts/keepalived cat>/opt/ytd_scripts/keepalived/UDP_CHECK.sh<<EOF #!/bin/bash /usr/bin/nc -uz -w1 $1 $2 | grep succeeded >/dev/null exit $? EOF cp -rp /etc/keepalived/keepalived.conf{,.bak}
2、更改keepalived.conf
注意:加权平均时,2个节点不要设置成1
1、master节点配置
vrrp_instance VI_1 { state BACKUP interface ens160 virtual_router_id 51 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 20180126 } virtual_ipaddress { 10.100.62.66 } } ###zuul-8080#### virtual_server 10.100.62.66 8080 { delay_loop 6 lb_algo wrr lb_kind DR persistence_timeout 5 protocol TCP real_server 10.100.62.43 8080 { weight 20 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 8080 } } real_server 10.100.62.44 8080 { weight 20 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 8080 } } } ###zuul-8080-udp#### virtual_server 10.100.62.66 8080 { delay_loop 6 lb_algo wrr lb_kind DR persistence_timeout 5 protocol UDP real_server 10.100.62.43 8080 { weight 20 MISC_CHECK { misc_path "/opt/ytd_scripts/keepalived/UDP_CHECK.sh 10.100.62.43 8080" misc_timeout 3 } } real_server 10.100.62.44 8080 { weight 20 MISC_CHECK { misc_path "/opt/ytd_scripts/keepalived/UDP_CHECK.sh 10.100.62.44 8080" misc_timeout 3 } } }