我们有两个 Ubuntu 实例,都配有 MySQL 服务器。其中一个实例中的 MySQL 每天都会无缘无故地关闭。
Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1031-aws x86_64)
在 MySQL 停止的实例中,我唯一能找到的是AppArmor
。最初我认为这不会给 MySQL 带来任何问题。但为了安全起见,我尝试删除 apparmor。
这是应用程序装甲删除的日志
ubuntu@ip-XX-XXX-XX-XX:~$ sudo apt remove apparmor
sudo: unable to resolve host ip-XX-XXX-XX-XX: Resource temporarily unavailable
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-aws-headers-4.15.0-1021 linux-aws-headers-4.15.0-1023 linux-aws-headers-4.15.0-1027 linux-aws-headers-4.15.0-1029 linux-aws-headers-4.15.0-1032
linux-aws-headers-4.15.0-1033
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
apparmor snapd ubuntu-core-launcher
0 upgraded, 0 newly installed, 3 to remove and 139 not upgraded.
1 not fully installed or removed.
After this operation, 69.6 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 222315 files and directories currently installed.)
Removing ubuntu-core-launcher (2.37.4+18.04.1) ...
Removing snapd (2.37.4+18.04.1) ...
Removing apparmor (2.12-4ubuntu5.1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up mysql-server-5.7 (5.7.25-0ubuntu0.18.04.2) ...
update-alternatives: warning: forcing reinstallation of alternative /etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
mysql_upgrade: [ERROR] 1146: Table 'mysql.plugin' doesn't exist
mysql_upgrade failed with exit status 5
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)
为什么 AppArmor 甚至在尝试卸载时也会尝试升级 MySQL?
这可能是 MySQL 关闭的原因吗?(每天 ~ UTC 时间上午 6:30)
编辑 这答案可能看起来有帮助。但问题仍然存在,为什么 apparmor 即使在尝试卸载时也需要更新 mysql?如果我将变量从
default-character-set = utf8
到
character_set_server = utf8
我可能会工作,但是这是否意味着 app armor 会自动更新/升级 mysql?
PS 有一个类似类型的问题,但细节很少,也没有答案。我没有尝试删除 app armor,所以我将问题单独提出。
答案1
第一次运行sudo apt 自动删除并看到它会帮助另一个我能看到的问题sudo:无法解析主机 ip-XX-XXX-XX-XX:资源暂时不可用尝试修复这些问题并重试。我认为一些过时的配置或资源会强制更改 mysql,请注意它是否是生产环境,并在接受更改之前检查它正在删除什么。