zoukankan      html  css  js  c++  java
  • 高可用keepalived的抢占式与非抢占式

    1.两个节点都启动

    #由于节点1的优先级高于节点2,所以VIP在节点1上面
    [root@lb01 ~]# ip addr | grep 10.0.0.3
        inet 10.0.0.3/32 scope global eth0
    
    [root@lb02 ~]# ip addr | grep 10.0.0.3

    2.停止主节点

    [root@lb01 ~]# systemctl stop keepalived
    
    #节点2联系不上节点1,主动接管VIP
    [root@lb02 ~]# ip addr | grep 10.0.0.3
        inet 10.0.0.3/32 scope global eth0

    3.重新启动主节点

    [root@lb01 ~]# systemctl start keepalived
    
    #由于节点1的优先级高于节点2,所以恢复节点1之后,vip又漂回节点1
    [root@lb01 ~]# ip addr | grep 10.0.0.3
        inet 10.0.0.3/32 scope global eth0

    4.配置非抢占式

    1)节点一修改

    [root@lb01 ~]# vim /etc/keepalived/keepalived.conf 
    ... ...
    vrrp_instance VI_1 {
        state BACKUP
        nopreempt
        ......
    }
    
    [root@lb01 ~]# systemctl restart keepalived

    2)节点2修改

    [root@lb02 ~]# vim /etc/keepalived/keepalived.conf 
    ... ...
    vrrp_instance VI_1 {
        state BACKUP
        nopreempt
        ......
    }
    
    [root@lb02 ~]# systemctl restart keepalived

    3)配置注意事项

    1.两台机器节点状态都要改成 BACKUP
    2.两个节点都要加上 nopreempt
    3.优先级不需要改变

    5.访问页面测试

    #配置hosts
    10.0.0.3 linux.blog.com
    
    #访问页面
    http://linux.blog.com/
    
    #节点测试
    [root@lb01 ~]# ip addr | grep 10.0.0.3
        inet 10.0.0.3/32 scope global eth0
    #访问网站,并且windows查看mac地址测试
    C:Users11764>arp -a
        VIP                        VMAC
      10.0.0.3              00-0c-29-d7-bc-2c     动态
      10.0.0.4              00-0c-29-d7-bc-2c     动态
      10.0.0.5              00-0c-29-89-2f-10     动态
      
    #关闭节点1keepalived
    [root@lb01 ~]# systemctl stop keepalived.service
    [root@lb02 ~]# ip addr | grep 10.0.0.3
        inet 10.0.0.3/32 scope global eth0
    #访问网站,并且windows查看mac地址测试
    C:Users11764>arp -a
        VIP                        VMAC
      10.0.0.3              00-0c-29-89-2f-10     动态
      10.0.0.4              00-0c-29-d7-bc-2c     动态
      10.0.0.5              00-0c-29-89-2f-10     动态
  • 相关阅读:
    1.C和C++区别,以及const分析(底层const/顶层const)
    4.移植驱动到3.4内核-移植总结
    3.移植驱动到3.4内核-移植DM9000C驱动
    2.移植3.4内核-支持烧写yaffs2,裁剪内核并制作补丁
    Android Support v4、v7、v13、v14、v17的区别和应用场景
    Android利用canvas画各种图形
    ActionBar 自定义布局定义
    android动画坐标定义
    GitHub上最著名的Android播放器开源项目大全
    CardView 简介和使用
  • 原文地址:https://www.cnblogs.com/chenlifan/p/13652518.html
Copyright © 2011-2022 走看看