$ sudo ifconfig eth0:0 172.16.8.252 netmask 255.255.255.255 up
修改配置文件 (上面的配置重启后需要重新输入命令)
$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
auto eth0
auto eth0:0
$ sudo ifconfig eth0:0 172.16.8.252 netmask 255.255.255.255 up
修改配置文件 (上面的配置重启后需要重新输入命令)
$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
auto eth0
auto eth0:0
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
curl: (7) couldn't connect to host
Web App Server 2
curl: (7) couldn't connect to host
Web App Server 2
curl: (7) couldn't connect to host
Web App Server 2
Web App Server 2
Web App Server 2
Web App Server 2
...
$ sudo ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.8.252:80 rr
-> 172.16.8.132:80 Route 3 0 114
$ ssh WEB_APP_SERVER_1
$ sudo service nginx stop
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
Web App Server 1
Web App Server 2
Web App Server 1
Web App Server 2
...
将LVS_MASTER关闭,查看请求web app server的结果
$ ssh LVS_MASTER
$ sudo shutdown -h now
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
Web App Server 1
Web App Server 2
Web App Server 1
Web App Server 2
...