notify_master is only automatically executed when the switch occurs on one server #2527
Description
We have configured two servers with IPs: one is 192.168.2.203 and the other is 192.168.2.229, with a VIP of 192.168.2.111. When 229 switches from backup to master, it can automatically execute the notify_master bound shell script. However, when 203 switches from backup to master, the notify_master bound shell script does not execute. SELinux has been configured to a disabled state.
192.168.2.229 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_229
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface eno3
virtual_router_id 51
priority 255
advert_int 1
authentication {
auth_type PASS
auth_pass xxx
}
virtual_ipaddress {
192.168.2.111
}
notify_master "/usr/libexec/keepalived/enable_write.sh"
}
192.168.2.203 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_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval
}
vrrp_instance VI_1 {
state BACKUP
interface eno3
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass xxx
}
virtual_ipaddress {
192.168.2.111
}
notify_master /usr/libexec/keepalived/enable_write.sh
}
my /usr/libexec/keepalived/enable_write.sh:
#!/bin/bash
echo "$(date '+%Y-%m-%d %H:%M:%S') - Executing SELECT pg_promote();" >> /var/log/keepalived.log
echo "Enabling write access to the database"
sudo -u postgres psql -c "SELECT pg_promote();" >> /var/log/keepalived.log 2>&1
echo "Executed!!!!!!!!!!!!!!!!!!!!!!!!!"
journalctl -u keepalived -f, 192.168.203:
1月 18 19:22:41 localhost.localdomain Keepalived_vrrp[15322]: VRRP_Instance(VI_1) Transition to MASTER STATE
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: VRRP_Instance(VI_1) Entering MASTER STATE
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: VRRP_Instance(VI_1) setting protocol VIPs.
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:42 localhost.localdomain Keepalived_vrrp[15322]: Opening script file /usr/libexec/keepalived/enable_write.sh
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on eno3 for 192.168.2.111
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
1月 18 19:22:47 localhost.localdomain Keepalived_vrrp[15322]: Sending gratuitous ARP on eno3 for 192.168.2.111
I have already tried disabling SELinux, but even after 192.168.2.203 switches to master, the notify_master bound enable_write.sh script still does not execute automatically
The enable_write.sh file has 755 permissions.
help!!! help!!!