然后使用ip a s命令查看是否有VIP地址分配。如果看到VIP地址已经成功分配在eth0网卡上,说明keepalived启动成功。
[root@kube32 ~]# ip a s1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNqlen1link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlovalid_lftforeverpreferred_lftforeverinet6::1/128scopehostvalid_lftforeverpreferred_lftforever2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscmqstateUPqlen1000link/ether00:50:56:a9:d5:bebrdff:ff:ff:ff:ff:ffinet10.86.13.32/23brd10.86.13.255scopeglobaleth0valid_lftforeverpreferred_lftforever**inet10.86.13.36/32scopeglobaleth0**valid_lftforeverpreferred_lftforeverinet6fe80::250:56ff:fea9:d5be/64scopelinkvalid_lftforeverpreferred_lftforever
更保险方法还可以通过systemctl status keepalived -l看看keepalived的状态
[root@kube32 ~]# systemctl status keepalived -l●keepalived.service-LVSandVRRPHighAvailabilityMonitorLoaded:loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendorpreset:disabled)Active:active (running) since Thu 2018-02-01 10:24:51 CST; 1months16daysagoMainPID:13448 (keepalived)Memory:6.0MCGroup:/system.slice/keepalived.service├─13448/usr/sbin/keepalived-D├─13449/usr/sbin/keepalived-D└─13450/usr/sbin/keepalived-DMar2004:51:15kube32Keepalived_vrrp[13450]:VRRP_Instance(VI-kube-master) DroppingreceivedVRRPpacket...**Mar 20 04:51:18 kube32 Keepalived_vrrp[13450]: (VI-kube-master): ip address associated with VRID 51 not present in MASTER advert : 10.86.13.36Mar2004:51:18kube32Keepalived_vrrp[13450]:bogusVRRPpacketreceivedoneth0!!!**
然后通过systemctl status haproxy -l看haproxy的状态
[root@kube32 ~]# systemctl status haproxy -l●haproxy.service-HAProxyLoadBalancerLoaded:loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendorpreset:disabled)Active:active (running) since Thu 2018-02-01 10:33:22 CST; 1months16daysagoMainPID:15116 (haproxy-systemd)Memory:3.2MCGroup:/system.slice/haproxy.service├─15116/usr/sbin/haproxy-systemd-wrapper-f/etc/haproxy/haproxy.cfg-p/run/haproxy.pid├─15117/usr/sbin/haproxy-f/etc/haproxy/haproxy.cfg-p/run/haproxy.pid-Ds└─15118/usr/sbin/haproxy-f/etc/haproxy/haproxy.cfg-p/run/haproxy.pid-Ds
这个时候说明你的keepalived和haproxy都是成功的。这个时候你可以依次将你其他Master节点的keepalived和haproxy启动。 此时,你通过ip a s命令去查看其中一台Master(非主Master)的时候,你看不到VIP,这个是正常的,因为VIP永远只在主Master节点上,只有当主Master节点挂掉后,才会切换到其他Master节点上。
[root@kube31 ~]# ip a s1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNqlen1link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlovalid_lftforeverpreferred_lftforeverinet6::1/128scopehostvalid_lftforeverpreferred_lftforever2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscmqstateUPqlen1000link/ether00:50:56:a9:07:23brdff:ff:ff:ff:ff:ffinet10.86.13.31/23brd10.86.13.255scopeglobaleth0valid_lftforeverpreferred_lftforeverinet6fe80::250:56ff:fea9:723/64scopelinkvalid_lftforeverpreferred_lftforever