keepalived+nginx高可用 ﹏ヽ暗。殇╰゛Y 2021-09-09 10:44 399阅读 0赞 nginx默认监听本地所有ip,0.0.0.0:80,所以域名可以绑定到keepalived的虚拟ip上。 **keepalived主机master配置:** ! Configuration File for keepalived global\_defs \{ notification\_email \{ ! Configuration File for keepalived global\_defs \{ notification\_email \{ acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc \} notification\_email\_from Alexandre.Cassen@firewall.loc smtp\_server 192.168.200.1 smtp\_connect\_timeout 30 router\_id woshizhu vrrp\_skip\_check\_adv\_addr \#vrrp\_strict vrrp\_garp\_interval 0 vrrp\_gna\_interval 0 \} vrrp\_script chk\_nginx \{ script "/data/check\_nginx.sh" \#\#检查本地nginx是否存活脚本需要自己写, interval 2 weight -20 \} \#VIP1 vrrp\_instance VI\_1 \{ state MASTER interface ens32 virtual\_router\_id 151 priority 150 advert\_int 5 \#健康检测频率 authentication \{ auth\_type PASS auth\_pass 1111 \} virtual\_ipaddress \{ 192.168.91.200/24 \} track\_script \{ chk\_nginx \} \} **keepalived从机backup配置:** ! Configuration File for keepalived global\_defs \{ notification\_email \{ acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc \} notification\_email\_from Alexandre.Cassen@firewall.loc smtp\_server 192.168.200.1 smtp\_connect\_timeout 30 router\_id woshicong vrrp\_skip\_check\_adv\_addr \#vrrp\_strict vrrp\_garp\_interval 0 vrrp\_gna\_interval 0 \} vrrp\_script chk\_nginx \{ script "/data/check\_nginx.sh" \#\#检查本地nginx是否存活脚本需要自己写 interval 2 weight -20 \} \#VIP1 vrrp\_instance VI\_1 \{ state BACKUP interface ens32 virtual\_router\_id 151 priority 100 advert\_int 5 \#健康检测频率 authentication \{ auth\_type PASS auth\_pass 1111 \} virtual\_ipaddress \{ 192.168.91.200/24 \} track\_script \{ chk\_nginx \} \} **检查nginx存活脚本check\_nginx.sh:** \#!/bin/bash killall -0 nginx if \[\[ $? -ne 0 \]\]; then systemctl stop keepalived fi
还没有评论,来说两句吧...