Keepalived 部署

keepalived在线上发现的一些问题:

虚拟IP(VIP)最好在同一网段

 

./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.32-279.el6.x86_64/

 

 

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

 

cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

 

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/

 

mkdir /etc/keepalived

 

/usr/etc/sysconfig/keepalived 

 

/etc/rc.d/init.d/keepalived stop

 

/etc/rc.d/init.d/keepalived start

 

手动加载 ip_vs模块

 

modprobe ip_vs

modprobe ip_vs_wrr

 

 

vi /etc/keepalived/keepalived.conf

 

 

! Configuration File for keepalived

 

global_defs {

   notification_email {

      [email protected]

   }

   notification_email_from [email protected]

   smtp_server smtp.qq.com

  # smtp_connect_timeout 30

   router_id LVS_DEVEL

}

 

# VIP1

vrrp_instance VI_1 {

    state BACKUP            

    interface em1

    virtual_router_id 60

    priority 50   

    advert_int 5

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.50.100

    }

}

 

 

检测shell:

 

#!/bin/bash

while :

    do

        nginxpid=`ps -C nginx --no-header | wc -l`

        if [ $nginxpid -eq 0 ];then                

                /etc/rc.d/init.d/keepalived stop

        fi

        sleep 5

done

你可能感兴趣的:(keepalived)