[size=1em]在172.18.11.121编辑该配置文件:
[size=1em]]# vim /etc/keepalived/keepalived.conf
---------------------------------------------------------------------------------
[size=1em]修改:
state BACKUP 修改为备用
priority 50 修改小优先级;
[size=1em]密码、router_id、vrrp_mcast_group4要保存一致;
[size=1em]在两个调度器上开启keepalived服务:
]# systemctl start keepalived.service
]# systemctl status keepalived.service
]# systemctl -l status keepalived.service 【-l 表示显示更多的信息】
[size=1em]【分别查看两个调度器,VIP地址是否自动在主服务器的接口别名上:】
]# ip addr l
]# tail /var/log/messages
[size=1em]手动使172.18.11.111主用服务器停止keepalived服务,再查看;
]# systemctl stop keepalived.service
[size=1em]用另一终端查看日志信息不退出:
[size=1em]显示部分内容:
]# tail -f /var/log/messages
[size=1em]May 10 05:25:01 localhost systemd: Stopping LVS and VRRP High Availability Monitor...
May 10 05:25:01 localhost Keepalived_vrrp[4258]: VRRP_Instance(VI_1) sending 0 priority 发送优先级为0的报文;
May 10 05:25:01 localhost Keepalived_vrrp[4258]: VRRP_Instance(VI_1) removing protocol VIPs. 移除VIP的协议
May 10 05:25:01 localhost Keepalived_healthcheckers[4257]: Netlink reflector reports IP 172.18.11.66 removed 移除VIP
May 10 05:25:01 localhost systemd: Stopped LVS and VRRP High Availability Monitor
[size=1em]在另一调度器172.18.11.121上,查看日志:
[size=1em]显示内容:
]# tail /var/log/messages
May 9 08:09:21 localhost Keepalived_vrrp[3881]: VRRP_Instance(VI_1) Transition to MASTER STATE 称为主用服务器
May 9 08:09:22 localhost Keepalived_vrrp[3881]: VRRP_Instance(VI_1) Entering MASTER STATE 确认主用状态
May 9 08:09:22 localhost Keepalived_vrrp[3881]: VRRP_Instance(VI_1) setting protocol VIPs. 设置
May 9 08:09:22 localhost Keepalived_vrrp[3881]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eno16777736 for 172.18.11.66 发送免费ARP报文
May 9 08:09:22 localhost Keepalived_healthcheckers[3880]: Netlink reflector reports IP 172.18.11.66 added 获得VIP地址
May 9 08:09:27 localhost Keepalived_vrrp[3881]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eno16777736 for 172.18.11.66
May 9 08:10:01 localhost systemd: Started Session 58 of user root.
May 9 08:10:01 localhost systemd: Starting Session 58 of user root.
May 9 08:10:01 localhost systemd: Started Session 59 of user root.
May 9 08:10:01 localhost systemd: Starting Session 59 of user root.