Debian

為什麼 MariaDB 升級後無法啟動 (NO_NEW_PRIVILEGES)

  • April 28, 2019

在 DigitalOcean 上升級我的 debian(testing, jessie to stretch) 伺服器後,MariaDB 不會以service mariadb start 啟動

我試圖清除所有 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

在#debian-next 的幫助下,我發現問題可能出在 digitalocean 自定義核心中。

檢查後發現我使用的是不是最新的核心——3.2.0-4,但是在從 Web 界面選擇更新的版本並重新啟動後它工作正常。

我無法升級核心(這是一個 vps)。

我找到了一個解決方案:

編輯/lib/systemd/system/mariadb.service

更改PrivateDevices=truePrivateDevices=false

systemctl daemon-reload

systemctl start mysql

引用自:https://serverfault.com/questions/831503