socat管理haproxy配置 ssh-keygen -N '' -t rsa -q -b 2048

时间:2023-03-09 00:30:34
socat管理haproxy配置   ssh-keygen -N '' -t rsa -q -b 2048

socat管理haproxy配置

haproxy是可以通过socat命令管理haproxy.cfg文件的;
1.安装socat

yum install socat -y

2.配置haproxy.cfg,启动socket

修改:stats socket /var/lib/haproxy/stats
修改为:stats socket /var/lib/haproxy/stats mode 600 level admin

注:level为admin,否则使用socat时会提示权限拒绝
3.socat使用方法

a.获取使用帮助
echo "help" | socat stdio /var/lib/haproxy/stats
b.获取常用信息
echo "show info" | socat stdio /var/lib/haproxy/stats
c.把某个backend的主机设置为维护
echo "disable server web_port/10.10.5.146" | socat stdio /var/lib/haproxy/stats
d.取消维护
echo "enable server web_port/10.10.5.146" | socat stdio /var/lib/haproxy/stats