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……
...全文
3419 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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.

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧