[英]Unknown/unsupported storage engine: InnoDB
I'm setting up a replication server and when I try to start the mysql service for the first time, it fails:我正在设置一个复制服务器,当我第一次尝试启动 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
I confirmed that user mysql
sees and is able to write to /databases/mysql/mysql_slow_queries.log
.我确认用户
mysql
看到并能够写入/databases/mysql/mysql_slow_queries.log
。
Then I checked getenforce
and see it is set to Enforcing
.然后我检查了
getenforce
并看到它设置为Enforcing
。
How do I configure MySQL to play nicely with SELinux?如何配置 MySQL 以与 SELinux 完美配合?
All I needed was to delete two files which are: 我只需要删除两个文件:
ib_logfile0
and 和
ib_logfile1
Then going back to start mysql everything worked 然后回去开始mysql一切正常
This resolved my problem 这解决了我的问题
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoremove
sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1
sudo apt-get install mysql-server
Ok this was actually much easier than expected . 好吧,这实际上比预期容易得多 。
By default SELinux
is Enforcing
, which prevents unexpected writes on the filesystem. 默认情况下,
SELinux
是Enforcing
,它可以防止对文件系统进行意外写入。 I just needed to tell SELinux that it's OK for MySQL to write to a non-standard directory. 我只需告诉SELinux,MySQL可以写入非标准目录。 To wit:
以机智:
[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"
-bash: semanage: command not found.
Derp. DERP。 To install
semanage
, use this: 要安装
semanage
,请使用以下命令:
yum install policycoreutils-python
Now run the command again. 现在再次运行该命令。 This may take a few moments...
这可能需要一些时间......
[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"
Check to see that SELinux is configured for this new directory by looking at this config file: 通过查看此配置文件,检查是否为此新目录配置了SELinux:
[root@ravioli]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local
/databases/mysql(/.*)? system_u:object_r:mysqld_db_t:s0
Additional directories can be added, for instance if you have a dedicated tmp directory somewhere. 可以添加其他目录,例如,如果您在某处有专用的tmp目录。
[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql_tmp(/.*)?"
Check the config again: 再次检查配置:
[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
Finally, update the permissions using restorecron
最后,使用
restorecron
更新权限
restorecon -R -v /www/databases/mysql/
and in my setup, 在我的设置中,
restorecon -R -v /www/databases/mysql_tmp/
Now issue: 现在问题:
service mysqld start
Bene. 好处。
Starting mysqld: [ OK ]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.