p2@P2:~$sudo systemctl restart mariadb
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
p2@P2:~$sudo systemctl status mariadb
mariadb.service - MariaDB 10.3.31 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
Active: failed (Result: exit-code) since Fri 2021-08-13 15:13:46 CEST; 5min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 313918 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 313919 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 313921 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSRE>
Process: 313968 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=127)
Main PID: 313968 (code=exited, status=127)
srp 13 15:13:46 P2 systemd[1]: Starting MariaDB 10.3.31 database server...
srp 13 15:13:46 P2 mysqld[313968]: /usr/sbin/mysqld: error while loading shared libraries: liblz4.so.1: cannot open shared object file: No such file or directory
srp 13 15:13:46 P2 systemd[1]: mariadb.service: Main process exited, code=exited, status=127/n/a
srp 13 15:13:46 P2 systemd[1]: mariadb.service: Failed with result 'exit-code'.
srp 13 15:13:46 P2 systemd[1]: Failed to start MariaDB 10.3.31 database server.
srp 13 15:13:46 P2 mysqld[313968]: /usr/sbin/mysqld: 加载共享库时出错: liblz4.so.1: 无法打开共享对象文件: 没有此文件或目录
好的,所以 mariaDB 找不到 liblz4-1 库。但是:
软件包 liblz4-1 已安装且为最新版本。liblz4.so.1 安装在 /lib/x86_64-linux-gnu/liblz4.so.1
如果我们单独运行 mariaDB:
p2@P2:~$ /usr/sbin/mysqld
/usr/sbin/mysqld: error while loading shared libraries: liblz4.so.1: cannot open shared object file: No such file or directory
但是如果我们在 mariaDB 上运行 ldd 来查找所需的库:
p2@P2:~$ ldd /usr/sbin/mysqld
linux-vdso.so.1 (0x00007ffe322c0000)
liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fa0406cd000)
libsnappy.so.1 => /lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007fa0406c2000)
libaio.so.1 => /lib/x86_64-linux-gnu/libaio.so.1 (0x00007fa0406bd000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa0406a1000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fa04062e000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fa0405f3000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fa040542000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa04053c000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa04035a000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa04020b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa0401e8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa03fff6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa03ffd9000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa03ffce000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fa03ffa5000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fa03fe87000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa0423ec000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fa03fe64000)
LDD能找到库!(如果找不到,则会输出 liblz4.so.1 => not found)
好的,那么是什么原因导致了这个错误以及如何让 mariaDB 运行?
补充说明:在互联网上进行深入研究后发现,这个问题可能由于丢失/损坏库加载器。但是,我怀疑给出的建议已经过时了,因为他们的问题是由我的多个体系结构引起的,而我系统中的软件包是 64 位的。此外,他们提到的加载器在我的发行版中不存在。
另外,我正在使用 Ubuntu 20.04.2 LTS。
编辑:库校验和
find / -name "liblz4.so*" -type f 2> /dev/null | xargs sha256sum
536ab2f5d4448fd1ff62d43b99ece092ec7824b083af7c7007bb0889353d2777 /snap/snap-store/542/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
536ab2f5d4448fd1ff62d43b99ece092ec7824b083af7c7007bb0889353d2777 /snap/snap-store/547/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
c619a6d991c87ec2967b2b0c417ae5a9b86a76f11396ff5492947b4f637369db /snap/snapd/12704/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
c619a6d991c87ec2967b2b0c417ae5a9b86a76f11396ff5492947b4f637369db /snap/snapd/12398/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
c619a6d991c87ec2967b2b0c417ae5a9b86a76f11396ff5492947b4f637369db /snap/core/11420/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
c619a6d991c87ec2967b2b0c417ae5a9b86a76f11396ff5492947b4f637369db /snap/core/11316/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
536ab2f5d4448fd1ff62d43b99ece092ec7824b083af7c7007bb0889353d2777 /snap/core18/2128/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
536ab2f5d4448fd1ff62d43b99ece092ec7824b083af7c7007bb0889353d2777 /snap/core18/2074/usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
d6574e34006e27cfb5d00dc75018cc06832d0bbc9e1b35316b9c03148355f0a0 /usr/lib/x86_64-linux-gnu/liblz4.so.1.9.2
答案1
这是 AppArmor,令人烦恼的是它显示“没有这样的文件或目录”。这个答案在 Ubuntu 20.04 LTS(服务器)上为我修复了这个问题:https://stackoverflow.com/a/60423057/539198
这对我有用:-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
但它也会禁用系统上的 MySQL 的 AppArmor。
答案2
要从应用程序装甲中删除 mariadb,这对我有用
要解决此问题,请在应用程序装甲状态输出中查找 mysqld:
$ sudo aa-status
然后按照以下步骤从应用程序防护中删除 mysqld:
$ echo "/usr/sbin/mysqld { }" | sudo tee /etc/apparmor.d/usr.sbin.mysqld
$ sudo apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
$ sudo systemctl restart mariadb