nginx代理服务器出现故障,架构是2台虚拟虚拟机keepalive+haproxy80+nginx8080,

开始以为是keepalive的问题,只要关闭keepalive1就正常了。

后来查看keepalive1的日志:

tail -f /var/log/messages -n 100

看到:

Dec 16 16:18:42 nginx01 haproxy-systemd-wrapper: [ALERT] 349/161842 (7527) : Starting frontend GLOBAL: cannot bind UNIX socket [/var/run/haproxy/info.sock]
Dec 16 16:18:42 nginx01 haproxy-systemd-wrapper: haproxy-systemd-wrapper: exit, haproxy RC=1
Dec 16 16:18:42 nginx01 systemd: haproxy.service: main process exited, code=exited, status=1/FAILURE
Dec 16 16:18:42 nginx01 systemd: Unit haproxy.service entered failed state.
Dec 16 16:18:42 nginx01 systemd: haproxy.service failed.
Dec 16 16:20:50 nginx01 systemd: Started HAProxy Load Balancer.
Dec 16 16:22:58 nginx01 systemd: Starting Cleanup of Temporary Directories...
Dec 16 16:22:58 nginx01 systemd: Started Cleanup of Temporary Directories.

 其实就是报haproxy故障

查看haproxy服务状态,果然haproxy无法启动: 

[root@nginx01 conf.d]# systemctl restart haproxy.service
[root@nginx01 conf.d]# systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2019-12-16 16:18:42 CST; 2s ago
  Process: 7526 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 7526 (code=exited, status=1/FAILURE)

Dec 16 16:18:42 nginx01 systemd[1]: Started HAProxy Load Balancer.
Dec 16 16:18:42 nginx01 haproxy-systemd-wrapper[7526]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Dec 16 16:18:42 nginx01 haproxy-systemd-wrapper[7526]: [ALERT] 349/161842 (7527) : Starting frontend GLOBAL: cannot bind UNIX socket [/var/run/haproxy/info.sock]
Dec 16 16:18:42 nginx01 haproxy-systemd-wrapper[7526]: haproxy-systemd-wrapper: exit, haproxy RC=1
Dec 16 16:18:42 nginx01 systemd[1]: haproxy.service: main process exited, code=exited, status=1/FAILURE
Dec 16 16:18:42 nginx01 systemd[1]: Unit haproxy.service entered failed state.
Dec 16 16:18:42 nginx01 systemd[1]: haproxy.service failed.

找到问题所在: 

创建目录和文件 

mkdir  /var/run/haproxy/
touch /var/run/haproxy/info.sock

 重启haproxy服务

[root@nginx01 conf.d]# systemctl restart haproxy.service
[root@nginx01 conf.d]# systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-12-16 16:20:50 CST; 2s ago
 Main PID: 9041 (haproxy-systemd)
   CGroup: /system.slice/haproxy.service
           ├─9041 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
           ├─9042 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
           └─9043 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

Dec 16 16:20:50 nginx01 systemd[1]: Started HAProxy Load Balancer.
Dec 16 16:20:50 nginx01 haproxy-systemd-wrapper[9041]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐