缺少/run/haproxy目录,haproxy服务启动失败

2023-12-31 09:39:00

湖蓝几何球体LinkedIn Banner.png
转载说明:如果您喜欢这篇文章并打算转载它,请私信作者取得授权。感谢您喜爱本文,请文明转载,谢谢。


问题描述:

搭建haproxy的机器,因出现故障重启了,然后发现haproxy服务出现异常。重新启动haproxy服务的时候出现下面的错误:

[root@dev115 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查看进程,服务进程没起来:

[root@dev115 log]# 
[root@dev115 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
[root@dev115 log]# 

执行 systemctl status haproxy.service,出现下面的结果:

[root@dev115 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.
[root@dev115 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

[root@dev115 run]# mkdir haproxy
[root@dev115 run]# chown haproxy:haproxy -P haproxy/

然后重新启动haproxy,成功:

[root@dev115 run]# cd /etc/init.d
[root@dev115 init.d]# ./haproxy start
Starting haproxy:                                          [  确定  ]
[root@dev115 init.d]# 

检查服务进程,进程已经起来了:

[root@dev115 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
[root@dev115 haproxy]# 

备注:本文为迁移博文,非近期遇到的故障

文章来源:https://blog.csdn.net/WF_crystal/article/details/135293672
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。