VRRP
image1.准备环境
- 准备机器lb01 lb02 web01 web02
- lb01 lb02 安装软件
yum install keepalived -y
[root@lb01 nginx]# rpm -qa keepalived
keepalived-1.3.5-8.el7_6.x86_64
[root@lb02 ~]# rpm -qa keepalived
keepalived-1.3.5-8.el7_6.x86_64
2.开启服务与自启动
lb01:
[root@lb01 nginx]# systemctl start keepalived.service
[root@lb01 nginx]# systemctl enable keepalived.service
lb02:
[root@lb02 ~]# systemctl start keepalived.service
[root@lb02 ~]# systemctl enable keepalived.service
2.利用Wireshark抓包
image随便抓个包看看:
image
3.配置文件
image/etc/keepalived/keepalived.conf
配置文件格式:
修改前将源配置文件备份
[root@lb01 nginx]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
}
4.lb01与lb02的keepalived配置文件
image image
测试一下
主关闭后,备接管
image
主恢复后,优先级高于备,自动跳转回来
主
image备
image
网友评论