Enabling and disabling HAproxy backend server option not
comes with default installation. Therefore we have setup a way to do it ourselves.
Below is how I do enable and disable servers without
restarting whole HAproxy server. I have configured unix socket and used socat
command to enable disable servers.
Therefore if not already installed you need to install socat
in your linux machine. I use yum command since I am using RHEL,
After installing socat, you need to enable stats socket in the haproxy configuration file as mentioned below,
( For more information check on http://www.haproxy.org/download/1.5/doc/configuration.txt url and go
the “9.2. Unix Socket commands section” ).
global
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
Save haproxy configuration and restart haproxy service,
#systemctl restart haproxy.service
Now you can enable or disable your server by using below
commands,
[root@localhost ~]# echo "enable server <your backend name>/<server name in
HAproxy configuration>" | socat stdio /var/run/haproxy.sock
[root@localhost ~]# echo "disable server <your backend name>/<server name in
HAproxy configuration>" | socat stdio /var/run/haproxy.sock
That’s all. You can check whether server is enabled or
disabled via haproxy stats page,
Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!
ReplyDelete
ReplyDeleteشركة تنظيف كنب بالقطيف
شركة تنظيف مجالس بالقصيم
شركة تنظيف مجالس بالرس