Haproxy + Keepalived +PXC 常见错误

1、

Apr 21 19:15:54 pxc1 systemd[1]: mysql@bootstrap.service: main process exited, code=exited, status=1/FAILURE
Apr 21 19:15:57 pxc1 mysql-systemd[8777]: /usr/bin/mysql-systemd: line 140: kill: (8776) - No such process
Apr 21 19:15:57 pxc1 mysql-systemd[8777]: ERROR! mysqld_safe with PID 8776 has already exited: FAILURE
Apr 21 19:15:57 pxc1 systemd[1]: mysql@bootstrap.service: control process exited, code=exited status=1
Apr 21 19:15:57 pxc1 mysql-systemd[9267]: WARNING: mysql pid file /var/run/mysqld/mysqld.pid empty or not readable
Apr 21 19:15:57 pxc1 mysql-systemd[9267]: ERROR! mysql already dead
Apr 21 19:15:57 pxc1 systemd[1]: mysql@bootstrap.service: control process exited, code=exited status=2
Apr 21 19:15:57 pxc1 mysql-systemd[9296]: WARNING: mysql pid file /var/run/mysqld/mysqld.pid empty or not readable
Apr 21 19:15:57 pxc1 mysql-systemd[9296]: WARNING: mysql may be already dead
Apr 21 19:15:57 pxc1 systemd[1]: Failed to start Percona XtraDB Cluster with config /etc/sysconfig/mysql.bootstrap.
-- Subject: Unit mysql@bootstrap.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql@bootstrap.service has failed.
--
-- The result is failed.
Apr 21 19:15:57 pxc1 systemd[1]: Unit mysql@bootstrap.service entered failed state.
Apr 21 19:15:57 pxc1 systemd[1]: mysql@bootstrap.service failed.
Apr 21 19:15:57 pxc1 polkitd[6586]: Unregistered Authentication Agent for unix-process:8728:76373 (system bus name :1.67, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

解决办法:

修改最新节点的文件参数

#vi /var/lib/mysql/grastate.dat

把safe_to_bootstrap: 0  改成1后

这个文件直接删除也可以的

开启服务:systemctl start mysql@bootstrap.service

参考:https://www.percona.com/forums/questions-discussions/percona-xtradb-cluster/49255-can-t-start-my-cluster-it-s-so-urgent

2、polkitd[6505]: Unregistered Authentication Agent for unix-process:11708:568436 (system bus name :1.115, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

Apr 24 20:07:19 pxc1 libvirtd[7173]: 2019-04-25 03:07:19.828+0000: 7173: info : libvirt version: 4.5.0, package: 10.el7 (CentOS BuildSystem <http://bugs.centos.org>, 201
Apr 24 20:07:19 pxc1 libvirtd[7173]: 2019-04-25 03:07:19.828+0000: 7173: info : hostname: pxc1
Apr 24 20:07:19 pxc1 libvirtd[7173]: 2019-04-25 03:07:19.828+0000: 7173: error : virFirewallApplyRuleFirewallD:790 : The name org.fedoraproject.FirewallD1 was not provid
Apr 24 20:07:19 pxc1 polkitd[6505]: Unregistered Authentication Agent for unix-process:11656:566133 (system bus name :1.114, object path /org/freedesktop/PolicyKit1/Auth
Apr 24 20:07:41 pxc1 polkitd[6505]: Registered Authentication Agent for unix-process:11708:568436 (system bus name :1.115 [/usr/bin/pkttyagent --notify-fd 5 --fallback],
Apr 24 20:07:41 pxc1 systemd[1]: Started HAProxy Load Balancer.
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Apr 24 20:07:41 pxc1 polkitd[6505]: Unregistered Authentication Agent for unix-process:11708:568436 (system bus name :1.115, object path /org/freedesktop/PolicyKit1/Auth
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: [WARNING] 113/200741 (11717) : parsing [/etc/haproxy/haproxy.cfg:46] : 'option httplog' not usable with frontend 'px
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: [WARNING] 113/200741 (11717) : config : 'option forwardfor' ignored for frontend 'pxc-front' as it requires HTTP mod
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: [WARNING] 113/200741 (11717) : config : 'option forwardfor' ignored for backend 'pxc-back' as it requires HTTP mode.
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: [ALERT] 113/200741 (11717) : Starting frontend pxc-front: cannot bind socket [0.0.0.0:3306]
Apr 24 20:07:41 pxc1 systemd[1]: haproxy.service: main process exited, code=exited, status=1/FAILURE
Apr 24 20:07:41 pxc1 haproxy-systemd-wrapper[11714]: haproxy-systemd-wrapper: exit, haproxy RC=1
Apr 24 20:07:41 pxc1 systemd[1]: Unit haproxy.service entered failed state.
Apr 24 20:07:41 pxc1 systemd[1]: haproxy.service failed.
Apr 24 20:10:01 pxc1 systemd[1]: Started Session 22 of user root.
Apr 24 20:10:01 pxc1 systemd[1]: Started Session 23 of user root.
Apr 24 20:10:01 pxc1 CROND[11869]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Apr 24 20:10:01 pxc1 CROND[11872]: (root) CMD (ntpdate ntp3.aliyun.com )
Apr 24 20:10:01 pxc1 CROND[11868]: (root) CMDOUT (/bin/sh: ntpdate: command not found)

解决办法:

绑定不了这个IP地址

没有办法,注释了该项

[root@pxc1 ~]# vi /etc/percona-xtradb-cluster.conf.d/wsrep.cnf

3、[ERROR] Can't start server: listen() on TCP/IP port: Address already in use

2019-04-25T09:39:26.855277Z 0 [Note] IPv6 is available.
2019-04-25T09:39:26.855304Z 0 [Note] - '::' resolves to '::';
2019-04-25T09:39:26.855332Z 0 [Note] Server socket created on IP: '::'.
2019-04-25T09:39:26.855373Z 0 [ERROR] Can't start server: listen() on TCP/IP port: Address already in use
2019-04-25T09:39:26.855382Z 0 [ERROR] listen() on TCP/IP failed with error 98
2019-04-25T09:39:26.855422Z 0 [ERROR] Aborting

2019-04-25T09:39:26.855437Z 0 [Note] Giving 2 client threads a chance to die gracefully
2019-04-25T09:39:28.861627Z 0 [Note] WSREP: Closing send monitor...
2019-04-25T09:39:28.861674Z 0 [Note] WSREP: Closed send monitor.
2019-04-25T09:39:28.861707Z 0 [Note] WSREP: gcomm: terminating thread
2019-04-25T09:39:28.861758Z 0 [Note] WSREP: gcomm: joining thread

解决办法:

查看相关地址,发现3306被占用

[root@pxc1 ~]# netstat -tunl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.132.131:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN

关闭keepalived虚拟的IP地址

[root@pxc1 ~]# systemctl stop keepalived

后重启正常

 4、Lost connection to MySQL server at 'reading initial communication packet'

[root@pxc1 ~]# mysql -uroot -p -h192.168.132.131
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

解决办法:

出现这个问题是在代理节点上的IP解析不到PXC集群里,检查集群里的xinetd是否部署好了。

原文地址:https://www.cnblogs.com/102x/p/10748823.html