备注:当killall haproxy启动服务后发现配置文件还没有生效,就需要删除pidfile(目录:/var/run/haproxy.pid) 文件就,然后可以启动服务了。
启动haproxy 命令 /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
如果发现如下错误:
ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:34] : 'listen' cannot handle unexpected argument '0.0.0.0:80'.
[ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:34] : please use the 'bind' keyword for listening addresses.
[ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:40] : 'listen' cannot handle unexpected argument '0.0.0.0:3838'.
[ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:40] : please use the 'bind' keyword for listening addresses.
[ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:46] : 'listen' cannot handle unexpected argument '0.0.0.0:4140'.
[ALERT] 195/134522 (16200) : parsing [/usr/local/haproxy/haproxy.cfg:46] : please use the 'bind' keyword for listening addresses.
[ALERT] 195/134522 (16200) : Error(s) found in configuration file : /usr/local/haproxy/haproxy.cfg
[WARNING] 195/134522 (16200) : config : proxy 'payserver' has no 'bind' directive. Please declare it as a backend if this was intended.
[WARNING] 195/134522 (16200) : config : missing timeouts for proxy 'payserver'.
| While not properly invalid, you will certainly encounter various problems
| with such a configuration. To fix this, please ensure that all following
| timeouts are set to a non-zero value: 'client', 'connect', 'server'.
[WARNING] 195/134522 (16200) : config : proxy 'payserver2' has no 'bind' directive. Please declare it as a backend if this was intended.
[WARNING] 195/134522 (16200) : config : missing timeouts for proxy 'payserver2'.
| While not properly invalid, you will certainly encounter various problems
| with such a configuration. To fix this, please ensure that all following
| timeouts are set to a non-zero value: 'client', 'connect', 'server'.
[WARNING] 195/134522 (16200) : config : proxy 'payserver3' has no 'bind' directive. Please declare it as a backend if this was intended.
[WARNING] 195/134522 (16200) : config : missing timeouts for proxy 'payserver3'.
| While not properly invalid, you will certainly encounter various problems
| with such a configuration. To fix this, please ensure that all following
| timeouts are set to a non-zero value: 'client', 'connect', 'server'.
[ALERT] 195/134522 (16200) : Fatal errors found in configuration.
解决方案:找到自己的haprox.cfg文件,查看文件(备注:网上有人给的是如下这种写法的,不知道为什么运行不报错,反正我的运行报错)########test配置#################
isten payserver 0.0.0.0:80
mode http
stats enable
balance roundrobin
server s1 192.168.1.11:6013
server s2 192.168.1.11:7013
listen payserver2 0.0.0.0:8011
mode http
stats enable
balance roundrobin
server s1 192.168.1.11:6014
server s2 192.168.1.11:7014将上面 listen 后面的内容改为:
listen payserver
bind 0.0.0.0:80
就可以解决语法错误,让haproxy正常运行
版权声明:本文为wyqlxy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。