- 环境:ubuntu22.04 mysql8.0.39
- 问题:mysql服务突然停止shutdown,查看mysql异常日志如下:
Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.39-0ubuntu0.22.04.1).
/usr/sbin/mysqld: Forcing close of thread 24 user: 'zabbix'.
/usr/sbin/mysqld: Shutdown complete (mysqld 8.0.39-0ubuntu0.22.04.1) (Ubuntu).
- 排查:
- 查资料,有的说是DNS反向解析导致mysql异常停止,要开启skip-name-resolve,查my.cnf已开启。
- 查看/var/log/syslog和journalctl -xe
发现每次mysql停止前都会出现启动apt-daily-upgrade.service,而该服务是每天定时更新服务upgrade and clean activities,再查/var/log/apt/term.log也看到了确实是更新的时候触发mysql shutdown,也有出现mysql被直接升级到最新
- 解决:
卸载mysql服务(当时dpkg安装),重新安装;或者停止apt-daily-upgrade
ubuntu自动升级一些事
- 触发服务apt-daily和apt-daily-upgrade
systemctl status apt-daily-upgrade查看,都是调用同一个脚本/usr/lib/apt/apt.systemd.daily - 何为apt-daily-upgrade
顾名思义就是自动升级。
是否开启自动升级、自动升级规则,查看目录/etc/apt/apt.conf.d/
重点关注50unattended-upgrades(无人值守自动升级),默认都是开启,每日6点多默默后台升级 - 查看日志
已自动升级日志:/var/log/apt/history.log
升级日志明细(含kill):/var/log/apt/term.log - 自动升级规则
/etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
};
${distro_id}代表发行版的ID(如Ubuntu);
${distro_codename}代表发行版的代号(如jammy,对应于Ubuntu 22.04)
例如:`apt search mysql-server` (如下版本就支持自动升级)
mysql-server-8.0/jammy-updates,jammy-security 8.0.37-0ubuntu0.22.04.3 amd64
- 已安装包查看是否会被自动升级
apt policy mysql-server
mysql-server:
Installed: (none) (已安装版本)
Candidate: 8.0.37-0ubuntu0.22.04.3 (候选版本)
Version table: (版本表)
8.0.37-0ubuntu0.22.04.3 500
500 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
500 http://cn.archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages
8.0.28-0ubuntu4 500
500 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
- 经验
因此,如果使用apt安装来自ubuntu官方源的包,可能会被静默升级,导致服务不可用。
Comments