-
-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keepalived issue with haproxy #2485
Comments
You will need to provide copies of your keepalived configurations, and also any track_scripts that you are using. Then we can have a look at it. |
PFB the configuration settings: server 1: [root@testbed06 postgres]# cat /etc/keepalived/keepalived.conf vrrp_script chk_haproxy_down { vrrp_script chk_both_haproxy_down { vrrp_instance VI_1 {
} Define the path to Keepalived's control socket or state file (if applicable)KEEPALIVED_VRRP_INSTANCE="VI_1" Local HAProxy status checkif killall -0 haproxy >/dev/null 2>&1; then
fi server 2: [postgres@testbed09-1664 ~]$ cat /etc/keepalived/keepalived.conf vrrp_script chk_haproxy_down { vrrp_script chk_both_haproxy_down { #vrrp_script chk_master_haproxy { script "ssh [email protected] 'killall -0 haproxy' || echo 1"interval 5weight 10#} vrrp_instance VI_1 { chk_both_haproxy_down} notify_master /etc/keepalived/start_haproxy.sh Define the path to Keepalived's control socket or state file (if applicable)KEEPALIVED_VRRP_INSTANCE="VI_1" Local HAProxy status checkif killall -0 haproxy >/dev/null 2>&1; then |
There appear to be a number of issues:
I don't know why keepalived is not taking over as master on test1 when keepalived is stopped on test2, but I suggest you correct the issues identified above first, and if you are still experiencing the original problem you will need to post the full keepalived logs from both systems. Also, if you execute |
I have changed the setting now : Master: [postgres@testbed06 ~]$ cat /etc/keepalived/keepalived.conf vrrp_script chk_haproxy { vrrp_instance VI_1 {
} BAckup: [postgres@testbed09-1664 ~]$ cat /etc/keepalived/keepalived.conf vrrp_script chk_haproxy { vrrp_instance VI_1 { notify_master /etc/keepalived/start_haproxy.sh when I shutdown the haproxy on testbed09 the service do not get to testbed06 because priority is 91 on it PFb the logs of both and I unable to find the /tmp/keepalived master log output : [postgres@testbed09-1664 ~]$ systemctl status keepalived Oct 29 12:32:32 testbed09-1664 Keepalived_vrrp[2761616]: (VI_1) Changing effective priority from 98 to 100 backup log : [postgres@testbed06 ~]$ systemctl status keepalived Oct 29 12:30:10 testbed06 Keepalived_vrrp[352794]: Sending gratuitous ARP on enp1s0 for 10.114.16.72 |
The file produced by I think your problem is that when a VRRP instance is in the backup state, you stop ha_proxy, and only start it again once the VRRP instance transitions to master state. So when keepalived is running on both testbed06 and testbed09, the VRRP instances start in backup mode (and haproxy is not running), so testbed06 has priority 99 (101 - 2) and testbed09 has priority 98 (100 - 2). testbed06 has higher priority and so becomes VRRP master, haproxy is started, and the VRRP instance priority increases to 101. You then stop haproxy on testbed06, and so the VRRP priority reduces to 99, but this is still higher than testbed09, and so testbed06 remains the VRRP master. I think you need to not have keepalived starting and stopping haproxy, and then it should work. |
Thank you for the update I have removed the starting and stopping haproxy in keepalived but still having the same issue because when priority get low on backup keepalived as it is testbed06 has priority 99 (101 - 2) and testbed09 has priority 98 (100 - 2) after stopping the service on testbed06 the priority becomes 99 and on testbed09 has already priority 98 so the VIP do not switch. I think failover (HA) for haproxy is not possible with keepalived as per my best knowledge and after performing many tests. Kindly can you share your expert opinion on the above test case. |
Thank you for the update. |
In the sample configurations I have seen don't specify an IP address to bind to, e.g.:
Doing it that way, you should not have a problem with the VIP not being present. |
Thank you for the update. I still think HA is not possible for haproxy using keepalived. Any idea ? PFB the output : Backup testbed09: Oct 31 06:55:49 testbed09-1664 Keepalived_vrrp[3136805]: Sending gratuitous ARP on enp1s0 for 10.114.16.72 [postgres@testbed09-1664 keepalived]$ psql -h 10.114.16.72 -p 5000 -U postgres -d mydb mydb=# Master testbed06: Oct 31 06:57:16 testbed06 Keepalived_vrrp[34771]: Sending gratuitous ARP on enp1s0 for 10.114.16.72 mydb=# |
I think you probably need to post your haproxy configuration in order for us to be able to comment any further. I can then try and reproduce the problem. It is worth trying to access postgresql from a third machine, and not testbed06 or testbed09, in the first instance. There can be complications when trying to forward connections when they originate on the same system as is doing the forwarding, although I don't know if that applies to haproxy. If you test it this way, then you can use tcpdump or wireshark to see what is happening to the packets and identify where the problem lies. You might find it works better if you use Given the number of artlcles on the web that describe how to use haproxy and keepalived together, I think it is very unlikely that HA is not possible for haproxy using keepalived. |
I've just seen that I didn't finish the second paragraph. I intended to suggest that you add |
Thank you for the update. I will try it my third system and will share the results in a while. [postgres@testbed06 ~]$ cat /etc/keepalived/keepalived.conf
} BACKUP: [postgres@testbed09-1664 ~]$ cat /etc/keepalived/keepalived.conf |
I have tried from the third system it accessible but still facing the priority issue i have stopped the haproxy service on master but it did not switched the VIP PFB the details : Master output : [postgres@testbed06 ~]$ systemctl status keepalived Nov 01 06:58:04 testbed06 Keepalived_vrrp[178717]: (VI_1) Changing effective priority from 100 to 102 BACKUP Output: [postgres@testbed09-1664 ~]$ systemctl status keepalived Nov 01 06:57:18 testbed09-1664 Keepalived_vrrp[3396582]: Sending gratuitous ARP on enp1s0 for 10.114.16.72 Nov 01 06:40:12 testbed09-1664 systemd[1]: Starting HAProxy Load Balancer... |
What the logs show is that at 06:58:04 testbed09 had priority 99 and at that time testbed06 had priority 100. At the same time, testbed06 increased its priority from 100 to 102 (so presumably the track_script detected that haproxy had started). At 07:00:12 chk_haproxy started returning 1 on testbed06, and so it reduced its priority to 100. This was still higher than the priority on testbed09 (99), and so testbed06 remained as master. It would appear that on testbed09 for some reason the track_script chk_haproxy is not correctly seeing that haproxy is running and is therefore returning a non-zero exit code, causing the priority to remain at 99. I suggest you post the full keepalived logs on both systems from the time that keepalived started up so that we can see what is actually happening. Just seeing the last few lines of the log entries from the output of systemctl status keepalived is really not sufficient. |
Hi,
Servers: test1, test2
I have already configured keepalived against two ha proxy servers I am able to move the VIP to other server when haproxy services goes down on one server (test1). Now when the haproxy service is running on server test2 and VIP is also on server test2 and then I start the service of keepalived on test1 but its priority is low and then when I shutdown the haproxy service on server test2 due to low priority on server test1 the keepalived does not move back the VIP to server test1.
Any idea or possibility to do it?
The text was updated successfully, but these errors were encountered: