免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 49455 | 回复: 29

keepalived vrrp_script 不起作用 [复制链接]

论坛徽章:
0
发表于 2011-08-02 10:48 |显示全部楼层
大家好,最近用keepalived配置一个简单的HA,用vrrp_script来做进程的监控。但是不知道为什么,把进程kill掉后vrrp_script就是不起作用,而且log里也没有相关的信息。我在网上查了很久,配置文件应该没错。不知道有没有碰到过和我一样的情况。我的系统是centos,keepalived版本是1.2.2. 希望各位前辈给指教一下。

keepalived.conf

vrrp_script  check_mysqld {
script "killall -0 mysqld"
interval 2
weight 4
}
vrrp_instance VI_1 {  
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
virtual_ipaddress {
192.168.1.10
}
track_script{
check_mysqld
}

论坛徽章:
0
发表于 2011-08-02 14:26 |显示全部楼层
和我遇到的问题一样~知道的帮忙下!
vrrp_script以及track_interface不起效!
端口可以监控到问题,但是不会影响到服务!

评分

参与人数 1可用积分 +2 收起 理由
kns1024wh + 2 鼓励交流

查看全部评分

论坛徽章:
0
发表于 2011-08-02 14:27 |显示全部楼层
楼上设置应该是
vrrp_script  check_mysqld {
script "killall -0 mysqld"
interval 2
weight -4  这里问题
}

论坛徽章:
0
发表于 2011-08-02 15:32 |显示全部楼层
能否具体一点?谢谢!

论坛徽章:
0
发表于 2011-08-02 15:35 |显示全部楼层
! Configuration File for keepalived
vrrp_script chk_haproxy {
        script "killall -0 haproxy" # cheaper than pidof
        interval 2  # check every 2 seconds
        weight -10 # default prio: -2 if connect fails
        fall   3     # require 2 failures for failures
        rise   1     # require 1 sucesses for ok
}

vrrp_script chk_http_port {
        script "/tcp/127.0.0.1/80" # connects and exits
        interval 1 # check every 1 second
        weight -10 # default prio: -2 if connect fails
        fall   3     # require 2 failures for failures
        rise   1     # require 1 sucesses for ok
}

vrrp_script chk_http {
        script "/etc/keepalived/check_http.sh" # connects and exits
        interval 1 # check every 1 second
        weight -10 # default prio: -2 if connect fails
        fall   3     # require 2 failures for failures
        rise   1     # require 1 sucesses for ok
}
vrrp_script chk_schedown {
   script "if [ -f /var/run/down ]; then exit 1; else exit 0; fi"
   interval 1  # check every 10 seconds
   weight -10   # if failed, decrease 40 of the priority
   fall   1     # require 2 failures for failures
   rise   1     # require 1 sucesses for ok
}


global_defs {
   notification_email {
         xxx.cn
   }
   notification_email_from sns-keepalive-A@xxx.cn
   #smtp_server 127.0.0.1
   #smtp_connect_timeout 30
   router_id Haproxy-haB
}


vrrp_instance VI_1 {
    state BACKUP            
    nopreempt
    garp_master_delay 2
    preempt_delay 300  
    interface eth0
    virtual_router_id 51
    priority 100   
    advert_int 1
    authentication {
        auth_type PASS

        auth_pass 1111
}

virtual_ipaddress {
    192.168.0.188
}

track_script{
    chk_haproxy
    chk_http_port
    chk_http
    chk_schedown
}

track_interface{
eth0   
eth1
    }
}

论坛徽章:
0
发表于 2011-08-02 15:38 |显示全部楼层
上面是配置~
我在这里说明下吧!
我配置了
script{
    chk_haproxy
    chk_http_port
    chk_http
    chk_schedown
}
4个模块加上
track_interface{
eth0   
eth1
    }

这样理论上只要我停HA服务或者停任意端口,服务将自动切到另外一台机器上!
但是我关闭HA和任意端口后,无任何反应!
日志除了有
Aug  2 11:57:43 ha-A Keepalived_healthcheckers: Netlink reflector reports IP 2.2.2.211 removed
Aug  2 11:57:43 ha-A Keepalived_vrrp: Netlink reflector reports IP 2.2.2.211 removed
没有任何其他反应!

感觉VRRP脚本机制本身没生效~ 难道和版本有关?

论坛徽章:
0
发表于 2011-08-02 15:49 |显示全部楼层
本帖最后由 Iinvincible 于 2011-08-02 15:54 编辑

日志里面没有相关的信息。我也试过最新版本还是有问题。难道是少了包?但make的时候没有报错

论坛徽章:
0
发表于 2011-08-02 15:54 |显示全部楼层
不是啊~ 你是weight 4 相当于权重加4,有啥用!
应该是weight -4 减少4

并且你的主从配置是以权重来划分并且差值不要太大!比如100 M  50S 这个你要减很久

论坛徽章:
0
发表于 2011-08-02 16:03 |显示全部楼层
我觉得和这个没有关系

论坛徽章:
0
发表于 2011-08-02 16:05 |显示全部楼层
返回值为真是weight 加4,
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP