本文共 1143 字,大约阅读时间需要 3 分钟。
nginx 安装
rpm -ivh
yum install nginx#设置开机启动
systemctl enable nginx.service#启动服务
systemctl start nginx.servicekeepalived 安装
#安装keepavlivedyum -y install keepalived#设置开机启动
systemctl enable nginx.service#启动服务
service keepalived startkeepavlived mater设置
global_defs {
notification_email {vrrp_instance VI_1 {
state MASTERinterface eth0lvs_sync_daemon_interface eth0virtual_router_id 151priority 100advert_int 5nopreemptauthentication { auth_type PASSauth_pass 1111}#VIPvirtual_ipaddress { 172.16.101.193}track_script { chk_nginx}}keepavlived backup 设置
cat keepalived.confglobal_defs {
notification_email {vrrp_instance VI_1 {
state BACKUPinterface eth0lvs_sync_daemon_interface eth0virtual_router_id 151priority 90advert_int 5authentication { auth_type PASSauth_pass 1111}#VIPvirtual_ipaddress { 172.16.101.193}track_script { chk_nginx}}脚本:
cat /etc/keepalived/chk_nginx.sh#!/bin/sh
A=ps -C nginx --no-header |wc -l
if [ $A -eq 0 ];thensystemctl start nginx.servicesleep 2if [ ps -C nginx --no-header |wc -l
-eq 0 ];thensystemctl stop keepalivedfifi 转载于:https://blog.51cto.com/guoshaoliang789/2163779