keepalived 1.2.7 notify_master脚本不执行

zimu312500 2014-02-20 07:35:14
我的keepalived.conf

! Configuration File for keepalived

global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.1.19.250
}
notify_backup "/etc/keepalived/notify.sh backup"
notify_master "/etc/keepalived/notify.sh master"
#notify_backup "/bin/echo backup >> /etc/keepalived/temp.txt"
#notify_master "/bin/echo master >> /etc/keepalived/temp.txt"
}

virtual_server 10.1.19.250 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP

real_server 10.1.19.12 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 30
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.1.19.13 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 30
nb_get_retry 3
delay_before_retry 3
}
}
}

赋予了notify.sh 777的权限,但是当keepalived状态发送切换时,notify.sh并未执行,并且/etc/keepalived/notify.sh backup能生成结果,notify.sh的内容如下:

#!/bin/bash

case "$1" in
master)
echo master >> temp.txt
;;
backup)
echo backup >> temp.txt
;;
*)
echo nothing >> temp.txt
;;
esac

经过试验通过以下可以正确执行,但换成脚本就是不行。

#notify_backup "/bin/echo backup >> /etc/keepalived/temp.txt"
#notify_master "/bin/echo master >> /etc/keepalived/temp.txt"

找了很多资料未解,请给位帮忙,thanks……
...全文
2025 点赞 收藏 6
写回复
6 条回复
平原2018 2016年05月13日
你的问题解决了吗?脚本是什么问题,我现在遇到同样的问题 virtual_server 192.168.10.200 3306 { delay_loop 2 lb_algo wrr lb_kind DR protocol TCP persistence_timeout 60 real_server 192.168.10.88 3306 { notify_down /etc/keepalived/db_down.sh weight 1 TCP_CHECK { connect_port 3306 connect_timeout 3 nb_get_retry 2 delay_before_retry 1 } 其中notify_down /etc/keepalived/db_down.sh 这一行就是不执行,我怀疑 监控检查real_server的时候出的问题 同时还有一个问题,我的keepalived少一个进程,如下 [root@host1 keepalived]# ps -fe | grep kee root 3410 1 0 16:39 ? 00:00:00 keepalived -D -d -S 0 root 3412 3410 0 16:39 ? 00:00:00 keepalived -D -d -S 0 root 3528 2942 0 16:58 pts/0 00:00:00 grep kee
回复 点赞
fwh20 2016年01月19日
#!/bin/bash case $3 in MASTER) echo master >> temp.txt ;; BACKUP) echo backup >> temp.txt ;; *) echo nothing >> temp.txt ;; esac 请注意红色处,同时脚本权限为777
回复 点赞
游侠wl 2014年09月26日
能告诉一下脚本有什么问题吗,我也是这种问题,不知道原因何在
回复 点赞
zimu312500 2014年02月21日
其实发现并不是没有执行,而是执行的脚本有问题,土了!
回复 点赞
zimu312500 2014年02月20日
回复 点赞
zimu312500 2014年02月20日
补充下重启keepalived时的日志,并未发现执行脚本的踪迹,求解!

Feb 20 19:31:59 host1 Keepalived[1681]: Stopping Keepalived v1.2.7 (02/14,2014)
Feb 20 19:31:59 host1 Keepalived_vrrp[1683]: VRRP_Instance(VI_1) sending 0 priority
Feb 20 19:31:59 host1 Keepalived_vrrp[1683]: VRRP_Instance(VI_1) removing protocol VIPs.
Feb 20 19:31:59 host1 Keepalived[1727]: Starting Keepalived v1.2.7 (02/14,2014)
Feb 20 19:31:59 host1 Keepalived[1728]: Starting Healthcheck child process, pid=1729
Feb 20 19:31:59 host1 Keepalived[1728]: Starting VRRP child process, pid=1730
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Interface queue is empty
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Netlink reflector reports IP 10.1.19.11 added
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Netlink reflector reports IP fe80::5054:ff:fe06:1799 added
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Interface queue is empty
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Registering Kernel netlink reflector
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Netlink reflector reports IP 10.1.19.11 added
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Registering Kernel netlink command channel
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Registering gratuitous ARP shared channel
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Netlink reflector reports IP fe80::5054:ff:fe06:1799 added
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Registering Kernel netlink reflector
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Registering Kernel netlink command channel
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Opening file '/etc/keepalived/keepalived.conf'.
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Opening file '/etc/keepalived/keepalived.conf'.
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Configuration is using : 14363 Bytes
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Configuration is using : 63800 Bytes
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: Using LinkWatch kernel netlink reflector...
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) Entering BACKUP STATE
Feb 20 19:31:59 host1 Keepalived_vrrp[1730]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Using LinkWatch kernel netlink reflector...
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Activating healthchecker for service [10.1.19.12]:80
Feb 20 19:31:59 host1 Keepalived_healthcheckers[1729]: Activating healthchecker for service [10.1.19.13]:80
Feb 20 19:32:00 host1 Keepalived_healthcheckers[1729]: TCP connection to [10.1.19.13]:80 failed !!!
Feb 20 19:32:00 host1 Keepalived_healthcheckers[1729]: Removing service [10.1.19.13]:80 from VS [10.1.19.250]:80
Feb 20 19:32:00 host1 Keepalived_healthcheckers[1729]: Remote SMTP server [192.168.200.1]:25 connected.
Feb 20 19:32:03 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) Transition to MASTER STATE
Feb 20 19:32:04 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) Entering MASTER STATE
Feb 20 19:32:04 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) setting protocol VIPs.
Feb 20 19:32:04 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.19.250
Feb 20 19:32:04 host1 Keepalived_healthcheckers[1729]: Netlink reflector reports IP 10.1.19.250 added
Feb 20 19:32:09 host1 Keepalived_vrrp[1730]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.19.250
Feb 20 19:32:30 host1 Keepalived_healthcheckers[1729]: Timeout reading data to remote SMTP server [192.168.200.1]:25.
回复 点赞
发动态
发帖子
系统维护与使用区
创建于2007-08-27

5683

社区成员

7.4w+

社区内容

系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区公告
暂无公告