|
Keepalived + nginx installation deployment hosts: IP- > 10.252.3.160 nginx installed OK (omitted) preparation machine: IP- > 10.252.3.161 nginx installed OK (omitted) VIP: 10.252.3.162 The first step: AMB installed with keepalived yum installkeepalived – y Step Two: configure /etc/keepalived/keepalived.conf host 10.252.3.160 configured as follows: configuration File for keepalived global_defs { notification_email {! acassen@firewall.loc # for message destination failover@firewall.loc sysadmin@firewall.loc } notification_email_from root @ nginx2 # for message source address smtp_server 127.0.0.1 #smtp server smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_scriptchk_http_port { script "/ data / script / nginx.sh " # monitoring service footsteps interval 2 # detection interval (execution step interval) weight 2 } vrrp_instanceVI_1 { state mASTER the difference between point # standby, logo interface eth1 # corresponding card virtual_router_id 60 priority 101 # priority, who call the shots (the greater the value, the higher the priority) advert_int 2 authentication { # authentication, and password must be the primary backup as auth_type PASS auth_pass 1234 } track_interface { # monitor card. If only monitoring service, where you can not fill eth1 } track_script { # to script to monitor chk_http_port in front fill chk_http_port } virtual_ipaddress { # switching mode. Switching Virtual IP 10.252.3.165/24 dev eth1 label eth1: 1 } } ====== ============================================= Preparation configuration: 10.252.3.161 configuration File for keepalived global_defs { notification_email { acassen@firewall.loc # for message destination address failover@firewall.loc sysadmin@firewall.loc } notification_email_from root @ nginx2 # for message source address smtp_server 127.0.0.1 #smtp server smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_scriptchk_http_port { script "/data/script/nginx.sh" # monitoring service footsteps interval 2 # detection interval (execution step interval) weight 2 } vrrp_instanceVI_1 { state bACKUP the difference between the primary and secondary point #, logos interface eth1 # corresponding card virtual_router_id 60 priority 100 # priority, who call the shots (the greater the value, the priority level higher) advert_int 2 authentication { # authentication mode and password must be the primary backup as auth_type PASS auth_pass 1234 } track_interface { # monitor card. If only monitoring service, where you can not fill eth1 } track_script { # to script to monitor chk_http_port in front fill chk_http_port } virtual_ipaddress { # switching mode. Switching Virtual IP 10.252.3.165/24 dev eth1 label eth1: 1 } } The third step: write / data / script / nginx.sh script content # / bin / sh nginxPidNum = `ps-C nginx --no-header |! wc -l` keepalivedPidNum =` ps-C keepalived --no-header | wc -l` if [$ nginxPidNum -eq 0]; then killall keepalived elif [$ keepalivedPidNum -eq 0]; then service keepalived start fi script permissions to chmod + x /data/script/nginx.sh step Four: start standby keepalived Servicekeepalived start Ifconfig View eth1: 1 whether up. If you up, you can test. No self-commissioning. |
|
|
|