• 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!
    本文版权归作者和博客园共有,欢迎转载,未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    mysql 全量备份和增量备份
    mysql 修改密码提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    MHA 常见问题解决
    MHA 数据库高可用+ GTID 同步测试部署
    通过电脑抓手机端log
    用js递归遍历树结构
    js实现全屏
    使表格随着内容自适应宽度
    POST请求
    vue中组件通信
  • 原文地址:https://www.cnblogs.com/wangyifu/p/7202575.html
Copyright © 2020-2023  润新知