第十二周-day52(下)-Keepalived高可用

Keepalived高可用软件

第十二周-day52(下)-Keepalived高可用_第1张图片

VRRP

第十二周-day52(下)-Keepalived高可用_第2张图片

1.准备环境

  1. 准备机器lb01 lb02 web01 web02
  2. 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抓包

第十二周-day52(下)-Keepalived高可用_第3张图片

随便抓个包看看:
第十二周-day52(下)-Keepalived高可用_第4张图片

3.配置文件

/etc/keepalived/keepalived.conf

第十二周-day52(下)-Keepalived高可用_第5张图片

配置文件格式:

修改前将源配置文件备份

[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配置文件

第十二周-day52(下)-Keepalived高可用_第6张图片
第十二周-day52(下)-Keepalived高可用_第7张图片

测试一下

主关闭后,备接管
主恢复后,优先级高于备,自动跳转回来


第十二周-day52(下)-Keepalived高可用_第8张图片

第十二周-day52(下)-Keepalived高可用_第9张图片

问题:现在只是停掉了高可用软件来测试,如果nginx挂了或断网了还能跳转吗,怎么办?

你可能感兴趣的:(第十二周-day52(下)-Keepalived高可用)