我正在尝试让 mariadb 10.2/10.3 在全新安装的 ubuntu server 6.04(附带 mysql 5.7)上运行。安装过程很顺利,一切正常,直到我重新启动系统,然后 mariadb 服务将不再启动,并返回超时错误
Job for mariadb.service failed because a timeout was exceeded. See "systemctl status mariadb.service" and "journalctl -xe" for details
systemctl status 返回:
mariadb.service - MariaDB 10.2.20 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
migrated-from-my.cnf-settings.conf
Active: failed (Result: timeout) Since Mon 2019-05-13 18:04:28 CEST; 46s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1922 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 1909 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery && VAR = || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-enviroment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 1901 ExecStartPre=/bin/sh -c systemctl unset-enviroment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process 1898 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
MainPID: 1922 (code=exited, status=0/SUCCESS)
ubuntu mysqld[1922]: [Note] Event Scheduler: Purging the queue. 0 events
ubuntu mysqld[1922]: [Note] InnoDB: Starting shutdown
ubuntu mysqld[1922]: [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
ubuntu mysqld[1922]: [Note] InnoDB: Buffer pool(s) to /var/lib/mysqld/ib_buffer_pool
ubuntu mysqld[1922]: [Note] InnoDB: Shutdown completed; log sequence number 3074612
ubuntu mysqld[1922]: [Note] InnoDB:Removed temporary tablespace data file "ibtmp1"
ubuntu mysqld[1922]: [Note] /usr/sbin/mysqld: Shutdown complete
ubuntu systemd[1]: Failed to start MariaDB 10.2.20 database server
ubuntu systemd[1]: mariadb.service: Unit entered failed state.
ubuntu systemd[1]: mariadb.service: Failed with result 'timeout'.
journalctl -xe 返回很多
AVC apparmor="DENIED" operation="open" or with operation="sendmsg"
答案1
以下是 /etc/apparmor.d/usr.sbin.mysqld 的一些内容,请分别更改您的目录。
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>
/usr/sbin/mysqld {
#include <abstractions/base>
...
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
...
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
重新加载装甲服务
$sudo service apparmor reload