Keepalived notify not 运行 脚本
Keepalived notify not running the script
我正在使用默认 yum v1.3.5 (03/19,2017) 的 keepalived,git 在 centos 7 (2009) 上提交 v1.3.5-6-g6fa32f2
vip 工作正常,但当我添加通知脚本时,它打开了文件,但没有 运行ning 它(我猜)。这是我备份的配置文件。我使用 root 是因为我在某处读到 keepalived 需要类似于 root 的特权(我可能错了)
! Configuration File for keepalived
global_defs {
enable_script_security
script_user root
}
vrrp_instance VI_1 {
state BACKUP
interface enp0s3
virtual_router_id 51
priority 100 #used in election, 150 for master & 100 for backup
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.11.33/24 dev enp0s3
}
notify "/etc/keepalive/notify.sh"
notify_master "/etc/keepalive/notify_master.sh"
notify_backup "/etc/keepalive/notify_backup.sh"
}
这是我的通知脚本(master 和 backup 有相同的东西)。我已经尝试使用 /bin/bash notify.sh 运行 它并且它有效。脚本权限为755
#!/bin/bash
echo "test" > /etc/keepalived/logs/log.log
当我start/stop主服务器时,备份服务器获得了vip,但文件夹日志中没有任何内容
这是来自 journalctl -u keepalived | 的日志尾巴-n 100
Jan 31 03:17:25 smtp.domain.com systemd[1]: Starting LVS and VRRP High Availability Monitor...
Jan 31 03:17:25 smtp.domain.com Keepalived[17729]: Starting Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2
Jan 31 03:17:25 smtp.domain.com Keepalived[17729]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:25 smtp.domain.com Keepalived[17730]: Starting Healthcheck child process, pid=17731
Jan 31 03:17:25 smtp.domain.com Keepalived[17730]: Starting VRRP child process, pid=17732
Jan 31 03:17:25 smtp.domain.com systemd[1]: Started LVS and VRRP High Availability Monitor.
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering Kernel netlink reflector
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering Kernel netlink command channel
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering gratuitous ARP shared channel
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:25 smtp.domain.com Keepalived_healthcheckers[17731]: Initializing ipvs
Jan 31 03:17:25 smtp.domain.com Keepalived_healthcheckers[17731]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) removing protocol VIPs.
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Using LinkWatch kernel netlink reflector...
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Entering BACKUP STATE
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify_backup.sh
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify.sh
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
Jan 31 03:17:34 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Transition to MASTER STATE
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Entering MASTER STATE
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) setting protocol VIPs.
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify_master.sh
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify.sh
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
对于我使用的临时答案:
放一个cron来检查服务器的当前状态和运行脚本
当前服务器状态命令行
journalctl -u keepalived | grep Entering | awk 'END{print }'
更新:
最后我发现了问题,当我运行 getenforce 时,它return 强制执行。似乎 vrrp_script 不会 运行 除非我制定规则或 setenforce 0
我编辑了 /etc/selinux/config 所以它在我重启后不会重置
SELINUX=permissive
我正在使用默认 yum v1.3.5 (03/19,2017) 的 keepalived,git 在 centos 7 (2009) 上提交 v1.3.5-6-g6fa32f2
vip 工作正常,但当我添加通知脚本时,它打开了文件,但没有 运行ning 它(我猜)。这是我备份的配置文件。我使用 root 是因为我在某处读到 keepalived 需要类似于 root 的特权(我可能错了)
! Configuration File for keepalived
global_defs {
enable_script_security
script_user root
}
vrrp_instance VI_1 {
state BACKUP
interface enp0s3
virtual_router_id 51
priority 100 #used in election, 150 for master & 100 for backup
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.11.33/24 dev enp0s3
}
notify "/etc/keepalive/notify.sh"
notify_master "/etc/keepalive/notify_master.sh"
notify_backup "/etc/keepalive/notify_backup.sh"
}
这是我的通知脚本(master 和 backup 有相同的东西)。我已经尝试使用 /bin/bash notify.sh 运行 它并且它有效。脚本权限为755
#!/bin/bash
echo "test" > /etc/keepalived/logs/log.log
当我start/stop主服务器时,备份服务器获得了vip,但文件夹日志中没有任何内容
这是来自 journalctl -u keepalived | 的日志尾巴-n 100
Jan 31 03:17:25 smtp.domain.com systemd[1]: Starting LVS and VRRP High Availability Monitor...
Jan 31 03:17:25 smtp.domain.com Keepalived[17729]: Starting Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2
Jan 31 03:17:25 smtp.domain.com Keepalived[17729]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:25 smtp.domain.com Keepalived[17730]: Starting Healthcheck child process, pid=17731
Jan 31 03:17:25 smtp.domain.com Keepalived[17730]: Starting VRRP child process, pid=17732
Jan 31 03:17:25 smtp.domain.com systemd[1]: Started LVS and VRRP High Availability Monitor.
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering Kernel netlink reflector
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering Kernel netlink command channel
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Registering gratuitous ARP shared channel
Jan 31 03:17:25 smtp.domain.com Keepalived_vrrp[17732]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:25 smtp.domain.com Keepalived_healthcheckers[17731]: Initializing ipvs
Jan 31 03:17:25 smtp.domain.com Keepalived_healthcheckers[17731]: Opening file '/etc/keepalived/keepalived.conf'.
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) removing protocol VIPs.
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Using LinkWatch kernel netlink reflector...
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Entering BACKUP STATE
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify_backup.sh
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify.sh
Jan 31 03:17:30 smtp.domain.com Keepalived_vrrp[17732]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
Jan 31 03:17:34 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Transition to MASTER STATE
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Entering MASTER STATE
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) setting protocol VIPs.
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify_master.sh
Jan 31 03:17:35 smtp.domain.com Keepalived_vrrp[17732]: Opening script file /etc/keepalived/notify.sh
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
Jan 31 03:17:40 smtp.domain.com Keepalived_vrrp[17732]: Sending gratuitous ARP on enp0s3 for 192.168.11.33
对于我使用的临时答案: 放一个cron来检查服务器的当前状态和运行脚本
当前服务器状态命令行
journalctl -u keepalived | grep Entering | awk 'END{print }'
更新:
最后我发现了问题,当我运行 getenforce 时,它return 强制执行。似乎 vrrp_script 不会 运行 除非我制定规则或 setenforce 0
我编辑了 /etc/selinux/config 所以它在我重启后不会重置
SELINUX=permissive