master: 192.168.203.128 slave: 192.168.203.129 VIP 192.168.203.130
yum -y install openssl-devel gcc gcc-c++ mkdir /etc/keepalived wget https://www.keepalived.org/software/keepalived-2.0.18.tar.gz
tar -zxvf keepalived-2.0.18.tar.gz mv keepalived-2.0.18 /usr/local/keepalived cd /usr/local/keepalived ./configure && make && make install
cp -a /usr/local/etc/keepalived /etc/init.d/ cp -a /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ cp -a /usr/local/sbin/keepalived /usr/sbin/
1 master
vim /etc/keepalived/keepalived.conf
global_defs { router_id internal_control } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 3 priority 200 advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.203.130/24 } }
2 slave
vim /etc/keepalived/keepalived.conf
global_defs { router_id internal_control } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 3 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.203.130/24 } }
systemctl start keepalived systemctl enable keepalived
查看maser上已经有vip地址了
1 master关闭keepalived
systemctl stop keepalived
2 salve查看vip地址