标签:pad inux efs ica yum 配置文件 vip router outer
Keepalived是Linux下面实现VRRP备份路由的高可靠性运行软件,能够真正做到主服务器和备份服务器故障时IP瞬间无缝交接
部署过程
两台机器安装nginx和keepalived
192.168.10.130 node 192.168.10.140 node 192.168.10.120 VIP 192.168.10.121 VIP
两台机器都安装
yum install -y nginx keepalived
健康检查脚本
cat /server/scripts/check_nginx.sh #!/bin/bash # check nginx service run=`ps -C nginx --no-header | wc -l` if [ $run -eq 0 ] then /etc/rc.d/init.d/nginx start sleep 3 fi
node上的keepalived配置
cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived global_defs { vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chk_nginx{ script "/server/scripts/check_nginx.sh" interval 2 weight 2 } #VIP1 vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 50 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.10.20 } } track_script { check_nginx } #VIP2,新增配置,新增一个实例VI_2 vrrp_instance VI_2 { state BAKCUP interface eth0 virtual_router_id 51 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.10.21 } }
另外一台node的keepalived的配置文件
! Configuration File for keepalived global_defs { vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chk_nginx{ script "/server/scripts/check_nginx.sh" interval 2 weight 2 } #VIP1 vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 50 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.10.20 } } track_script { check_nginx } #VIP2,新增的实例,VI_2 vrrp_instance VI_2 { state MASTER interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.10.21 } }
配置完成启动服务即可
systemctl enable keepalived && systemctl start keepalived systemctl enable nginx && systemctl start nginx
至此部署完成
CentOS 7.8 部署nginx+keepalived双主配置
标签:pad inux efs ica yum 配置文件 vip router outer
原文地址:https://www.cnblogs.com/huanglingfa/p/13823937.html