且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CentOS 7.0 安装keepalived

更新时间:2022-09-05 15:12:43

1、安装目录包

yum install -y net-tools psmisc
2、安装keepalived

yum install -y ipvsadm keepalived
3、master配置文件

! Configuration File for keepalived
global_defs {
notification_email {br/>acassen@firewall.loc
failover@firewall.loc
br/>sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_nginx {
script "killall -0 nginx"
interval 1
weight -15
}
vrrp_instance VI_1 {
state MASTER
interface eno16777736
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.1.10
}
track_script {
chk_nginx
}
}
4、backup配置文件

! Configuration File for keepalived
global_defs {
notification_email {
br/>acassen@firewall.loc
failover@firewall.loc
br/>sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_nginx {
script "killall -0 nginx"
interval 1
weight -15
}
vrrp_instance VI_1 {
state BACKUP
interface eno16777736
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.1.10
}
track_script {
chk_nginx
}
}
5、设置开启启动和启动keepalived

systemctl enable keepalived
systemctl start keepalived

本文转自 Lee_吉  博客,原文链接:   http://blog.51cto.com/12173069/2051251     如需转载请自行联系原作者