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 &

posted @ 2017-07-18 20:36  王亦福-Jeff  阅读(760)  评论(0编辑  收藏  举报