记一次mysql启动失败分析和处理 - 原因:SElinux

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

在51、52、54三台主机上搭建Galera集群,在54上安装mysql并能成功启动,但在51、52上始终无法启动,能看到的日志也非常少。

Feb 28 16:45:19 localhost systemd: Starting LSB: start and stop MySQL...
Feb 28 16:45:19 localhost mysql: Starting MySQL.170228 16:45:19 mysqld_safe Logging to '/var/lib/mysql/controller2.err'.
Feb 28 16:45:19 localhost mysql: 170228 16:45:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 28 16:45:19 localhost mysql: /usr/bin/mysqld_safe_helper: Can't create/write to file '#001' (Errcode: -1769717024)
Feb 28 16:45:20 localhost mysql: [FAILED]
Feb 28 16:45:20 localhost systemd: mysql.service: control process exited, code=exited status=1
Feb 28 16:45:20 localhost systemd: Failed to start LSB: start and stop MySQL.
Feb 28 16:45:20 localhost systemd: Unit mysql.service entered failed state.
Feb 28 16:45:20 localhost systemd: mysql.service failed.

但能分析的内容太少,通过journalctl -xe也看到如下日志:

Feb 28 16:30:31 compute2 useradd[16108]: failed adding user 'mysql', exit code: 9

分析感觉与权限有关系,查看/etc/passwd中mysql用户是存在的,并且/var/lib/mysql目前也存在并且权限也是mysql。

但51和52的mysql的始终启动不了,对于这种没有太多异常日志的问题处理,感觉真的无力下手。

后面在网上浏览帖子,发现有提到过selinux,就试着用getenforce查看了三台主机的状态,发现54关闭,51和52两台是开着的。

关闭selinux 后,通过如下命令

yum install MariaDB-Galera-server MariaDB-client galera

安装后mysql启动正常了。


Centos7 Galera安装教程:https://tecadmin.net/setup-mariadb-galera-cluster-5-5-in-centos-rhel/

转载于:https://my.oschina.net/sannychan/blog/848399

你可能感兴趣的:(记一次mysql启动失败分析和处理 - 原因:SElinux)