Nginx+keepalived(部分配置)

wKioL1lJDYrTZE35AADvDgGFhMs149.png

wKiom1lJDYug3J5zAADpNT01XxI704.png

wKiom1lJDYyi_LCKAADM_GwjXBU992.png

wKioL1lJDY2hGSm_AACGpX6SNnU933.png

wKioL1lJDY6yzHYNAAC-EY8D5vw110.png

wKiom1lJDY_ibbn5AACraCNl3Ko496.png

Nginx-S上面也要配置跟Nginx-M上面一樣的Nginx代理服務配置


Nginx-M和Nginx-S的keepalived服務配置:

wKiom1lJDY-xSuvkAACgeCHODYw041.png

wKioL1lJDZCAD_paAACKAz0haDE994.png

配置文件模板:

! Configuration File for keepalived

global_defs {

notification_email {

[email protected]

[email protected]

}

notification_email_from [email protected]

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

}

}

wKiom1lJDZGDn4oyAACvFqbbVV8267.png

此監控腳本Nginx-S服務器上面也需要:

腳本模板:

#!/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服務器上面只需要搭建Apache服務即可,不需要做其他的網絡設置

將Nginx-M和Nginx-S服務器上面的keepalived和Nginx服務開啓,再將/opt/下面的監控腳本執行,之後停掉任何一臺Nginx代理服務器查看效果驗證是否一臺Nginx代理服務器宕機的情況下,另一臺繼續工作


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章