1. 问题描述

MYSQL 每天自动关闭,查看/var/log/mysql/error.log.1.gz ,内容如下:

2019-06-12T06:33:13.582973+08:00 0 [Note] Shutting down plugin ‘CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS’
2019-06-12T06:33:13.583022+08:00 0 [Note] Shutting down plugin ‘CONNECTION_CONTROL’
2019-06-12T06:33:13.583053+08:00 0 [Note] Shutting down plugin ‘ngram’
2019-06-12T06:33:13.583066+08:00 0 [Note] Shutting down plugin ‘partition’
2019-06-12T06:33:13.583078+08:00 0 [Note] Shutting down plugin ‘ARCHIVE’
2019-06-12T06:33:13.583089+08:00 0 [Note] Shutting down plugin ‘BLACKHOLE’
2019-06-12T06:33:13.583101+08:00 0 [Note] Shutting down plugin ‘MRG_MYISAM’
2019-06-12T06:33:13.583111+08:00 0 [Note] Shutting down plugin ‘MEMORY’
2019-06-12T06:33:13.583122+08:00 0 [Note] Shutting down plugin ‘MyISAM’
2019-06-12T06:33:13.583137+08:00 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA’
2019-06-12T06:33:13.583202+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_VIRTUAL’
2019-06-12T06:33:13.583218+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES’
2019-06-12T06:33:13.583228+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES’
2019-06-12T06:33:13.583238+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS’
2019-06-12T06:33:13.583247+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN’
2019-06-12T06:33:13.583256+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_FIELDS’
2019-06-12T06:33:13.583265+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS’
2019-06-12T06:33:13.583274+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_INDEXES’
2019-06-12T06:33:13.583283+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS’
2019-06-12T06:33:13.583292+08:00 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLES’
2019-06-12T06:33:13.583302+08:00 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE’

2. 解决过程

网上有很多帖子,基本都是修改 /etc/mysql/my.cnf 文件相关配置

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
log_bin=mysql_bin_log
server-id=1
max_connections=1024
open_files_limit=65535
table_open_cache=2048
#connection-control-failed-connections-threshold=5 #login failed times
#connection-control-min-connection-delay=108000 #login tryagin timeout
skip-name-resolve
wait_timeout=31536000
interactive_timeout=31536000
explicit_defaults_for_timestamp=true
skip-ssl
log_timestamps = SYSTEM

尝试修改了各种参数,/var/log/mysql/error.log 中各种错误信息一个都没有了,但是第二天还是关机,问题没有解决,有点崩溃了。

mysql的错误日志文件没有任何错误信息,只能看系统日志文件了。

vi /var/log/syslog.1

mon.Worker [INFO]: Updating cache
Jun 12 06:26:49 gmt-PowerEdge-R620 AptDaemon.Worker: INFO: Finished transaction /org/debian/apt/transaction/1cf051be572f4eab833c3ae618e14ace
Jun 12 06:26:49 gmt-PowerEdge-R620 org.debian.apt[1493]: 06:26:49 AptDaemon.Worker [INFO]: Finished transaction /org/debian/apt/transaction/1cf051be572f4eab833c3ae618e14ace
Jun 12 06:31:52 gmt-PowerEdge-R620 systemd[1]: Starting Daily apt upgrade and clean activities…
Jun 12 06:33:05 gmt-PowerEdge-R620 gnome-session[5949]: (gnome-software:6160): As-WARNING **: failed to rescan: Failed to parse /usr/share/applications/vim.desktop.dpkg-new file: cannot process file of type text/plain
Jun 12 06:33:05 gmt-PowerEdge-R620 gnome-session[5949]: (gnome-software:6160): As-WARNING **: failed to rescan: Failed to parse /usr/share/applications/vim.desktop.dpkg-tmp file: cannot process file of type text/plain
Jun 12 06:33:06 gmt-PowerEdge-R620 gnome-session[5949]: (gnome-software:6160): As-WARNING **: failed to rescan: Failed to parse /usr/share/applications/vim.desktop file: cannot process file of type application/x-desktop
Jun 12 06:33:07 gmt-PowerEdge-R620 systemd[1]: Reloading.
Jun 12 06:33:07 gmt-PowerEdge-R620 systemd[1]: [/lib/systemd/system/mysql.service:22] Unknown lvalue ‘LimitNPPOC’ in section ‘Service’
Jun 12 06:33:07 gmt-PowerEdge-R620 systemd[1]: Started CUPS Scheduler.
Jun 12 06:33:07 gmt-PowerEdge-R620 systemd[1]: Started ACPI event daemon.
Jun 12 06:33:10 gmt-PowerEdge-R620 systemd[1]: Reloading.
Jun 12 06:33:10 gmt-PowerEdge-R620 systemd[1]: [/lib/systemd/system/mysql.service:22] Unknown lvalue ‘LimitNPPOC’ in section ‘Service’
Jun 12 06:33:10 gmt-PowerEdge-R620 systemd[1]: Started CUPS Scheduler.
Jun 12 06:33:10 gmt-PowerEdge-R620 systemd[1]: Started ACPI event daemon.
Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: Reloading.
Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: [/lib/systemd/system/mysql.service:22] Unknown lvalue ‘LimitNPPOC’ in section ‘Service’
Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: Started CUPS Scheduler.
Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: Started ACPI event daemon.
Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: Stopping MySQL Community Server…
Jun 12 06:33:15 gmt-PowerEdge-R620 systemd[1]: Stopped MySQL Community Server.
Jun 12 06:33:19 gmt-PowerEdge-R620 systemd[1]: Reloading.
Jun 12 06:33:19 gmt-PowerEdge-R620 systemd[1]: [/lib/systemd/system/mysql.service:22] Unknown lvalue ‘LimitNPPOC’ in section ‘Service’
Jun 12 06:33:19 gmt-PowerEdge-R620 systemd[1]: Started CUPS Scheduler.
Jun 12 06:33:19 gmt-PowerEdge-R620 systemd[1]: Started ACPI event daemon.
Jun 12 06:33:20 gmt-PowerEdge-R620 dbus[1493]: [system] Reloaded configuration
Jun 12 06:33:20 gmt-PowerEdge-R620 systemd[1]: Stopped target Sockets.
Jun 12 06:33:20 gmt-PowerEdge-R620 systemd[1]: Stopping Sockets.
Jun 12 06:33:20 gmt-PowerEdge-R620 systemd[1]: Reached target Sockets.
Jun 12 06:33:21 gmt-PowerEdge-R620 gnome-session[5949]: (gnome-software:6160): As-WARNING **: failed to rescan: Failed to parse /usr/share/applications/bamf-2.index file: cannot process file of type text/plain
Jun 12 06:33:34 gmt-PowerEdge-R620 systemd[1]: Started Daily apt upgrade and clean activities.
Jun 12 06:35:01 gmt-PowerEdge-R620 CRON[19079]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)

搜索发现系统日志文件中在 “Jun 12 06:33:11 gmt-PowerEdge-R620 systemd[1]: Stopping MySQL Community Server…” 之前有“Jun 12 06:31:52 gmt-PowerEdge-R620 systemd[1]: Starting Daily apt upgrade and clean activities…” 信息,所以怀疑在每天执行更新的时候,将这个MySQL 给停止了。

所以,将这个每天进行系统更新的任务取消,操作如下:

apt-get remove unattended-upgrades
systemctl kill --kill-who=all apt-daily.service
systemctl stop apt-daily.timer
systemctl disable apt-daily.timer
systemctl stop apt-daily.service
systemctl disable apt-daily.service
systemctl mask apt-daily.service
systemctl daemon-reload

关闭完成后检查结果:

systemctl status apt-daily.timer

注意结果中的:

Active: inactive (dead)