2015-10-13 29 views
2

我設置複製服務器,當我嘗試啓動mysql服務的第一次,它失敗:未知/不支持的存儲引擎:InnoDB的

[[email protected] mysql]# service mysqld start 
MySQL Daemon failed to start. 
Starting mysqld:           [FAILED] 
[[email protected] 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良好地配合?

回答

0

好的,這實際上是much easier than expected

默認情況下SELinuxEnforcing,它可以防止意外寫入文件系統。我只需告訴SELinux,MySQL可以寫入非標準目錄。即:

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

Derp。要安裝semanage,請使用:

yum install policycoreutils-python 

現在再次運行該命令。這可能需要一些時間......

[[email protected]]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?" 

檢查,看看對SELinux配置爲這個新目錄通過查看這個配置文件:可以添加

[[email protected]]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local 

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

額外的目錄,例如,如果你有一個專門的tmp目錄。

[[email protected]]# semanage fcontext -a -t mysqld_db_t "/databases/mysql_tmp(/.*)?" 

再次檢查配置:

[[email protected]]# 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 ] 
1

這解決了我的問題

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 
7

所有我需要的是刪除這兩個文件分別是:

ib_logfile0 

ib_logfile1 

然後回到啓動mysql一切正常

相關問題