創(chuàng)新互聯(lián)建站10多年成都定制網(wǎng)頁設(shè)計(jì)服務(wù);為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁設(shè)計(jì)及高端網(wǎng)站定制服務(wù),成都定制網(wǎng)頁設(shè)計(jì)及推廣,對酒樓設(shè)計(jì)等多個(gè)領(lǐng)域擁有豐富的網(wǎng)站營銷經(jīng)驗(yàn)的網(wǎng)站建設(shè)公司。
Nginx-S上面也要配置跟Nginx-M上面一樣的Nginx代理服務(wù)配置
Nginx-M和Nginx-S的keepalived服務(wù)配置:
配置文件模板:
! Configuration File for keepalived
global_defs {
notification_email {
ops@wangshibo.cn
tech@wangshibo.cn
}
notification_email_from ops@wangshibo.cn
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id master-node
}
vrrp_script chk_http_port {
script "/opt/chk_nginx.sh"
interval 2
weight -5
fall 2
rise 1
}
vrrp_instance VI_1 {
state MASTER
interface eth0
mcast_src_ip 192.168.115.173
virtual_router_id 51
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.115.100
}
track_script {
chk_http_port
}
}
此監(jiān)控腳本Nginx-S服務(wù)器上面也需要:
腳本模板:
#!/bin/bash
counter=$(ps -C nginx --no-heading|wc -l)
if [ "${counter}" = "0" ]; then
service nginx restart
sleep 2
counter=$(ps -C nginx --no-heading|wc -l)
if [ "${counter}" = "0" ]; then
service keepalived stop
fi
fi
WEB服務(wù)器上面只需要搭建Apache服務(wù)即可,不需要做其他的網(wǎng)絡(luò)設(shè)置
將Nginx-M和Nginx-S服務(wù)器上面的keepalived和Nginx服務(wù)開啟,再將/opt/下面的監(jiān)控腳本執(zhí)行,之后停掉任何一臺(tái)Nginx代理服務(wù)器查看效果驗(yàn)證是否一臺(tái)Nginx代理服務(wù)器宕機(jī)的情況下,另一臺(tái)繼續(xù)工作