HAProxy启动失败,该如何检查

今天在搭建集群时候,启动haproxy服务失败了,分享下排错流程。

[root@master02 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2025-05-30 11:49:02 CST; 23min ago
  Process: 1519 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 1519 (code=exited, status=1/FAILURE)

5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [ALERT] 149/114902 (1520...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [ALERT] 149/114902 (1520...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [ALERT] 149/114902 (1520...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [WARNING] 149/114902 (15...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [WARNING] 149/114902 (15...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: [ALERT] 149/114902 (1520...
5月 30 11:49:02 master02 haproxy-systemd-wrapper[1519]: haproxy-systemd-wrapper:...
5月 30 11:49:02 master02 systemd[1]: haproxy.service: main process exited, cod...RE
5月 30 11:49:02 master02 systemd[1]: Unit haproxy.service entered failed state.
5月 30 11:49:02 master02 systemd[1]: haproxy.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

1 直接去日志文件查看(应该是haproxy.cfg 配置文件中某些字段敲错了)

less /var/log/messages

2 进入配置文件,找38、39、46行

vim /etc/haproxy/haproxy.cfg


 

mode 字段写错了,更改为 option

default-backend 修改为 default_backend

fall 后指定一个数值 2

修改完成,保存退出;

3 重启haproxy服务,查看状态

[root@master02 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2025-05-30 12:28:06 CST; 9s ago
 Main PID: 1581 (haproxy-systemd)
    Tasks: 3
   Memory: 1.6M
   CGroup: /system.slice/haproxy.service
           ├─1581 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
           ├─1582 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
           └─1583 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

5月 30 12:28:06 master02 systemd[1]: Started HAProxy Load Balancer.
5月 30 12:28:06 master02 haproxy-systemd-wrapper[1581]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
5月 30 12:28:06 master02 haproxy-systemd-wrapper[1581]: [WARNING] 149/122806 (1582) : config : frontend 'GLOBAL' has no 'bind' directive. Please decl...ntended.
Hint: Some lines were ellipsized, use -l to show in full.

4 此时,也可以通过指定的网页监听端口去查看

ok,问题已经解决了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值