基于Docker的Percona XtraDB Cluster(PXC)掉电无法正常启动的解决方法

1.使用Docker重新start容器ID后,可能会出现下面的错误

Error response from daemon: container fd7f8a24df60aa60e5fcacfdd6c4f36456cff62d062fc26c8d5b427d76a200fe: endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway_7227e3f50f1e (9c121a8ada028bda61adad4119b6992b709129fb1e23fd7b685b354375f357ed): Error starting userland proxy: listen tcp 0.0.0.0:3310: bind: address already in use

解决方法:

先试用netstat -lntp|grep 3310(端口号)找到具体进程,然后kill -9 杀掉进程

如果没有发现这个端口号被占用,则使用#>docker service restart,重启Docker

2.重启Docker后,我们需要找到原来设置主的节点,比如node1(参考我之前写的搭建percona xtradb 集群文章

如果报下面这个错误:

通过#>docker logs -f 镜像ID,(或者到主机容器目录看容器日志)

基于Docker的Percona XtraDB Cluster(PXC)掉电无法正常启动的解决方法

有如下报错:

It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates.
To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1

到var/lib/docker/volumes/v1目录(v2,v3目录)将grastate.dat 文件 或者修改 文件 设置 safe_to_bootstrap 为 1

3.最后使用顺序的docker启动命令,即可正常启动pxc和haproxy

#>docker start pxc1镜像ID

#>docker start haproxy1镜像ID

#>docker start pxc2镜像ID

#>docker start haproxy3镜像ID

最后启动keepalived 即可解决问题

参考文章

按照视频中docker stop node1作为挂起第一个节点,当再次start node1遇到问题
https://coding.imooc.com/learn/questiondetail/93379.html
记一次测试环境下PXC集群问题《经验总结》
https://www.cnblogs.com/liangshaoye/p/10438531.html
Percona XtraDB Cluster(PXC)掉电无法正常启动
https://blog.csdn.net/hxpjava1/article/details/80047288
CentOS 下 netstat 命令显示不完整程序名的原因
http://jaminzhang.github.io/linux/the-reason-of-centos-netstat-command-does-not-display-full-program-name/