配置k8s时,haproxy服务启动失败,尝试N多方法
- 共 3,000 次检阅

问题描述:
搭建haproxy的机器,因出现故障重启了,然后发现haproxy服务出现异常。

haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 六 2023-07-22 10:33:53 EDT; 412ms ago
  Process: 61378 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 61378 (code=exited, status=1/FAILURE)

7月 22 10:33:53 master02 systemd[1]: Started HAProxy Load Balancer.
7月 22 10:33:53 master02 haproxy-systemd-wrapper[61378]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
7月 22 10:33:53 master02 haproxy-systemd-wrapper[61378]: [ALERT] 202/103353 (61384) : Starting frontend k8s-master: cannot bind socket [0.0.0.0:16443]
7月 22 10:33:53 master02 haproxy-systemd-wrapper[61378]: [ALERT] 202/103353 (61384) : Starting frontend k8s-master: cannot bind socket [127.0.0.1:16443]
7月 22 10:33:53 master02 haproxy-systemd-wrapper[61378]: haproxy-systemd-wrapper: exit, haproxy RC=1
7月 22 10:33:53 master02 systemd[1]: haproxy.service: main process exited, code=exited, status=1/FAILURE
7月 22 10:33:53 master02 systemd[1]: Unit haproxy.service entered failed state.
7月 22 10:33:53 master02 systemd[1]: haproxy.service failed

最后发现是SELinux的问题

sed -i 's/enforcing/disabled/' /etc/selinux/config #永久
setenforce 0  #临时关闭

执行完后重启:

systemctl restart haproxy
 haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2023-07-22 10:35:00 EDT; 843ms ago
 Main PID: 62405 (haproxy-systemd)
    Tasks: 3
   Memory: 2.3M
   CGroup: /system.slice/haproxy.service
           ├─62405 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
           ├─62406 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
           └─62407 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

7月 22 10:35:00 master02 systemd[1]: Started HAProxy Load Balancer.
7月 22 10:35:00 master02 haproxy-systemd-wrapper[62405]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

 

分享到:

这篇文章还没有评论

发表评论