Keepalived部署
1.安装
yum install keepalived -y
2.配置
vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id k8singress #标识信息,随便取
}
vrrp_instance VI_1 {
state MASTER #角色,node01为MASTER,node02为BACKUP
interface eth0 #vip绑定的网络端口
virtual_router_id 66 #让master和backup在同一个虚拟路由里,id号必须相同
priority 120 #优先级,谁的优先级高谁就是master;node01为120,node02为110
advert_int 1 #心跳间隔时间
authentication {
auth_type PASS #认证
auth_pass 1111 #密码
}
virtual_ipaddress {
192.168.2.11 #虚拟ip
}
}
3.启动
# 启动
systemctl start keepalived
# 开机启动
systemctl enable keepalived