zoukankan      html  css  js  c++  java
  • Keepalived 单纯的IP漂移更简单

    Keepalived 单纯的IP漂移更简单。
    Heartbeat  对资源服务控制,更适合 存储的高可用。


      Keepalived安装
             yum install keepalived -y
             rpm -qa keepalived
     
    启动停止
          /etc/init.d/keepalived start
          /etc/init.d/keepalived stop

    配置文件:


    主配置文件

    /etc/keepalived/keepalived.conf

    ! Configuration File for keepalived


    global_defs {

       notification_email {

         jeff@yunqichina.com

       }

       notification_email_from Alexandre.Cassen@firewall.loc

       smtp_server 192.168.200.1

       smtp_connect_timeout 30

       router_id LVS_01

    }


    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 {

            192.168.100.222/24

        }

    }


    主配置VIP地址:

    ip addr add 192.168.100.222/24 dev eth0



    备配置文件


    /etc/keepalived/keepalived.conf

    ! Configuration File for keepalived


    global_defs {

       notification_email {

         jeff@yunqichina.com

       }

       notification_email_from Alexandre.Cassen@firewall.loc

       smtp_server 192.168.200.1

       smtp_connect_timeout 30

       router_id LVS_02

    }


    vrrp_instance VI_1 {

        state MASTER

        interface eth0

        virtual_router_id 51

        priority 100

        advert_int 1

        authentication {

            auth_type PASS

            auth_pass 1111

        }

        virtual_ipaddress {

            192.168.100.222/24

        }

    }


    keepalived 只对服务器接管


    一个网段多组keepalived 时使用多播地址:


    global_defs {

                  router_id LVS_19

                  vrrp_mcast_group4 224.0.0.19 #<==这个就是指定多播地址的配置

           }

                       


    当Nginx停止自动停止keepalived 服务脚本


    mkdir -p /server/scripts

    cd /server/scripts

    ll

    vim check_web.sh

    #!/bin/sh

    while true

    if [~ps -er | grep nginx |grep -v grep| wc -l ~ -lt 3 ]

           then /etc/init.d/keepalived stop

    fi

    sleep 10

    done


    后台执行

    sh check_web.sh &

    北丐洪七公--Jeff
    Dignity comes from strength, strength comes from struggle!
    本文版权归作者和博客园共有,欢迎转载,未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    Linux CentOS6环境下MySQL5.1升级至MySQL5.5版本过程
    linux卸载mysql
    springboot2.x+security对明文密码加密
    AJAX模拟登录注册
    Jedis工具类
    java连接Redis
    centOS 6.5 以及7以上的开启端口,以及重启防火墙指令
    Mybatis连接数据库错误he server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one
    Git clone时出现Please make sure you have the correct access rights and the repository exists.问题已解决。
    Spring Cloud-集群配置的eureka
  • 原文地址:https://www.cnblogs.com/wangyifu/p/7202575.html
Copyright © 2011-2022 走看看