Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56269
  • 博文数量: 22
  • 博客积分: 585
  • 博客等级: 中士
  • 技术积分: 230
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-16 14:36
个人简介

...

文章分类

全部博文(22)

文章存档

2013年(7)

2011年(9)

2010年(2)

2009年(4)

我的朋友

分类: 系统运维

2013-08-14 10:32:42

[root@XXX-ngix01 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived


global_defs {
   notification_email {
     wei.zhou@XXX.com
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server mail.XXX.com
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_script chk_nginx { 
    script "/etc/keepalived/nginx_pid.sh"
    interval 2
    weight 3
}


vrrp_instance VI_1 {
    state MASTER
    interface em1
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
       222.XXX.250.162 
    }
    track_script {
        chk_nginx
    }
}


vrrp_instance VI_2 {
    state BACKUP
    interface em1
    virtual_router_id 52
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        222.XXX.250.163
    }
    track_script {
        chk_nginx
    }
}



[root@XXX-ngix01 ~]# cat /etc/keepalived/nginx_pid.sh 
# vi /etc/keepalived/nginx_pid.sh
        #!/bin/bash 
        #version 0.0.1 
        # 
        touch /root/keepalived.test
        A=`ps -C nginx --no-header |wc -l` 
        if [ $A -eq 0 ];then 
        #  /usr/sbin/nginx 
              service nginx start 
                      sleep 3 
                        if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then 
        #                       killall keepalived 
                                service  keepalived stop 
        fi 
        fi 



[root@XXX-ngix01 ~]# ip a list
1: lo: mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: em1: mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:22:19:5d:19:ed brd ff:ff:ff:ff:ff:ff
    inet 222.XXX.250.208/25 brd 222.73.250.255 scope global em1
    inet 222.XXX.250.162/32 scope global em1
    inet6 fe80::222:19ff:fe5d:19ed/64 scope link 
       valid_lft forever preferred_lft forever
3: em2: mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:22:19:5d:19:ef brd ff:ff:ff:ff:ff:ff
    inet 192.168.25.178/24 brd 192.168.25.255 scope global em2
    inet6 fe80::222:19ff:fe5d:19ef/64 scope link 
       valid_lft forever preferred_lft forever
4: em3: mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:22:19:5d:19:f1 brd ff:ff:ff:ff:ff:ff
5: em4: mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:22:19:5d:19:f3 brd ff:ff:ff:ff:ff:ff

阅读(409) | 评论(0) | 转发(0) |
0

上一篇:nginx配置

下一篇:named配置

给主人留下些什么吧!~~