您的位置:首页 > 运维架构 > Nginx

keepalived+nginx高可用环境搭建

2017-11-28 10:55 465 查看
MASTER:192.168.101.132

BACKUP:192.168.101.133

真实主机zabbix:192.168.101.131

虚IP:192.168.101.138

1、安装nginx和keepalived,需要安装依赖

yum -y install gcc pcre-devel zlib-devel openssl-devel


2、对于keepalived,配置文件中的说明

! Configuration File for keepalived

global_defs {
notification_email {
wanghaikuo@hysec.com
wanghaikuo@gmail.com
}

notification_email_from wanghaikuo@hysec.com
smtp_server smtp.hysec.com
smtp_connect_timeout 30
router_id nginx_master

}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 101        #要比backup多至少50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
50.1.1.2      #并不需要在网卡中配置虚IP,只是在这里写明即可;
}
}

3、对于监控脚本

需要在下面加入如下行:

vrrp_script chk_http_port {
script "/opt/chk_nginx.sh"
interval 2
weight 2
}

track_script {               #这里是必须要添加的,否则无法检测到脚本的存在;
chk_http_port
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: