第一步:安装
yum -y install keepalived
第二步:配置 /etc/keepalived/keepalived.conf
! Configuration File for keepalived global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL01 #这个id 相当与mysql的server_id ,类似router_id 也要求在每一个keepalived 上保持唯一。
} vrrp_instance VI_1 {
state MASTER #这是keepalived 实例的角色信息,然而真正的主从是由priority 的决定的。
interface eno16777736 #网卡接口名
virtual_router_id 51#这个要对两个keepalvied实例中保持一致。
priority 100 #权重
advert_int 1 #心跳检测间隔
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.80.100/24 #vip/mask
}
}
第三步:启动keepalived
keepalived -D -f /etc/keepalived/keepalived.conf