返回首页 | 新开户送体验金的娱乐城

合作共赢、快速高效、优质的网站建设提供商

更多精品源码-尽在织梦模板-www.moke8.com

网站开发LVS+Keepalived高可用负载均衡集群架构试验

时间:2017-10-23 编辑:admin

接下来持续测验:

隔两秒改写页面如下:

重复几回轮询调用正常。

七:模仿毛病

毛病前先看一下ipvsadm状况:

[root@booktes********vsadm -l -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
 - RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.214.10:80 rr persistent 2
 - 192.168.214.131:80 Route 1 0 0 
 - 192.168.214.132:80 Route 1 0 0 
[root@booktest ~]# 

将192.168.214.131这台Web Server down掉模仿毛病。直接粗犷点杀掉nginx:pkill nginx

页面正常拜访。再看ipvsadm状况:

[root@booktes********vsadm -l -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
 - RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.214.10:80 rr persistent 2
 - 192.168.214.131:80 Route 1 0 0 
[root@booktest ~]# 
能够看到192.168.21.132节点的Web Server现已掉线了

接下来,测验负载均衡的主备切换。先关掉MASTER的keepalived效劳模仿毛病,然后检查BACKUP 的状况

[root@booktest ~]# service keepalived stop
中止 keepalived: [断定]
[root@booktest ~]# tail /var/log/messages
Oct 21 16:10:43 booktest Keepalived_healthcheckers[2094]: Error connecting server [192.168.214.132]:80.
Oct 21 16:10:43 booktest Keepalived_healthcheckers[2094]: Removing service [192.168.214.132]:80 from VS [192.168.214.10]:80
Oct 21 16:10:43 booktest Keepalived_healthcheckers[2094]: Remote SMTP server [192.168.200.1]:25 connected.
Oct 21 16:11:04 booktest Keepalived_healthcheckers[2094]: Error reading data from remote SMTP server [192.168.200.1]:25.
Oct 21 16:19:27 booktest kernel: IPVS: __ip_vs_del_service: enter
Oct 21 16:19:27 booktest Keepalived_vrrp[2095]: VRRP_Instance(VI_1) sending 0 priority
Oct 21 16:19:27 booktest Keepalived_vrrp[2095]: VRRP_Instance(VI_1) removing protocol VIPs.
Oct 21 16:19:27 booktest Keepalived[2093]: Stopping Keepalived v1.2.13 (03/19,2015)
Oct 21 16:19:27 booktest Keepalived_healthcheckers[2094]: Netlink reflector reports IP 192.168.214.10 removed
Oct 21 16:19:27 booktest Keepalived_healthcheckers[2094]: Removing service [192.168.214.131]:80 from VS [192.168.214.10]:80
[root@booktest ~]# 

接着检查BACKUP的状况:

[root@node1 ~]# tail /var/log/messages
Oct 22 00:11:03 node1 Keepalived_healthcheckers[3053]: Error reading data from remote SMTP server [192.168.200.1]:25.
Oct 22 00:16:29 node1 dhclient[989]: DHCPREQUEST on eth0 to 192.168.214.254 port 67 (xid=0x37dffe90)
Oct 22 00:16:29 node1 dhclient[989]: DHCPACK from 192.168.214.254 (xid=0x37dffe90)
Oct 22 00:16:31 node1 dhclient[989]: bound to 192.168.214.130 -- renewal in 806 seconds.
Oct 22 00:19:26 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Transition to MASTER STATE
Oct 22 00:19:27 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Entering MASTER STATE
Oct 22 00:19:27 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) setting protocol VIPs.
Oct 22 00:19:27 node1 Keepalived_healthcheckers[3053]: Netlink reflector reports IP 192.168.214.10 added
Oct 22 00:19:27 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.214.10
Oct 22 00:19:32 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.214.10
[root@node1 ~]# 

能够看到本来BACKUP现已顶替了MASTER,成为了MASTER。

然后再从头发动MASTER的keepalived效劳,重启的MASTER会主动成为MASTER,而本来的BACKUP会从MASTER变为BACKUP

[root@booktest ~]# service keepalived start
正在发动 keepalived: [断定]
[root@booktest ~]# tail /var/log/messages
Oct 21 16:29:43 booktest Keepalived_healthcheckers[2256]: Using LinkWatch kernel netlink reflector...
Oct 21 16:29:43 booktest Keepalived_healthcheckers[2256]: Activating healthchecker for service [192.168.214.131]:80
Oct 21 16:29:43 booktest Keepalived_healthcheckers[2256]: Activating healthchecker for service [192.168.214.132]:80
Oct 21 16:29:43 booktest Keepalived_vrrp[2257]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
Oct 21 16:29:44 booktest Keepalived_vrrp[2257]: VRRP_Instance(VI_1) Transition to MASTER STATE
Oct 21 16:29:44 booktest Keepalived_vrrp[2257]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Oct 21 16:29:45 booktest Keepalived_vrrp[2257]: VRRP_Instance(VI_1) Entering MASTER STATE
Oct 21 16:29:45 booktest Keepalived_vrrp[2257]: VRRP_Instance(VI_1) setting protocol VIPs.
Oct 21 16:29:45 booktest Keepalived_healthcheckers[2256]: Netlink reflector reports IP 192.168.214.10 added
Oct 21 16:29:45 booktest Keepalived_vrrp[2257]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.214.10
[root@booktest ~]# 

再看本来BACKUP主机状况:

[root@node1 ~]# tail /var/log/messages
Oct 22 00:19:27 node1 Keepalived_healthcheckers[3053]: Netlink reflector reports IP 192.168.214.10 added
Oct 22 00:19:27 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.214.10
Oct 22 00:19:32 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.214.10
Oct 22 00:29:42 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Received higher prio advert
Oct 22 00:29:42 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) Entering BACKUP STATE
Oct 22 00:29:42 node1 Keepalived_vrrp[3055]: VRRP_Instance(VI_1) removing protocol VIPs.
Oct 22 00:29:42 node1 Keepalived_healthcheckers[3053]: Netlink reflector reports IP 192.168.214.10 removed
Oct 22 00:29:57 node1 dhclient[989]: DHCPREQUEST on eth0 to 192.168.214.254 port 67 (xid=0x37dffe90)
Oct 22 00:29:57 node1 dhclient[989]: DHCPACK from 192.168.214.254 (xid=0x37dffe90)
Oct 22 00:29:59 node1 dhclient[989]: bound to 192.168.214.130 -- renewal in 793 seconds.
[root@node1 ~]# 

BACKUP主机从头从MASTER状况变成BACKUP状况。持续改写页面正常。

Lvs+Keepalived高可用负载均衡试验成功。接下来将会对web server进行布置优化。


浏览:

网站建设

流程

    网站建设流程