Haproxy 配置文件中 'listen' cannot handle unexpected argument 报错信息

在启动Haproxy服务时遇到'listen'不能处理意外参数的报错。解决方法是删除PID文件,然后使用指定配置文件的命令启动服务。如果出现语法错误,应检查listen指令后面的内容,确保其格式正确,例如:listen payserver,bind 0.0.0.0:80,这样可以避免错误并使Haproxy顺利运行。

备注:当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正常运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值