haproxy启动失败
问题描述
haproxy服务无法启动
问题原因
由于未关闭selinux 导致无法关联端口,导致haproxy服务失败
操作方案
排查配置文件无问题
末尾添加配置
~]# tail /etc/haproxy/haproxy.cfg
server app2 127.0.0.1:5002 check
server app3 127.0.0.1:5003 check
server app4 127.0.0.1:5004 check
listen k8s-6443
bind 172.31.7.188:6443
mode tcp
server 172.31.7.101 172.31.7.101:6443 check inter 2s fall 3 rise 5
server 172.31.7.102 172.31.7.102:6443 check inter 2s fall 3 rise 5
server 172.31.7.103 172.31.7.103:6443 check inter 2s fall 3 rise 5
[root@k8s-ha1 ~]#
检查状态
systemctl status haproxy.service
查看messages日志确认失败原因
~]# less /var/log/messages
Jan 23 23:13:18 k8s-ha1 systemd: Unit haproxy.service entered failed state.
Jan 23 23:13:18 k8s-ha1 systemd: haproxy.service failed.
Jan 23 23:18:53 k8s-ha1 systemd: Started HAProxy Load Balancer.
Jan 23 23:18:53 k8s-ha1 haproxy-systemd-wrapper: [WARNING] 022/231853 (4316) : parsing [/etc/haproxy/haproxy.cfg:45] : 'option httplog' not usable with proxy 'k8s-6443' (needs 'mode http'). Falling back to 'option tcplog'.
Jan 23 23:18:53 k8s-ha1 haproxy-systemd-wrapper: [WARNING] 022/231853 (4316) : config : 'option forwardfor' ignored for proxy 'k8s-6443' as it requires HTTP mode.
Jan 23 23:18:53 k8s-ha1 haproxy-systemd-wrapper: [ALERT] 022/231853 (4316) : Starting proxy k8s-6443: cannot bind socket [172.31.7.188:6443]
Jan 23 23:18:53 k8s-ha1 systemd: haproxy.service: main process exited, code=exited, status=1/FAILURE
Jan 23 23:18:53 k8s-ha1 haproxy-systemd-wrapper: haproxy-systemd-wrapper: exit, haproxy RC=1
Jan 23 23:18:53 k8s-ha1 systemd: Unit haproxy.service entered failed state.
Jan 23 23:18:53 k8s-ha1 systemd: haproxy.service failed.
Jan 23 23:19:00 k8s-ha1 kernel: e1000: eth0 NIC Link is Down
Jan 23 23:19:00 k8s-ha1 Keepalived_vrrp[3032]: Kernel is reporting: interface eth0 DOWN
Jan 23 23:19:00 k8s-ha1 Keepalived_vrrp[3032]: VRRP_Instance(VI_1) Entering FAULT STATE
Jan 23 23:19:00 k8s-ha1 Keepalived_vrrp[3032]: VRRP_Instance(VI_1) removing protocol VIPs.
Jan 23 23:19:00 k8s-ha1 Keepalived_vrrp[3032]: VRRP_Instance(VI_1) Now in FAULT state
Jan 23 23:19:04 k8s-ha1 kernel: e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
检查未关闭selinux
~]# setenforce 0