美文网首页工作生活
Keepalived高可用

Keepalived高可用

作者: 杨丶子 | 来源:发表于2019-07-03 20:47 被阅读0次

    VRRP

    image

    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抓包

    image

    随便抓个包看看:

    image

    3.配置文件

    /etc/keepalived/keepalived.conf

    image

    配置文件格式:

    修改前将源配置文件备份

    [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

    相关文章

      网友评论

        本文标题:Keepalived高可用

        本文链接:https://www.haomeiwen.com/subject/okhhhctx.html