现象
CentOS7.2安装HAProxy1.8.12后启动报错,
[root@fffmo.com run]# journalctl -xe
Jan 22 16:37:10 fffmo.com systemd[1]: Unit haproxy.service entered failed state.
Jan 22 16:37:10 fffmo.com systemd[1]: haproxy.service failed.
Jan 22 16:37:10 fffmo.com systemd[1]: haproxy.service holdoff time over, scheduling restart.
Jan 22 16:37:10 fffmo.com systemd[1]: Cannot add dependency job for unit syslog.service, ignoring: Unit not found.
Jan 22 16:37:10 fffmo.com systemd[1]: Starting HAProxy Load Balancer...
-- Subject: Unit haproxy.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit haproxy.service has begun starting up.
Jan 22 16:37:10 fffmo.com haproxy[14609]: [ALERT] 021/163710 (14609) : Starting frontend GLOBAL: cannot bind UNIX socket
Jan 22 16:37:10 fffmo.com systemd[1]: haproxy.service: control process exited, code=exited status=1
Jan 22 16:37:10 fffmo.com systemd[1]: Failed to start HAProxy Load Balancer.
-- Subject: Unit haproxy.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit haproxy.service has failed.
--
-- The result is failed.
Jan 22 16:37:10 fffmo.com systemd[1]: Unit haproxy.service entered failed state.
Jan 22 16:37:10 fffmo.com systemd[1]: haproxy.service failed.
Jan 22 16:37:10 fffmo.com systemd[1]: haproxy.service holdoff time over, scheduling restart.
产生原因
haproxy启动无/var/lib/haproxy/stats文件,导致启动报错。
解决方案
创建/var/lib/haproxy/stats文件
[root@fffmo.com ~]# mkdir -p /var/lib/haproxy
[root@fffmo.com ~]
# touch /var/lib/haproxy/stats 再次启动,成功
[root@fffmo.com ~]
# systemctl start haproxy
[root@fffmo.com ~]
[root@fffmo.com ~]# ps -ef | grep -i haproxy
root 14637 1 0 16:38 ? 00:00:00 /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
haproxy 14639 14637 0 16:38 ? 00:00:00 /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
root 14641 2589 0 16:38 pts/0 00:00:00 grep --color=auto -i haproxy