为什么 MariaDB 升级后无法启动(NO_NEW_PRIVILEGES)

为什么 MariaDB 升级后无法启动(NO_NEW_PRIVILEGES)

在 DigitalOcean 上升级我的 debian(测试,jessie 到 stretch)服务器后,MariaDB 无法启动服务 MariaDB 启动

我尝试清除所有 mariadb-* 和 mysql-* 包,删除配置和数据,然后重新安装它们,但 mariadb-server-10.1.21-5 拒绝配置:

Setting up mariadb-server-10.1 (10.1.21-5) ...
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mariadb.service - MariaDB database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2017-02-09 21:25:27 CET; 10ms ago
  Process: 1696 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=227/NO_NEW_PRIVILEGES)
  Process: 1589 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 1584 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 1582 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 1696 (code=exited, status=227/NO_NEW_PRIVILEGES)

Feb 09 21:25:27 cddssh systemd[1]: Starting MariaDB database server...
Feb 09 21:25:27 cddssh systemd[1696]: mariadb.service: Failed at step NO_NEW_PRIVILEGES spawning /usr/sbin/mysqld: Invalid argument
Feb 09 21:25:27 cddssh systemd[1]: mariadb.service: Main process exited, code=exited, status=227/NO_NEW_PRIVILEGES
Feb 09 21:25:27 cddssh systemd[1]: Failed to start MariaDB database server.
Feb 09 21:25:27 cddssh systemd[1]: mariadb.service: Unit entered failed state.
Feb 09 21:25:27 cddssh systemd[1]: mariadb.service: Failed with result 'exit-code'.
dpkg: error processing package mariadb-server-10.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mariadb-server:
 mariadb-server depends on mariadb-server-10.1 (>= 10.1.21-5); however:
  Package mariadb-server-10.1 is not configured yet.

dpkg: error processing package mariadb-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mariadb-server-10.1
 mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

这是输出journalctl-xe在我尝试启动服务后:

Feb 09 05:10:52 cddssh systemd[1]: mariadb.service: Failed to set invocation ID on control group /system.slice/mariadb.service, ignoring: Operation not supported
Feb 09 05:10:52 cddssh systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit mariadb.service has begun starting up.
Feb 09 05:10:52 cddssh systemd[7114]: mariadb.service: Failed at step NO_NEW_PRIVILEGES spawning /usr/sbin/mysqld: Invalid argument
-- Subject: Process /usr/sbin/mysqld could not be executed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The process /usr/sbin/mysqld could not be executed and failed.
--
-- The error number returned by this process is 22.
Feb 09 05:10:52 cddssh systemd[1]: mariadb.service: Main process exited, code=exited, status=227/NO_NEW_PRIVILEGES
Feb 09 05:10:52 cddssh systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Feb 09 05:10:52 cddssh systemd[1]: mariadb.service: Unit entered failed state.
Feb 09 05:10:52 cddssh systemd[1]: mariadb.service: Failed with result 'exit-code'.

mysql 错误日志没有错误/警告。

我可以自行启动 mysqld 二进制文件。

我尝试按照以下说明进行操作https://mariadb.com/kb/en/mariadb/upgrade-10116maria-1jessie-broke-system/但后来我得到了错误

mariadb.service:步骤 NO_NEW_PRIVILEGES 失败,生成 /usr/sbin/mysqld:参数无效

似乎它与 selinux 有关,因为我在 /lib/systemd/system/mariadb.service 中发现了这些行

# Doesn't yet work properly with SELinux enabled
# NoNewPrivileges=true

有人对超级用户提出了非常类似的问题,但我不明白他是如何解决这个问题的:https://superuser.com/questions/1103321/mariadb-server-broken-after-failed-package-update

答案1

在#debian-next 的帮助下,我发现问题可能出在 digitalocean 自定义内核中。

检查后发现我使用的内核不是太新 – 3.2.0-4,但从 Web 界面选择了较新的版本并重新启动后,它就可以正常工作了。

答案2

我无法升级内核(这是一个 vps)。

我找到了一个解决方案:

编辑/lib/systemd/system/mariadb.service

改成PrivateDevices=truePrivateDevices=false

跑步systemctl daemon-reload

systemctl start mysql

答案3

我在使用 Debian 9.1 和 MariaDB 时也遇到了同样的问题10.1.26-MariaDB-0+deb9u1。似乎也与内核版本有关。将内核从 更新到 解决3.2.504.9.0-3-amd64该问题。

答案4

对我来说,这也是内核(升级到 4.9.0-3-amd64);只有我在 Xen vm 中运行 MariaDB。

内核是从启动脚本中获取的 Dom0,因此即使更新后,它仍然有旧内核。更改 Dom0 上的脚本解决了 MariaDB 问题。

相关内容