为什么MariaDB安装会持续很长时间?

bak*_*eok 4 server mysql command-line mariadb

mariaDB的安装持续了很长时间,结束了终端进程。

\n\n
$ sudo apt-get install mariadb-server mariadb-client\n
Run Code Online (Sandbox Code Playgroud)\n\n

尝试再次安装MariaDB导致以下问题:

\n\n
Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 31891 (apt-get) - open (11: Resource temporarily unavailable)\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以我找到了以下解决方案。

\n\n
$ sudo rm /var/lib/apt/lists/lock\n$ sudo rm /var/cache/apt/archives/lock\n$ sudo rm /var/lib/dpkg/lock*\n\n$ sudo dpkg --configure -a\n$ sudo apt update\n
Run Code Online (Sandbox Code Playgroud)\n\n

但这也出现了一些问题:

\n\n
$ sudo dpkg --configure -a\nSetting up mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\n^Cdpkg: error processing package mariadb-server-10.3 (--configure):\n installed mariadb-server-10.3 package post-installation script subprocess was interrupted\ndpkg: dependency problems prevent configuration of mariadb-server:\n mariadb-server depends on mariadb-server-10.3 (>= 1:10.3.22-0ubuntu0.19.10.1); however:\n  Package mariadb-server-10.3 is not configured yet.\n\ndpkg: error processing package mariadb-server (--configure):\n dependency problems - leaving unconfigured\nErrors were encountered while processing:\n mariadb-server-10.3\n mariadb-server\n
Run Code Online (Sandbox Code Playgroud)\n\n

我删除并重新安装了MariaDB,但安装很长时间没有完成。

\n\n
$ sudo apt-get install mariadb-server mariadb-client\nReading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nThe following additional packages will be installed:\n  mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3\n  mariadb-server-core-10.3\nSuggested packages:\n  mailx mariadb-test tinyca\nThe following NEW packages will be installed:\n  mariadb-client mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server\n  mariadb-server-10.3 mariadb-server-core-10.3\n0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 0 B/17.3 MB of archives.\nAfter this operation, 158 MB of additional disk space will be used.\nDo you want to continue? [Y/n] y \nPreconfiguring packages ...\nSelecting previously unselected package mariadb-common.\n(Reading database ... 212987 files and directories currently installed.)\nPreparing to unpack .../mariadb-common_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...\nUnpacking mariadb-common (1:10.3.22-0ubuntu0.19.10.1) ...\nSelecting previously unselected package mariadb-client-core-10.3.\nPreparing to unpack .../mariadb-client-core-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...\nUnpacking mariadb-client-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSelecting previously unselected package mariadb-client-10.3.\nPreparing to unpack .../mariadb-client-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...\nUnpacking mariadb-client-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSelecting previously unselected package mariadb-server-core-10.3.\nPreparing to unpack .../mariadb-server-core-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...\nUnpacking mariadb-server-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSetting up mariadb-common (1:10.3.22-0ubuntu0.19.10.1) ...\nupdate-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode\nSelecting previously unselected package mariadb-server-10.3.\n(Reading database ... 213145 files and directories currently installed.)\nPreparing to unpack .../mariadb-server-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...\nUnpacking mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSelecting previously unselected package mariadb-client.\nPreparing to unpack .../mariadb-client_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...\nUnpacking mariadb-client (1:10.3.22-0ubuntu0.19.10.1) ...\nSelecting previously unselected package mariadb-server.\nPreparing to unpack .../mariadb-server_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...\nUnpacking mariadb-server (1:10.3.22-0ubuntu0.19.10.1) ...\nSetting up mariadb-server-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSetting up mariadb-client-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSetting up mariadb-client-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nSetting up mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...\nCreated symlink /etc/systemd/system/mysql.service \xe2\x86\x92 /lib/systemd/system/mariadb.service.\nCreated symlink /etc/systemd/system/mysqld.service \xe2\x86\x92 /lib/systemd/system/mariadb.service.\nCreated symlink /etc/systemd/system/multi-user.target.wants/mariadb.service \xe2\x86\x92 /lib/systemd/system/mariadb.service.\n
Run Code Online (Sandbox Code Playgroud)\n

小智 5

如果您之前安装过 mySQL,并且您的 syslog 显示

AVC apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld"
Run Code Online (Sandbox Code Playgroud)

使用 Ubuntu/Debian 存储库时,清除、重新安装等不会有帮助。

持续存在的 AppArmor 配置文件将阻止 mariaDB 成功启动。

因此,任何想要在 Debian 或 Ubuntu 上从 mySQL 切换到 mariaDB 的人都会惨遭失败(是否有一些 Oracle 维护者参与了包的创建?;-))

这是从 18.04 起就已知的问题,包括修复,但直到现在才修复。

https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263

echo "/usr/sbin/mysqld { }" > /etc/apparmor.d/usr.sbin.mysqld
apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
Run Code Online (Sandbox Code Playgroud)

会修复它。然后,可以安装 mariaDB 和/或启动服务。