Haproxy—缺少/run/haproxy目录,haproxy服务启动失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Haproxy—缺少/run/haproxy目录,haproxy服务启动失败相关的知识,希望对你有一定的参考价值。
问题描述:搭建haproxy的机器,因出现故障重启了,然后发现haproxy服务出现异常。重新启动haproxy服务的时候出现下面的错误:
[[email protected] log]# service haproxy start
Starting haproxy (via systemctl): Job for haproxy.service failed because the control process exited with error code. See "systemctl status haproxy.service" and "journalctl -xe" for details.
[失败]
使用ps -ef查看进程,服务进程没起来:
[[email protected] log]#
[[email protected] log]# ps -ef|grep haproxy
106 12735 12669 0 09:29 ? 00:00:00 haproxy -p /var/run/haproxy.pid -f /etc/haproxy/haproxy.cfg -sf 26
root 13002 12475 0 09:32 pts/0 00:00:00 grep --color=auto haproxy
[[email protected] log]#
执行 systemctl status haproxy.service,出现下面的结果:
[[email protected] run]# systemctl status haproxy.service
● haproxy.service - SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications
Loaded: loaded (/etc/rc.d/init.d/haproxy; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since 四 2018-05-10 10:33:24 CST; 9s ago
Docs: man:systemd-sysv-generator(8)
Process: 17614 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=1/FAILURE)
5月 10 10:33:24 dev115 systemd[1]: Starting SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications...
5月 10 10:33:24 dev115** haproxy[17614]: Starting haproxy: [ALERT] 129/103324 (17622) : Starting frontend GLOBAL: cannot bind UNIX socket [/run/haproxy/admin.sock]**
5月 10 10:33:24 dev115 systemd[1]: haproxy.service: control process exited, code=exited status=1
5月 10 10:33:24 dev115 haproxy[17614]: [失败]
5月 10 10:33:24 dev115 systemd[1]: Failed to start SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications.
5月 10 10:33:24 dev115 systemd[1]: Unit haproxy.service entered failed state.
5月 10 10:33:24 dev115 systemd[1]: haproxy.service failed.
[[email protected] run]#
根据报错中的“5月 10 10:33:24 dev115 haproxy[17614]: Starting haproxy: [ALERT] 129/103324 (17622) : Starting frontend GLOBAL: cannot bind UNIX socket [/run/haproxy/admin.sock]”这一句,经过链接https://stackoverflow.com/questions/30101075/haproxy-doesnt-start-can-not-bind-unix-socket-run-haproxy-admin-sock 的解答:
Haproxy needs to write to /run/haproxy/admin.sock but it wont create the directory for you. Create the directory /run/haproxy/ first or set stats socket to a different path.
原来是/run下面的haproxy目录丢失了,所以手动在/run目录下面创建了一盒haproxy目录,并且改权限为haproxy:haproxy
[[email protected] run]# mkdir haproxy
[[email protected] run]# chown haproxy:haproxy -P haproxy/
然后重新启动haproxy,成功:
[[email protected] run]# cd /etc/init.d
[[email protected] init.d]# ./haproxy start
Starting haproxy: [ 确定 ]
[[email protected] init.d]#
检查服务进程,进程已经起来了:
[[email protected] haproxy]# ps -ef|grep haproxy
106 17574 17509 0 10:33 ? 00:00:05 haproxy -p /var/run/haproxy.pid -f /etc/haproxy/haproxy.cfg -sf 26
haproxy 17858 1 0 10:36 ? 00:00:00 /usr/local/haproxy/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
root 20764 12475 0 11:20 pts/0 00:00:00 grep --color=auto haproxy
[[email protected] haproxy]#
以上是关于Haproxy—缺少/run/haproxy目录,haproxy服务启动失败的主要内容,如果未能解决你的问题,请参考以下文章