分别启动主备节点的keepalived服务,然后在主节点查看VIP有没有启动:
31服务器: [root@mysql1 ~]# ip a |grep eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 inet 192.168.8.31/24 brd 192.168.8.255 scope global eth0 inet 192.168.8.30/32 scope global eth0 32服务器: [root@mysql2 keepalived-1.1.19]# ip a |grep eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 inet 192.168.8.32/24 brd 192.168.8.255 scope global eth0 现在把31服务器的mysql服务停掉: [root@mysql1 keepalived]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:d4:fd:b3 brd ff:ff:ff:ff:ff:ff inet 192.168.8.31/24 brd 192.168.8.255 scope global eth0 inet 192.168.8.30/32 scope global eth0 [root@mysql1 keepalived]# service mysqld stop Shutting down MySQL. [ OK ] [root@mysql1 keepalived]# service keepalived status keepalived is stopped [root@mysql1 keepalived]#可以看到mysql服务停掉后,keepalived服务也马上停掉了!
再到32节点上查看下VIP有没有接管:
[root@mysql2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:e3:dd:5a brd ff:ff:ff:ff:ff:ff
inet 192.168.8.32/24 brd 192.168.8.255 scope global eth0
inet 192.168.8.30/32 scope global eth0
可以看到接管过来了!