keepalived安裝配置 centos 7linux
###centos 7.4 ###三臺keepalived節點,兩臺也能夠
###全部節點運行 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux setenforce 0 systemctl stop firewalld.service systemctl disable firewalld.service hostnamectl --static set-hostname l_$(ip addr |grep brd |grep global |head -n1 |cut -d '/' -f1 |cut -d '.' -f4) yum install -y keepalived ##################master1 運行配置 cat >/etc/keepalived/keepalived.conf <<EOF global_defs { router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 157 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 2829 } virtual_ipaddress { 172.16.3.228/24 dev ens33 } } EOF systemctl enable keepalived.service systemctl restart keepalived.service systemctl status keepalived.service ip address show ens33 ##################master2 運行配置 cat >/etc/keepalived/keepalived.conf <<EOF global_defs { router_id LVS_DEVEL } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 157 priority 99 advert_int 1 authentication { auth_type PASS auth_pass 2829 } virtual_ipaddress { 172.16.3.228/24 dev ens33 } } EOF systemctl enable keepalived.service systemctl restart keepalived.service systemctl status keepalived.service ip address show ens33 ##################master3 運行配置 cat >/etc/keepalived/keepalived.conf <<EOF global_defs { router_id LVS_DEVEL } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 157 priority 98 advert_int 1 authentication { auth_type PASS auth_pass 2829 } virtual_ipaddress { 172.16.3.228/24 dev ens33 } } EOF ######### systemctl enable keepalived.service systemctl restart keepalived.service systemctl status keepalived.service ip address show ens33 ####切換主執行腳本 #notify_master "sleep 1 ;systemctl restart haproxy.service" ####切換備執行腳本 #notify_backup "pkill haproxy"