今天早些时候,我尝试关闭我的 Ubuntu 20.04.1 LTS 服务器。执行此操作时,我收到以下消息:
Operation inhibited by "APT" (PID 729631 "unattended-upgr", user root), reason is "APT is installing or removing packages".
Please retry operation after closing inhibitors and logging out other users.
Alternatively, ignore inhibitors and users with 'systemctl poweroff -i'.
同样地,这会抑制 apt 的运行,我试图看看这是否会对问题有所帮助:
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 729611 (unattended-upgr)..
我调查了导致此锁定的原因,发现自今天早上以来,以下进程一直在运行:
$ sudo ps -eaf | grep -i apt
root 729574 1 0 06:37 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
root 729579 729574 0 06:37 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install
$ sudo ps -eaf | grep -i unat
root 1073 1 0 Nov20 ? 00:00:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 729611 729579 0 06:37 ? 00:02:06 /usr/bin/python3 /usr/bin/unattended-upgrade
root 729631 729611 0 06:37 ? 00:01:00 /usr/bin/python3 /usr/bin/unattended-upgrade
我检查了升级的进度,这给了我一个罪魁祸首和一个进度指示器,在过去的 3 或 4 个小时内它根本没有移动:
$ tail -f /var/run/unattended-upgrades.progress
Progress: 84.6154 % (mysql-server-8.0)
以下是正在运行的mysql相关进程:
$ ps -ef | grep mysql
root 729960 729959 0 06:40 pts/0 00:00:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
root 729966 729960 0 06:40 pts/0 00:00:00 /bin/bash /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
root 730079 729966 0 06:42 pts/0 00:00:00 fuser /var/lib/mysql/ibdata1
看起来像是挂起的更新日志:
$ cat /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
Log started: 2020-12-01 06:37:25
Preconfiguring packages ...
Preconfiguring packages ...
(Reading database ... 139629 files and directories currently installed.)
Preparing to unpack .../mysql-client-8.0_8.0.22-0ubuntu0.20.04.3_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.22-0ubuntu0.20.04.3) over (8.0.22-0ubuntu0.20.04.2) ...
Preparing to unpack .../mysql-server-8.0_8.0.22-0ubuntu0.20.04.3_amd64.deb ...
Unpacking mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) over (8.0.22-0ubuntu0.20.04.2) ...
Preparing to unpack .../mysql-server-core-8.0_8.0.22-0ubuntu0.20.04.3_amd64.deb ...
Unpacking mysql-server-core-8.0 (8.0.22-0ubuntu0.20.04.3) over (8.0.22-0ubuntu0.20.04.2) ...
Setting up mysql-server-core-8.0 (8.0.22-0ubuntu0.20.04.3) ...
Setting up mysql-client-8.0 (8.0.22-0ubuntu0.20.04.3) ...
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
Installing new version of config file /etc/mysql/mysql.conf.d/mysqld.cnf ...
所以我想我的问题是,我该怎么做?在尝试研究这个问题的过程中,我发现很多帖子都说不要随便终止进程和删除锁,我该如何安全地解决这个问题?
我看不到链接,但我会提到它以防万一:我的网络 NAS 挂载似乎也遇到了一些问题,几天前它被关闭了。可疑,我刚刚尝试卸载它,但该命令挂起了。
编辑:看来我的失踪坐骑曾是问题最终还是出现了:我刚刚重新打开它,升级过程和锁定立即完成。