zoukankan      html  css  js  c++  java
  • Keepalived 双主虚拟路由配置实例

    Keepalived 双主虚拟路由配置实例

    演示前说明: 

     2台centos7.2 主机:node-00,node-01

    VIP1:10.1.38.19预定node-00占有

    VIP2:10.1.38.20 预定node-01占有

    2台主机安装好keepalived之后,开始编辑配置文件 

    node-00的配置如下 

    复制代码
    ! Configuration File for keepalived
    
    global_defs {
       notification_email {
        root@localhost
       }
       notification_email_from keepalived@localhost           #定义来信人
       smtp_server 127.0.0.1
       smtp_connect_timeout 30
       router_id node-00
       vrrp_mcast_group4 224.0.38.12
    }
    
    vrrp_instance VI_1 {
        state MASTER
        interface team0
        virtual_router_id 38
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass x1er44q
        }
        virtual_ipaddress {
            10.1.38.19/16 dev team0
        }
    
        smtp_alert            #状态切换,使用邮件通知
    }
    
    vrrp_instance VI_2 {
        state BACKUP
        interface team0
        virtual_router_id 39
        priority 97
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass x1er44q
        }
        virtual_ipaddress {
            10.1.38.20/16 dev team0
        }
        smtp_alert
    }
    复制代码

    复制要把备注删掉

    node-01配置如下

    复制代码
    ! Configuration File for keepalived
    
    global_defs {
       notification_email {
        root@localhost
       }
       notification_email_from keepalived@localhost 
       smtp_server 127.0.0.1
       smtp_connect_timeout 30
       router_id node-01
       vrrp_mcast_group4 224.0.38.12
    }
    
    vrrp_instance VI_1 {
        state BACKUP
        interface bond0
        virtual_router_id 38
        priority 97
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass x1er44q
        }
        virtual_ipaddress {
            10.1.38.19/16 dev bond0
        }
        smtp_alert
    }
    
    vrrp_instance VI_2 {
        state MASTER
        interface bond0
        virtual_router_id 39
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass x1er44q
        }
        virtual_ipaddress {
            10.1.38.20/16 dev bond0
        }
        smtp_alert
    }
    复制代码

    配置完成后,启动服务

    #systemctl start keepalived

    使用ip命令查看ip地址情况

    #ip address show

    node-00情况

    node-01情况

    此时,我们模拟node-00宕机,将node-00的keepalived服务停掉,那么10.1.38.19此ip会流动到node-01上

    #systemctl stop keepalived

    至此此部分演示完毕。

  • 相关阅读:
    java 多线程 继承Thread和实现Runnable的区别
    TCP和UDP的区别
    重载与覆盖(java)
    感悟
    ant design + react带有二级导航菜单自动生成
    自己搭建ant design框架
    ant design框架学习
    radio美化
    nodejs-微信公众号 ----答疑机器人
    微信小程序----开发小技巧(二)
  • 原文地址:https://www.cnblogs.com/soymilk2019/p/11053064.html
Copyright © 2011-2022 走看看