backend app
balance roundrobin
mode tcp
stick-table type ip size 20k peers mypeer
stick src
server app1 192.168.148.128:80 check
server app2 192.168.148.135:80 check
server app3 192.168.148.136:80 check
server app4 192.168.148.137:80 check
peers mypeer
peer ha1 192.168.148.140:80
peer ha2 192.168.148.138:80
Jan 28 09:26:28 localhost.localdomain systemd[1]: Starting HAProxy Load Balancer...
Jan 28 09:26:28 localhost.localdomain systemd[1]: Started HAProxy Load Balancer.
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: [WARNING] 027/092628 (13186) : config : 'option forwardfor' ignored for frontend 'main' as it requires HTTP mode.
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: [ALERT] 027/092628 (13186) : Proxy 'app': unable to find local peer 'localhost.localdomain' in peers section 'mypeer'.
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: [WARNING] 027/092628 (13186) : config : 'option forwardfor' ignored for backend 'app' as it requires HTTP mode.
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: [WARNING] 027/092628 (13186) : Removing incomplete section 'peers mypeer' (no peer named 'localhost.localdomain').
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: [ALERT] 027/092628 (13186) : Fatal errors found in configuration.
Jan 28 09:26:28 localhost.localdomain haproxy-systemd-wrapper[13185]: haproxy-systemd-wrapper: exit, haproxy RC=256
答案 0 :(得分:2)
Haproxy默认为主机名,您必须强制它使用您在配置中提供的ID。
haproxy -f /etc/haproxy/haproxy.cfg -L ha1
https://cbonte.github.io/haproxy-dconv/configuration-1.6.html#3.5