相关文章推荐
帅气的葡萄  ·  Python ...·  3 月前    · 
怕老婆的西装  ·  Java8特性详解 ...·  1 年前    · 
乖乖的韭菜  ·  HBuilderX.vue文件 以及 ...·  1 年前    · 

问题1:部分node的haproxy启动失败,且VIP存在?

[root@k8s-master02 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2021-08-13 16:50:14 CST; 5min ago
Main PID: 1760 (code=exited, status=1/FAILURE)

Aug 13 16:50:14 k8s-master02 systemd[1]: Started HAProxy Load Balancer.
Aug 13 16:50:14 k8s-master02 haproxy-systemd-wrapper[1760]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Aug 13 16:50:14 k8s-master02 haproxy-systemd-wrapper[1760]: [WARNING] 224/165014 (1761) : config : frontend 'GLOBAL' has no 'bind' directive. Please declare it as a backend ... intended.
Aug 13 16:50:14 k8s-master02 haproxy-systemd-wrapper[1760]: [ALERT] 224/165014 (1761) : Starting frontend K8S-master: cannot bind socket [0.0.0.0:16443]
Aug 13 16:50:14 k8s-master02 haproxy-systemd-wrapper[1760]: [ALERT] 224/165014 (1761) : Starting frontend K8S-master: cannot bind socket [127.0.0.1:16443]
Aug 13 16:50:14 k8s-master02 haproxy-systemd-wrapper[1760]: haproxy-systemd-wrapper: exit, haproxy RC=1
Aug 13 16:50:14 k8s-master02 systemd[1]: haproxy.service: main process exited, code=exited, status=1/FAILURE
Aug 13 16:50:14 k8s-master02 systemd[1]: Unit haproxy.service entered failed state.
Aug 13 16:50:14 k8s-master02 systemd[1]: haproxy.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

原因分析:由于VIP已先启动haproxy并在某个node绑定,故其他node在启动haproxy启动时无法绑定端口;

Aug 13 16:52:20 k8s-master01 systemd: Started HAProxy Load Balancer.
Aug 13 16:52:20 k8s-master01 haproxy-systemd-wrapper: [WARNING] 224/165220 (1876) : config : frontend 'GLOBAL' has no 'bind' directive. Please declare it as a backend if this was intended.
Aug 13 16:52:20 k8s-master01 haproxy-systemd-wrapper: [ALERT] 224/165220 (1876) : Starting frontend K8S-master: cannot bind socket [0.0.0.0:16443]
Aug 13 16:52:20 k8s-master01 haproxy-systemd-wrapper: [ALERT] 224/165220 (1876) : Starting frontend K8S-master: cannot bind socket [127.0.0.1:16443]
Aug 13 16:52:20 k8s-master01 haproxy-systemd-wrapper: haproxy-systemd-wrapper: exit, haproxy RC=1
Aug 13 16:52:20 k8s-master01 systemd: haproxy.service: main process exited, code=exited, status=1/FAILURE
Aug 13 16:52:20 k8s-master01 systemd: Unit haproxy.service entered failed state.
Aug 13 16:52:20 k8s-master01 systemd: haproxy.service failed.
Aug 13 16:52:25 k8s-master01 Keepalived_vrrp[1777]: /etc/keepalived/check_apiserver.sh exited with status 2
Aug 13 16:52:30 k8s-master01 Keepalived_vrrp[1777]: /etc/keepalived/check_apiserver.sh exited with status 2
Aug 13 16:52:35 k8s-master01 Keepalived_vrrp[1777]: /etc/keepalived/check_apiserver.sh exited with status 2
Aug 13 16:52:40 k8s-master01 Keepalived_vrrp[1777]: /etc/keepalived/check_apiserver.sh exited with status 2

解决方法:注释掉配置bind后重启服务,服务正常运行后并再次将注释取消。

以下方法经验证,无效;

mkdir /var/run/haproxy -p
touch /var/run/haproxy/info.sock
chown haproxy:haproxy -P /var/run/haproxy
chown haproxy:haproxy -P /var/run/haproxy/info.sock
cat <<eof>> /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind=1
eof
sysctl -p
ll /var/run/haproxy /var/run/haproxy/info.sock

MHA高可用配置及故障切换

MySQL MHA1、什么是MHAMHA (MasterHigh Availability)是一套优秀的MysQL高可用环境下故障切换和主从复制的软件。MHA的出现就是解决MySQL单点的问题。MySQL故障切换过程中,MHA能做到0-30秒内自动完成故障切换操作。MHA能在故障切换的过程中最大程度上保证数据的一致性,以达到真正意义上的高可用。2、MHA 的组成MHA Node(数据节点)MHA Node运行在每台MySQL服务器上。MHA Manager(管理节点)MHA Manager可以单独部署在一台独立的机器上,管理多个master-slave 集群;也可以部署在一台 slave 节点上。WHA Manager会定时探测集群中的master 节点。当 master 出现故障时,它可以自动将最新数据的 slave 提升为新的master,然后将所有其他的 slave 重新指向新的master。整个故障转移过程对应用程序完全透明。