#node12节点日志
Jun 28 12:36:39 node12 systemd: Stopped HAProxy Load Balancer.
Jun 28 12:36:39 node12 Keepalived_vrrp[9408]:
#haproxy 检测状态为 1
/etc/keepalived/chk_haproxy.sh exited with status 1
Jun 28 12:36:40 node12 Keepalived_vrrp[9408]:
/etc/keepalived/chk_haproxy.sh exited with status 1
Jun 28 12:36:41 node12 Keepalived_vrrp[9408]: /etc/keepalived/chk_haproxy.sh exited with status 1
Jun 28 12:36:41 node12 Keepalived_vrrp[9408]: VRRP_Script(chk_haproxy) failed
Jun 28 12:36:41 node12 Keepalived_vrrp[9408]: VRRP_Instance(VI_200) Changing effective priority from 100 to 20
Jun 28 12:36:42 node12 Keepalived_vrrp[9408]: /etc/keepalived/chk_haproxy.sh exited with status 1
Jun 28 12:36:43 node12 Keepalived_vrrp[9408]: VRRP_Instance(VI_200) Received advert with higher priority 80, ours 20
Jun 28 12:36:43 node12 Keepalived_vrrp[9408]: VRRP_Instance(VI_200) Entering BACKUP STATE
Jun 28 12:36:43 node12 Keepalived_vrrp[9408]: VRRP_Instance(VI_200) removing protocol VIPs.
#VIP飘到node13上
[root@node13 haproxy]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a0:98:7e brd ff:ff:ff:ff:ff:ff
inet 172.16.62.13/24 brd 172.16.62.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 172.16.62.248/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.249/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.250/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.251/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.252/32 scope global eth0
valid_lft forever preferred_lft forever
[root@node13 haproxy]#
#node13节点日志
Jun 28 12:36:43 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) forcing a new MASTER election
Jun 28 12:36:45 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Transition to MASTER STATE
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Entering MASTER STATE
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) setting protocol VIPs.
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.248
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.249
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.250
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.251
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 28 12:36:47 node13 Keepalived_vrrp[3692]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.252
#在node12和node13上安装keepalived
#安装keepalived
yum install keepalived -y
#查看node13节点keepalived
[root@node12 keepalived]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-06-27 17:49:44 CST; 39s ago
Process: 2195 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 2219 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2220 (keepalived)
CGroup: /system.slice/keepalived.service
├─2220 /usr/sbin/keepalived -D
├─2221 /usr/sbin/keepalived -D
└─2222 /usr/sbin/keepalived -D
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 17:49:53 node12 Keepalived_vrrp[2222]: Sending gratuitous ARP on eth0 for 172.16.62.252
[root@node12 keepalived]#
#查看node13节点keepalived
[root@node13 keepalived]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2020-06-27 17:49:55 CST; 22s ago
Process: 2457 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2458 (keepalived)
CGroup: /system.slice/keepalived.service
├─2458 /usr/sbin/keepalived -D
├─2459 /usr/sbin/keepalived -D
└─2460 /usr/sbin/keepalived -D
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: Registering Kernel netlink reflector
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: Registering Kernel netlink command channel
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: Registering gratuitous ARP shared channel
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: VRRP_Instance(VI_200) removing protocol VIPs.
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: Using LinkWatch kernel netlink reflector...
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: VRRP_Instance(VI_200) Entering BACKUP STATE
Jun 27 17:49:55 node13 Keepalived_vrrp[2460]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]
Jun 27 17:49:55 node13 Keepalived_healthcheckers[2459]: Activating healthchecker for service [172.16.62.248]:80
Jun 27 17:49:55 node13 Keepalived_healthcheckers[2459]: Activating healthchecker for service [172.16.62.248]:80
[root@node13 keepalived]#
2.2 安装LVS
#在node12和node13上安装LVS
#安装LVS
yum -y install ipvsadm
如果服务无法启动,请创建和保持至ipvsadm
ipvsadm --save > /etc/sysconfig/ipvsadm
[root@node12 keepalived]# systemctl status ipvsadm
● ipvsadm.service - Initialise the Linux Virtual Server
Loaded: loaded (/usr/lib/systemd/system/ipvsadm.service; enabled; vendor preset: disabled)
Active: active (exited) since Sat 2020-06-27 17:54:06 CST; 43s ago
Process: 2251 ExecStart=/bin/bash -c exec /sbin/ipvsadm-restore < /etc/sysconfig/ipvsadm (code=exited, status=0/SUCCESS)
Main PID: 2251 (code=exited, status=0/SUCCESS)
Jun 27 17:54:06 node12 systemd[1]: Starting Initialise the Linux Virtual Server...
Jun 27 17:54:06 node12 systemd[1]: Started Initialise the Linux Virtual Server
[root@node12 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a0:a4:f5 brd ff:ff:ff:ff:ff:ff
inet 172.16.62.12/24 brd 172.16.62.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 172.16.62.248/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.249/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.250/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.251/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.252/32 scope global eth0
valid_lft forever preferred_lft forever
[root@node12 keepalived]#
#关闭node12
[root@node12 keepalived]# systemctl stop keepalived
#切换到node13节点上,VIP切换到BACKUP上
[root@node13 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a0:98:7e brd ff:ff:ff:ff:ff:ff
inet 172.16.62.13/24 brd 172.16.62.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 172.16.62.248/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.249/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.250/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.251/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.252/32 scope global eth0
valid_lft forever preferred_lft forever
[root@node13 keepalived]#
#node13节点日志
Jun 27 19:02:20 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Transition to MASTER STATE
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Entering MASTER STATE
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) setting protocol VIPs.
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.252
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:22 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:24 node13 ntpd[718]: Listen normally on 15 eth0 172.16.62.248 UDP 123
Jun 27 19:02:24 node13 ntpd[718]: Listen normally on 16 eth0 172.16.62.249 UDP 123
Jun 27 19:02:24 node13 ntpd[718]: Listen normally on 17 eth0 172.16.62.250 UDP 123
Jun 27 19:02:24 node13 ntpd[718]: Listen normally on 18 eth0 172.16.62.251 UDP 123
Jun 27 19:02:24 node13 ntpd[718]: Listen normally on 19 eth0 172.16.62.252 UDP 123
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.252
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:02:27 node13 Keepalived_vrrp[2670]: Sending gratuitous ARP on eth0 for 172.16.62.252
#测试网站
[root@node24 named]# curl 172.16.62.248
mobile mobile.haostack.com 172.16.62.15
[root@node24 named]# curl 172.16.62.248
mobile mobile.haostack.com 172.16.62.16
[root@node24 named]# curl 172.16.62.248
mobile mobile.haostack.com 172.16.62.15
[root@node24 named]# curl 172.16.62.248
mobile mobile.haostack.com 172.16.62.16
#查看ipvsadm
[root@node13 keepalived]# ipvsadm -Ln --stats
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 172.16.62.248:80 17 111 0 7217 0
-> 172.16.62.15:80 8 48 0 3176 0
-> 172.16.62.16:80 9 63 0 4041 0
#开启node12节点,VIP回到MASTER
[root@node12 keepalived]# systemctl start keepalived
[root@node12 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a0:a4:f5 brd ff:ff:ff:ff:ff:ff
inet 172.16.62.12/24 brd 172.16.62.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 172.16.62.248/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.249/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.250/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.251/32 scope global eth0
valid_lft forever preferred_lft forever
inet 172.16.62.252/32 scope global eth0
valid_lft forever preferred_lft forever
[root@node12 keepalived]#
node12日志
Jun 27 19:05:39 node12 systemd: Starting LVS and VRRP High Availability Monitor...
Jun 27 19:05:39 node12 Keepalived[2691]: Starting Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2
Jun 27 19:05:39 node12 Keepalived[2691]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 27 19:05:39 node12 Keepalived[2692]: Starting Healthcheck child process, pid=2693
Jun 27 19:05:39 node12 Keepalived[2692]: Starting VRRP child process, pid=2694
Jun 27 19:05:39 node12 systemd: Started LVS and VRRP High Availability Monitor.
Jun 27 19:05:39 node12 Keepalived_healthcheckers[2693]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: Registering Kernel netlink reflector
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: Registering Kernel netlink command channel
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: Registering gratuitous ARP shared channel
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) removing protocol VIPs.
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: Using LinkWatch kernel netlink reflector...
Jun 27 19:05:39 node12 Keepalived_vrrp[2694]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]
Jun 27 19:05:39 node12 Keepalived_healthcheckers[2693]: Activating healthchecker for service [172.16.62.248]:80
Jun 27 19:05:39 node12 Keepalived_healthcheckers[2693]: Activating healthchecker for service [172.16.62.248]:80
Jun 27 19:05:40 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Transition to MASTER STATE
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Entering MASTER STATE
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) setting protocol VIPs.
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.252
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:42 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:44 node12 ntpd[715]: Listen normally on 30 eth0 172.16.62.248 UDP 123
Jun 27 19:05:44 node12 ntpd[715]: Listen normally on 31 eth0 172.16.62.249 UDP 123
Jun 27 19:05:44 node12 ntpd[715]: Listen normally on 32 eth0 172.16.62.250 UDP 123
Jun 27 19:05:44 node12 ntpd[715]: Listen normally on 33 eth0 172.16.62.251 UDP 123
Jun 27 19:05:44 node12 ntpd[715]: Listen normally on 34 eth0 172.16.62.252 UDP 123
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Sending/queueing gratuitous ARPs on eth0 for 172.16.62.252
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.248
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.249
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.250
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.251
Jun 27 19:05:47 node12 Keepalived_vrrp[2694]: Sending gratuitous ARP on eth0 for 172.16.62.252
# 查看IPVSADM
[root@node12 keepalived]# ipvsadm -Ln --stats
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 172.16.62.248:80 4 26 0 1704 0
-> 172.16.62.15:80 2 12 0 800 0
-> 172.16.62.16:80 2 14 0 904 0
#网站测试
172.16.62.248 做个DNS解析
[root@node24 named]# curl www.haostack.com
mobile mobile.haostack.com 172.16.62.16
[root@node24 named]# curl www.haostack.com
mobile mobile.haostack.com 172.16.62.15
[root@node24 named]# curl www.haostack.com
mobile mobile.haostack.com 172.16.62.16
[root@node24 named]# curl www.haostack.com
mobile mobile.haostack.com 172.16.62.15
[root@node24 named]#
#本地页面
[root@node14 tmp]# curl 172.16.62.14
Website maintenance, please contact 1380000001
[root@node14 tmp]#
#绑定VIP
[root@node14 tmp]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 172.16.62.248/32 brd 172.16.62.248 scope global lo:0
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a0:e7:75 brd ff:ff:ff:ff:ff:ff
inet 172.16.62.14/24 brd 172.16.62.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:c9:59:c6:0a brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
[root@node14 tmp]#
#关闭后端web nginx
[root@web15 tmp]# systemctl stop nginx
[root@web16 conf]# systemctl stop nginx
#查看master节点日志 不能链接到[172.16.62.15]:80
Jun 27 19:58:47 node12 Keepalived_vrrp[2694]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]
Jun 27 19:58:49 node12 Keepalived_vrrp[2694]: VRRP_Instance(VI_200) Transition to MASTER STATE
Jun 27 20:01:01 node12 systemd: Started Session 7 of user root.
Jun 27 20:01:04 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:07 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:09 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:10 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:12 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:13 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:13 node12 Keepalived_healthcheckers[2693]: Check on service [172.16.62.15]:80 failed after 3 retry.
Jun 27 20:01:13 node12 Keepalived_healthcheckers[2693]: Removing service [172.16.62.15]:80 from VS [172.16.62.248]:80
Jun 27 20:01:13 node12 Keepalived_healthcheckers[2693]: SMTP connection ERROR to [127.0.0.1]:25.
Jun 27 20:01:15 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Check on service [172.16.62.16]:80 failed after 3 retry.
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Removing service [172.16.62.16]:80 from VS [172.16.62.248]:80
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Lost quorum 1-0=1 > 0 for VS [172.16.62.248]:80
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Adding sorry server [172.16.62.14]:80 to VS [172.16.62.248]:80
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: Removing alive servers from the pool for VS [172.16.62.248]:80
Jun 27 20:01:18 node12 Keepalived_healthcheckers[2693]: SMTP connection ERROR to [127.0.0.1]:25.
#查看backup节点日志 不能链接到[172.16.62.15]:80
Jun 27 20:01:03 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:06 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:09 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:09 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:12 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.15]:80.
Jun 27 20:01:12 node13 Keepalived_healthcheckers[2669]: Check on service [172.16.62.15]:80 failed after 3 retry.
Jun 27 20:01:12 node13 Keepalived_healthcheckers[2669]: Removing service [172.16.62.15]:80 from VS [172.16.62.248]:80
Jun 27 20:01:12 node13 Keepalived_healthcheckers[2669]: SMTP connection ERROR to [127.0.0.1]:25.
Jun 27 20:01:12 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:15 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Error connecting server [172.16.62.16]:80.
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Check on service [172.16.62.16]:80 failed after 3 retry.
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Removing service [172.16.62.16]:80 from VS [172.16.62.248]:80
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Lost quorum 1-0=1 > 0 for VS [172.16.62.248]:80
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Adding sorry server [172.16.62.14]:80 to VS [172.16.62.248]:80
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: Removing alive servers from the pool for VS [172.16.62.248]:80
Jun 27 20:01:18 node13 Keepalived_healthcheckers[2669]: SMTP connection ERROR to [127.0.0.1]:25.
#查看ipvsadm
[root@node12 keepalived]# ipvsadm -Ln --stats
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 172.16.62.248:80 78 482 0 32106 0
-> 172.16.62.14:80 0 0 0 0 0
#页面测试
[root@node24 named]# while true;do curl http://www.haostack.com && sleep 1;done
Website maintenance, please contact 1380000001
Website maintenance, please contact 1380000001
Website maintenance, please contact 1380000001
Website maintenance, please contact 1380000001