MySQL/Tritonn - SELinuxにご注意を(回避方法あり)

いつの頃からかは知りませんが、Linux(CentOSとか)をインストールするとデフォルトでSELinuxが有効(Enfocing)になっていました。

GUIインストーラ作業時にDisabledにするか、あるいは/etc/selinux/configでSELINUX=disabledにしておけばいいのですが、そのままにしておくと/etc/init.dからのmysqlの起動に失敗します。

こんな感じ。

[root@centos52 ~]# service mysql start
Starting MySQL..Manager of pid-file quit without updating f[失敗]

mysqld_safeを直接叩くと起動できたり、

[root@centos52 ~]# which mysqld_safe
/usr/bin/mysqld_safe
[root@centos52 ~]# mysqld_safe &
[1] 2985
[root@centos52 ~]# Starting mysqld daemon with databases from /var/lib/mysql

[root@centos52 ~]#

エラーログを見ると

081210 09:52:34  mysqld started
081210 09:52:36  mysqld ended

081210 09:53:08  mysqld started
081210 09:53:09  mysqld ended

特に何も書かれていないので原因が特定しにくいのですが、これはSELinuxの設定に起因しています。

厳しい言い方をすると、mysqld側のログ出力が甘い、ということなのですが。

というわけでご注意を。

問題回避のためのSELinux設定例。

tritonn@tritonn64:~$ cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

追記

以下のようにSELinux側で設定を追加することでも対応可能とのことです。byコメント欄

restorecon -FRv /var/lib/mysql

ということは、mysql.specに書いておけばいいのかな!?