今天在搭建集群时候,启动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 -Ds5月 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,问题已经解决了!