centos 未知/不支持的存储引擎:创新数据库

k4aesqcs  于 2022-11-07  发布在  其他
关注(0)|答案(3)|浏览(131)

我正在设置一个复制服务器,当我第一次尝试启动mysql服务时,它失败了:

[root@ravioli mysql]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]
[root@ravioli mysql]# tail /var/log/mysqld.log 
151013 13:41:27 [ERROR] Plugin 'InnoDB' init function returned error.
151013 13:41:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
/usr/libexec/mysqld: File '/databases/mysql/mysql_slow_queries.log' not found (Errcode: 13)
151013 13:41:27 [ERROR] Could not use /databases/mysql/mysql_slow_queries.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
151013 13:41:27 [ERROR] Unknown/unsupported storage engine: InnoDB
151013 13:41:27 [ERROR] Aborting

151013 13:41:27 [Note] /usr/libexec/mysqld: Shutdown complete

151013 13:41:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

我已确认用户mysql可以看到并写入/databases/mysql/mysql_slow_queries.log
然后我检查了getenforce,发现它被设置为Enforcing
如何配置MySQL以与SELinux完美配合?

vshtjzan

vshtjzan1#

所有我需要的是删除两个文件,这是:

ib_logfile0

ib_logfile1

然后返回启动mysql,一切正常

ki1q1bka

ki1q1bka2#

这解决了我的问题:

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1

sudo apt-get install mysql-server
j91ykkif

j91ykkif3#

好的,这实际上是much easier than expected
默认情况下,SELinuxEnforcing,这可以防止对文件系统的意外写入。我只需要告诉SELinux,MySQL可以写入非标准目录。

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"
-bash: semanage: command not found.

要安装semanage,请使用以下命令:

yum install policycoreutils-python

现在再次运行该命令。这可能需要一些时间...

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"

通过查看以下配置文件,检查是否为该新目录配置了SELinux:

[root@ravioli]#  grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local

/databases/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0

可以添加其他目录,例如,如果您在某个地方有一个专用的tmp目录。

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql_tmp(/.*)?"

再次检查配置:

[root@ravioli]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local

/databases/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0
/databases/mysql_tmp(/.*)?    system_u:object_r:mysqld_db_t:s0

最后,使用restorecron更新权限

restorecon -R -v /www/databases/mysql/

在我的设置中,

restorecon -R -v /www/databases/mysql_tmp/

现发布:

service mysqld start

贝内。

Starting mysqld:         [  OK  ]

相关问题