I am using HA proxy version 1.6.6 for load balancing rabbitmq server, and it works fine but i want to add server dynamically in ha proxy backend in ubuntu using script. can anyone please tell me how can i done it?
How to add server dynamically in HA proxy backend?
Asked Answered
HAProxy OSS v1.8 does not include add/remove
commands in Runtime API, but you can achieve similar functionality by using ready/disabled
state commands.
- Add server(s) config in haproxy.cfg in
disabled
state:server-template websrv 1-100 192.168.122.1:8080 check disabled
//This adds 100 servers (websrv1...websrv100) in disabled state - Enable server (similar to
add
feature):set server be_template/websrv1 state ready
- Disable server (similar to
remove
feature):set server be_template/websrv1 state maint
Address and port can be changed using Runtime API as usual: set server be_template/websrv1 addr 192.168.50.112 port 8000
Reference(s):
This does not work in haproxy 1.8: "Update for the current server address family is only supported through configuration file" –
Creatinine
Changing server addresses is working in HA-Proxy version 2.0.7 2019/09/27 –
Eurasian
Unknown command: 'server-template', but maybe one of the following ones is a better match -- haproxy 2.8 –
Temple
As far as I know haproxy api ( stats socket ) does not support dynamic adding/removing servers to backend. One of the solution to use consul, the cost - reload service after some change. https://www.hashicorp.com/blog/haproxy-with-consul.html
I think there is not this kind of features with HAProxy Open Source.
If you use their ALOHA Load Balancer, there is an API to do this actions here :
© 2022 - 2024 — McMap. All rights reserved.