`
lionlx
  • 浏览: 282819 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

nginx+keepalived单主高可用负载均衡配置

阅读更多
keepalived主:

## Configuration File for keepalived
global_defs {
   notification_email {
     user@163.com
   }

   notification_email_from keepalived@163.com
   smtp_server localhost
   smtp_connect_timeout 30
   router_id a1      ##uniq
}

vrrp_script chk_tengine {
    script "/etc/keepalived/chk_tengine_status.sh"
    ####script "killall -0 nginx"
    interval 1
    weight 20
}

vrrp_instance VI_1 {
    state MASTER
    interface em1
    virtual_router_id 30
    priority 110            ## uniq
    advert_int 1
    grap_master_delay 1
    authentication {
        auth_type PASS
        auth_pass a30
    }

    track_interface {
        em1    
    }

    virtual_ipaddress {
        10.10.10.30
    }

    track_script {
        chk_tengine    
    }
}

keepalived从:
## Configuration File for keepalived
global_defs {
   notification_email {
     user@163.com
   }

   notification_email_from keepalived@163.com
   smtp_server localhost
   smtp_connect_timeout 30
   router_id a2         ## uniq
}

vrrp_script chk_tengine {
    script "/etc/keepalived/chk_tengine_status.sh"
    ####script "killall -0 nginx"
    interval 1
    weight 20
}

vrrp_instance VI_1 {
    state BACKUP            ## uniq
    interface eth0
    virtual_router_id 30
    priority 100            ## uniq
    advert_int 1
    grap_master_delay 1
    authentication {
        auth_type PASS
        auth_pass a30
    }

    track_interface {
        eth0
    }

    virtual_ipaddress {
        10.10.10.30
    }

    track_script {
        chk_tengine    
    }
}

chk_tengine_status.sh:
#!/bin/sh
## check process nginx exit

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

count=`ps xau|grep -v grep |grep nginx  -c`
if [ $count -gt 0 ]
then
    exit 0
else
    exit 2
fi
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics