一、keepalived是什麼 Keepalived 軟體起初是專為LVS負載均衡軟體設計的,用來管理並監控LVS集群系統中各個服務節點的狀態,後來又加入了可以實現高可用的VRRP功能。因此,Keepalived除了能夠管理LVS軟體外,還可以作為其他服務(例如:Nginx、Haproxy、MySQ ...
目錄
一、keepalived是什麼
Keepalived 軟體起初是專為LVS負載均衡軟體設計的,用來管理並監控LVS集群系統中各個服務節點的狀態,後來又加入了可以實現高可用的VRRP功能。因此,Keepalived除了能夠管理LVS軟體外,還可以作為其他服務(例如:Nginx、Haproxy、MySQL等)的高可用解決方案軟體。
Keepalived軟體主要是通過VRRP協議實現高可用功能的。VRRP是Virtual Router RedundancyProtocol(虛擬路由器冗餘協議)的縮寫,VRRP出現的目的就是為瞭解決靜態路由單點故障問題的,它能夠保證當個別節點宕機時,整個網路可以不間斷地運行。
所以,Keepalived 一方面具有配置管理LVS的功能,同時還具有對LVS下麵節點進行健康檢查的功能,另一方面也可實現系統網路服務的高可用功能。
二、Keepalived服務的重要功能
1、實現對LVS集群節點健康檢查功能(healthcheck)
Keepalived可以通過在自身的keepalived.conf文件里配置LVS的節點IP和相關參數實現對LVS的直接管理;除此之外,當LVS集群中的某一個甚至是幾個節點伺服器同時發生故障無法提供服務時,Keepalived服務會自動將失效的節點伺服器從LVS的正常轉發隊列中清除出去,並將請求調度到別的正常節點伺服器上,從而保證最終用戶的訪問不受影響;當故障的節點伺服器被修複以後,Keepalived服務又會自動地把它們加入到正常轉發隊列中,對客戶提供服務。
2、作為系統網路服務的高可用功能
Keepalived高可用功能實現的簡單原理為,兩台主機同時安裝好Keepalived軟體並啟動服務,開始正常工作時,由角色為Master的主機獲得所有資源並對用戶提供服務,角色為Backup的主機作為Master主機的熱備;當角色為Master的主機失效或出現故障時,角色為Backup的主機將自動接管Master主機的所有工作,包括接管VIP資源及相應資源服務;而當角色為Master的主機故障修複後,又會自動接管回它原來處理的工作,角色為Backup的主機則同時釋放Master主機失效時它接管的工作,此時,兩台主機將恢復到最初啟動時各自的原始角色及工作狀態。
3、Keepalived高可用故障切換轉移原理
Keepalived高可用服務對之間的故障切換轉移,是通過VRRP(Virtual Router Redundancy Protocol,虛擬路由器冗餘協議)來實現的。
在Keepalived服務正常工作時,主Master節點會不斷地向備節點發送(多播的方式)心跳消息,用以告訴備Backup節點自己還活著,當主Master節點發生故障時,就無法發送心跳消息,備節點也就因此無法繼續檢測到來自主Master節點的心跳了,於是調用自身的接管程式,接管主Master節點的IP資源及服務。而當主Master節點恢復時,備Backup節點又會釋放主節點故障時自身接管的IP資源及服務,恢復到原來的備用角色。
三、keepalived工作原理描述
Keepalived高可用對之間是通過VRRP通信的,因此,我們從 VRRP開始瞭解起:
1、VRRP,全稱 Virtual Router Redundancy Protocol,中文名為虛擬路由冗餘協議,VRRP的出現是為瞭解決靜態路由的單點故障。
2、VRRP是通過一種竟選協議機制來將路由任務交給某台 VRRP路由器的。
3、VRRP用 IP多播的方式(預設多播地址(224.0_0.18))實現高可用對之間通信。
4、工作時主節點發包,備節點接包,當備節點接收不到主節點發的數據包的時候,就啟動接管程式接管主節點的開源。備節點可以有多個,通過優先順序競選,但一般 Keepalived系統運維工作中都是一對。
5、VRRP使用了加密協議加密數據,但Keepalived官方目前還是推薦用明文的方式配置認證類型和密碼。
介紹完 VRRP,接下來我再介紹一下 Keepalived服務的工作原理:
Keepalived高可用對之間是通過VRRP進行通信的,VRRP是通過競選機制來確定主備節點的,主節點的優先順序高於備節點,因此,工作時主節點會優先獲得所有的資源,備節點處於等待狀態,當主節點出現故障時,備節點就會接管主節點的資源,然後頂替主節點對外提供服務。
在Keepalived服務對之間,只有作為主節點的伺服器會一直發送 VRRP廣播包,告訴備節點它還活著,此時備節點不會搶占主節點資源,當主節點不可用時,即備節點監聽不到主節點發送的廣播包時,備節點就會啟動相關服務接管主節點的資源,保證業務的連續性。接管速度最快可以小於1秒。
四、keepalived實現nginx負載均衡機高可用
環境說明
系統信息 | 主機名 | IP |
---|---|---|
centos8 | master | 192.168.111.141 |
centos8 | backup | 192.168.111.142 |
本次高可用虛擬IP(VIP)地址暫定為 192.168.111.250
1.keepalived安裝
配置主伺服器keepalived
//修改主機名便於區分
[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# bash
//關閉防火牆和selinux
[root@master ~]# systemctl disable --now firewalld
[root@master ~]# setenforce 0
[root@master ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
//配置yum源
[root@master ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@master ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//下載依賴包
[root@master ~]# yum -y install epel-release vim wget gcc gcc-c++
//下載keepalived服務
[root@master ~]# yum -y install keepalived
//查看安裝生成的文件
[root@master ~]# rpm -ql keepalived
/etc/keepalived //配置目錄
/etc/keepalived/keepalived.conf //此為主配置文件
/etc/sysconfig/keepalived
/usr/bin/genhash
/usr/lib/systemd/system/keepalived.service //此為服務控制文件
/usr/libexec/keepalived
/usr/sbin/keepalived
.....此處省略N行
配置備伺服器keepalived
//修改主機名便於區分
[root@localhost ~]# hostnamectl set-hostname backup
[root@localhost ~]# bash
//關閉防火牆和selinux
[root@backup ~]# systemctl disable --now firewalld
[root@backup ~]# setenforce 0
[root@backup ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
//配置yum源
[root@backup ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@backup ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//下載依賴包
[root@backup ~]# yum -y install epel-release vim wget gcc gcc-c++
//下載keepalived服務
[root@backup ~]# yum -y install keepalived
2.在主備上分別安裝nginx
在master上安裝nginx
[root@master ~]# yum -y install nginx
[root@master ~]# cd /usr/share/nginx/html/
[root@master html]# ls
404.html 50x.html index.html nginx-logo.png poweredby.png
[root@master html]# mv index.html{,.bak}
[root@master html]# echo 'master' > index.html
[root@master html]# ls
404.html 50x.html index.html index.html.bak nginx-logo.png poweredby.png
[root@master html]# systemctl start nginx
[root@master html]# systemctl enable nginx
[root@master html]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 [::]:80 [::]:*
[root@master html]# curl 192.168.111.141
master
在slave上安裝nginx
[root@backup ~]# yum -y install nginx
[root@backup ~]# cd /usr/share/nginx/html/
[root@backup html]# ls
404.html 50x.html index.html nginx-logo.png poweredby.png
[root@backup html]# mv index.html{,.bak}
[root@backup html]# echo 'backup' > index.html
[root@backup html]# ls
404.html 50x.html index.html index.html.bak nginx-logo.png poweredby.png
[root@backup html]# systemctl start nginx
[root@backup html]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
[root@backup html]# curl 192.168.111.142
backup
3.配置keepalived
配置主伺服器keepalived
//將原配置文件備份
[root@master ~]# mv /etc/keepalived/keepalived.conf{,.bak}
[root@master ~]# ls /etc/keepalived/
keepalived.conf.bak
//重新創建一個配置文件
[root@master ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.111.250
}
}
virtual_server 192.168.111.250 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.111.141 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.111.142 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
//設置開機自啟動
[root@master ~]# systemctl enable --now keepalived
配置備伺服器keepalived
[root@backup ~]# mv /etc/keepalived/keepalived.conf{,.bak}
[root@backup ~]# ls /etc/keepalived/
keepalived.conf.bak
[root@backup ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.111.250
}
}
virtual_server 192.168.111.250 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.111.141 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.111.142 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
//設置開機自啟動
[root@backup ~]# systemctl enable --now keepalived
4.查看VIP在哪台伺服器上
在master上查看
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 925sec preferred_lft 925sec
inet 192.168.111.250/32 scope global ens33 //可以看到虛擬IP(VIP)
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
在backup上查看
[root@backup ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:07:42:65 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.142/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 1651sec preferred_lft 1651sec
inet6 fe80::20c:29ff:fe07:4265/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5.讓keepalived監控nginx負載均衡機
keepalived通過腳本來監控nginx負載均衡機的狀態
在master上編寫腳本
[root@master ~]# mkdir /scripts
[root@master ~]# cd /scripts/
[root@master scripts]# vim check_nginx.sh
#!/bin/bash
nginx_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bnginx\b'|wc -l)
if [ $nginx_status -lt 1 ];then
systemctl stop keepalived
fi
[root@master scripts]# vim notify.sh
#!/bin/bash
VIP=$2
case "$1" in
master)
nginx_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bnginx\b'|wc -l)
if [ $nginx_status -lt 1 ];then
systemctl start nginx
fi
sendmail
;;
backup)
nginx_status=$(ps -ef|grep -Ev "grep|$0"|grep '\bnginx\b'|wc -l)
if [ $nginx_status -gt 0 ];then
systemctl stop nginx
fi
;;
*)
echo "Usage:$0 master|backup VIP"
;;
esac
[root@master scripts]# chmod +x check_nginx.sh
[root@master scripts]# chmod +x notify.sh
[root@master scripts]# ll
total 8
-rwxr-xr-x 1 root root 143 Oct 8 23:18 check_nginx.sh
-rwxr-xr-x 1 root root 451 Oct 8 23:37 notify.sh
在backup上編寫腳本
[root@backup ~]# mkdir /scripts
[root@backup ~]# cd /scripts/
[root@backup scripts]# scp [email protected]:/scripts/* .
The authenticity of host '192.168.111.141 (192.168.111.141)' can't be established.
ECDSA key fingerprint is SHA256:+KjoLZnhr7A3Jz2DNbF6JHSkb/6pBZPVizet4RohrS0.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.111.141' (ECDSA) to the list of known hosts.
[email protected]'s password:
check_nginx.sh 100% 143 99.3KB/s 00:00
notify.sh 100% 451 403.0KB/s 00:00 [root@backup scripts]# ll
total 8
-rwxr-xr-x 1 root root 143 Oct 8 23:38 check_nginx.sh
-rwxr-xr-x 1 root root 451 Oct 8 23:38 notify.sh
6.配置keepalived加入監控腳本的配置
配置主伺服器keeplived
[root@master ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_script nginx_check { //添加這一部分
script "/scripts/check_nginx.sh"
interval 1
weight -20
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.111.250
}
track_script { //添加這一部分
nginx_check
}
notify_master "/scripts/notify.sh master 192.168.111.250"
notify_backup "/scripts/notify.sh bakcup 192.168.111.250"
}
virtual_server 192.168.111.250 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.111.141 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.111.142 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
[root@master ~]# systemctl restart keepalived
配置備伺服器keepalived
[root@backup ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.111.250
}
notify_master "/scripts/notify.sh master 192.168.111.250" //添加這兩句
notify_backup "/scripts/notify.sh backup 192.168.111.250"
}
virtual_server 192.168.111.250 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.111.141 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.111.142 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
[root@backup ~]# systemctl restart keepalived
測試
//在master上關閉nginx服務模擬出錯,進行測試
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 1251sec preferred_lft 1251sec
inet 192.168.111.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@master ~]# systemctl stop nginx
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 1238sec preferred_lft 1238sec
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@master ~]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sun 2022-10-09 00:25:47 CST; 52s ago
Process: 277285 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 277288 (code=exited, status=0/SUCCESS)
//在backup上查看
[root@backup ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:07:42:65 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.142/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 1080sec preferred_lft 1080sec
inet 192.168.111.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe07:4265/64 scope link noprefixroute
valid_lft forever preferred_lft forever
瀏覽器進行訪問
//啟動master上的nginx服務和keepalived服務,看VIP是否會回到主伺服器上
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 1053sec preferred_lft 1053sec
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@master ~]# systemctl start nginx
[root@master ~]# systemctl restart keepalived
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 971sec preferred_lft 971sec
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
//需要重啟備伺服器上的keepalived服務
[root@backup ~]# systemctl restart keepalived
//VIP才能回到主服務上
[root@master ~]# 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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:50:34:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.141/24 brd 192.168.111.255 scope global dynamic noprefixroute ens33
valid_lft 926sec preferred_lft 926sec
inet 192.168.111.250/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe50:3472/64 scope link noprefixroute
valid_lft forever preferred_lft forever
//VIP在主伺服器上時,想要訪問需要關閉backup上的nginx服務
[root@backup ~]# systemctl stop nginx