这几天,我的三台服务器几乎同时出现同样的问题,大约每24小时一次。
几个月来我没有对使用 MySQL 或 ubuntu 配置的代码进行任何更改。
在错误日志(/var/log/mysql/error.log)中我看到 MySQL 显然无缘无故地自行停止了:
2022-02-10T06:48:17.246813Z 0 [Note] Giving 10 client threads a chance to die gracefully
2022-02-10T06:48:17.246853Z 0 [Note] Shutting down slave threads
2022-02-10T06:48:19.246990Z 0 [Note] Forcefully disconnecting 10 remaining clients
2022-02-10T06:48:19.247028Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 7 user: 'root'
2022-02-10T06:48:19.249583Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 10 user: 'root'
2022-02-10T06:48:19.249613Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 8 user: 'root'
2022-02-10T06:48:19.249628Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 51 user: 'root'
2022-02-10T06:48:19.249641Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 3 user: 'root'
2022-02-10T06:48:19.249654Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 2 user: 'root'
2022-02-10T06:48:19.249667Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 4 user: 'root'
2022-02-10T06:48:19.249680Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 5 user: 'root'
2022-02-10T06:48:19.249693Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 6 user: 'root'
2022-02-10T06:48:19.249705Z 0 [Warning] /usr/sbin/mysqld: Forcing close of thread 9 user: 'root'
2022-02-10T06:48:19.249723Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2022-02-10T06:48:19.252212Z 0 [Note] Binlog end
2022-02-10T06:48:19.254111Z 0 [Note] Shutting down plugin 'ngram'
2022-02-10T06:48:19.254125Z 0 [Note] Shutting down plugin 'partition'
2022-02-10T06:48:19.254130Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2022-02-10T06:48:19.254135Z 0 [Note] Shutting down plugin 'ARCHIVE'
2022-02-10T06:48:19.254139Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2022-02-10T06:48:19.254168Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2022-02-10T06:48:19.254173Z 0 [Note] Shutting down plugin 'MyISAM'
2022-02-10T06:48:19.254180Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2022-02-10T06:48:19.254184Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2022-02-10T06:48:19.254188Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2022-02-10T06:48:19.254191Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2022-02-10T06:48:19.254195Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2022-02-10T06:48:19.254198Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2022-02-10T06:48:19.254202Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2022-02-10T06:48:19.254206Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2022-02-10T06:48:19.254209Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2022-02-10T06:48:19.254213Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2022-02-10T06:48:19.254216Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2022-02-10T06:48:19.254220Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2022-02-10T06:48:19.254223Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2022-02-10T06:48:19.254227Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2022-02-10T06:48:19.254230Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2022-02-10T06:48:19.254234Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2022-02-10T06:48:19.254237Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2022-02-10T06:48:19.254241Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2022-02-10T06:48:19.254244Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2022-02-10T06:48:19.254248Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2022-02-10T06:48:19.254251Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2022-02-10T06:48:19.254255Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2022-02-10T06:48:19.254258Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2022-02-10T06:48:19.254262Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2022-02-10T06:48:19.254265Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2022-02-10T06:48:19.254269Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2022-02-10T06:48:19.254272Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2022-02-10T06:48:19.254276Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2022-02-10T06:48:19.254279Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2022-02-10T06:48:19.254295Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2022-02-10T06:48:19.254299Z 0 [Note] Shutting down plugin 'InnoDB'
2022-02-10T06:48:19.254402Z 0 [Note] InnoDB: FTS optimize thread exiting.
2022-02-10T06:48:19.254552Z 0 [Note] InnoDB: Starting shutdown...
2022-02-10T06:48:19.354843Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2022-02-10T06:48:19.356501Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 220210 6:48:19
2022-02-10T06:48:20.819810Z 0 [Note] InnoDB: Shutdown completed; log sequence number 36134591308
2022-02-10T06:48:20.820191Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-02-10T06:48:20.820204Z 0 [Note] Shutting down plugin 'MEMORY'
2022-02-10T06:48:20.820215Z 0 [Note] Shutting down plugin 'CSV'
2022-02-10T06:48:20.820222Z 0 [Note] Shutting down plugin 'sha256_password'
2022-02-10T06:48:20.820225Z 0 [Note] Shutting down plugin 'mysql_native_password'
2022-02-10T06:48:20.820358Z 0 [Note] Shutting down plugin 'binlog'
2022-02-10T06:48:20.821311Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2022-02-10T06:48:21.370898Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-10T06:48:21.372832Z 0 [Note] mysqld (mysqld 5.7.37-0ubuntu0.18.04.1) starting as process 8693 ...
2022-02-10T06:48:21.377512Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-02-10T06:48:21.377533Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-02-10T06:48:21.377538Z 0 [Note] InnoDB: Uses event mutexes
2022-02-10T06:48:21.377543Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-02-10T06:48:21.377547Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-02-10T06:48:21.377551Z 0 [Note] InnoDB: Using Linux native AIO
2022-02-10T06:48:21.377803Z 0 [Note] InnoDB: Number of pools: 1
2022-02-10T06:48:21.377915Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-02-10T06:48:21.379635Z 0 [Note] InnoDB: Initializing buffer pool, total size = 1G, instances = 8, chunk size = 128M
2022-02-10T06:48:21.447914Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-02-10T06:48:21.463713Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-02-10T06:48:21.484266Z 0 [Note] InnoDB: Opened 3 undo tablespaces
2022-02-10T06:48:21.484292Z 0 [Note] InnoDB: 0 undo tablespaces made active
2022-02-10T06:48:21.484511Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-02-10T06:48:21.520917Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-02-10T06:48:21.521030Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-02-10T06:48:21.552476Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-02-10T06:48:21.552668Z 0 [Warning] InnoDB: The parameter innodb_undo_logs is deprecated and may be removed in future releases. Please use innodb_rollback_segments instead. See http://dev.mysql.com/doc/refman/5.7/en/innodb-undo-logs.html
2022-02-10T06:48:21.553292Z 0 [Note] InnoDB: 1 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
2022-02-10T06:48:21.553304Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-02-10T06:48:21.553598Z 0 [Note] InnoDB: Waiting for purge to start
2022-02-10T06:48:21.603836Z 0 [Note] InnoDB: 5.7.37 started; log sequence number 36134591308
2022-02-10T06:48:21.604219Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-02-10T06:48:21.604678Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-02-10T06:48:21.606857Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.gtid_executed' doesn't exist
2022-02-10T06:48:21.606890Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-02-10T06:48:21.608219Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-02-10T06:48:21.608233Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2022-02-10T06:48:21.608238Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-02-10T06:48:21.608241Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-02-10T06:48:21.611484Z 0 [Warning] CA certificate ca.pem is self signed.
2022-02-10T06:48:21.611520Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2022-02-10T06:48:21.614815Z 0 [Warning] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2022-02-10T06:48:21.615451Z 0 [Warning] InnoDB: Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T06:48:21.615470Z 0 [Warning] Failed to open optimizer cost constant tables
2022-02-10T06:48:21.616297Z 0 [Warning] InnoDB: Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T06:48:21.616314Z 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
2022-02-10T06:48:21.616955Z 0 [Warning] InnoDB: Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T06:48:21.617005Z 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2022-02-10T06:48:21.682478Z 0 [Note] mysqld: ready for connections.
Version: '5.7.37-0ubuntu0.18.04.1' socket: '/tmp/tmp.q6ChLS0FIM/mysqld.sock' port: 0 (Ubuntu)
2022-02-10T06:48:21.747960Z 3 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T06:48:21.751266Z 0 [Note] Giving 0 client threads a chance to die gracefully
2022-02-10T06:48:21.751284Z 0 [Note] Shutting down slave threads
2022-02-10T06:48:21.751291Z 0 [Note] Forcefully disconnecting 0 remaining clients
2022-02-10T06:48:21.751331Z 0 [Note] Binlog end
2022-02-10T06:48:21.751679Z 0 [Note] Shutting down plugin 'ngram'
2022-02-10T06:48:21.751688Z 0 [Note] Shutting down plugin 'partition'
2022-02-10T06:48:21.751692Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2022-02-10T06:48:21.751696Z 0 [Note] Shutting down plugin 'ARCHIVE'
2022-02-10T06:48:21.751699Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2022-02-10T06:48:21.751726Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2022-02-10T06:48:21.751730Z 0 [Note] Shutting down plugin 'MyISAM'
2022-02-10T06:48:21.751736Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2022-02-10T06:48:21.751740Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2022-02-10T06:48:21.751743Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2022-02-10T06:48:21.751747Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2022-02-10T06:48:21.751750Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2022-02-10T06:48:21.751753Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2022-02-10T06:48:21.751757Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2022-02-10T06:48:21.751760Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2022-02-10T06:48:21.751771Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2022-02-10T06:48:21.751775Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2022-02-10T06:48:21.751778Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2022-02-10T06:48:21.751782Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2022-02-10T06:48:21.751785Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2022-02-10T06:48:21.751788Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2022-02-10T06:48:21.751792Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2022-02-10T06:48:21.751795Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2022-02-10T06:48:21.751798Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2022-02-10T06:48:21.751802Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2022-02-10T06:48:21.751805Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2022-02-10T06:48:21.751808Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2022-02-10T06:48:21.751812Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2022-02-10T06:48:21.751815Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2022-02-10T06:48:21.751818Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2022-02-10T06:48:21.751822Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2022-02-10T06:48:21.751825Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2022-02-10T06:48:21.751828Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2022-02-10T06:48:21.751832Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2022-02-10T06:48:21.751835Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2022-02-10T06:48:21.751838Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2022-02-10T06:48:21.751842Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2022-02-10T06:48:21.751845Z 0 [Note] Shutting down plugin 'InnoDB'
2022-02-10T06:48:21.751876Z 0 [Note] InnoDB: FTS optimize thread exiting.
2022-02-10T06:48:21.751974Z 0 [Note] InnoDB: Starting shutdown...
2022-02-10T06:48:21.752015Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220210 6:48:21
2022-02-10T06:48:21.752037Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2022-02-10T06:48:21.752203Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 220210 6:48:21
2022-02-10T06:48:23.180121Z 0 [Note] InnoDB: Shutdown completed; log sequence number 36134591327
2022-02-10T06:48:23.181629Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-02-10T06:48:23.181644Z 0 [Note] Shutting down plugin 'MEMORY'
2022-02-10T06:48:23.181651Z 0 [Note] Shutting down plugin 'CSV'
2022-02-10T06:48:23.181656Z 0 [Note] Shutting down plugin 'sha256_password'
2022-02-10T06:48:23.181660Z 0 [Note] Shutting down plugin 'mysql_native_password'
2022-02-10T06:48:23.181788Z 0 [Note] Shutting down plugin 'binlog'
2022-02-10T06:48:23.182138Z 0 [Note] mysqld: Shutdown complete
当我启动 MySQL 时,日志显示以下内容:
2022-02-10T07:00:47.819747Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-10T07:00:47.821725Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.37-0ubuntu0.18.04.1) starting as process 8871 ...
2022-02-10T07:00:47.826117Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-02-10T07:00:47.826140Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-02-10T07:00:47.826145Z 0 [Note] InnoDB: Uses event mutexes
2022-02-10T07:00:47.826150Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-02-10T07:00:47.826155Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-02-10T07:00:47.826160Z 0 [Note] InnoDB: Using Linux native AIO
2022-02-10T07:00:47.826411Z 0 [Note] InnoDB: Number of pools: 1
2022-02-10T07:00:47.826520Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-02-10T07:00:47.829890Z 0 [Note] InnoDB: Initializing buffer pool, total size = 1G, instances = 8, chunk size = 128M
2022-02-10T07:00:47.900431Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-02-10T07:00:47.916391Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-02-10T07:00:47.928336Z 0 [Note] InnoDB: Opened 3 undo tablespaces
2022-02-10T07:00:47.928362Z 0 [Note] InnoDB: 0 undo tablespaces made active
2022-02-10T07:00:47.928568Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-02-10T07:00:47.958351Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-02-10T07:00:47.958418Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-02-10T07:00:47.988870Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-02-10T07:00:47.989095Z 0 [Warning] InnoDB: The parameter innodb_undo_logs is deprecated and may be removed in future releases. Please use innodb_rollback_segments instead. See http://dev.mysql.com/doc/refman/5.7/en/innodb-undo-logs.html
2022-02-10T07:00:47.989671Z 0 [Note] InnoDB: 1 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
2022-02-10T07:00:47.989680Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-02-10T07:00:47.989974Z 0 [Note] InnoDB: Waiting for purge to start
2022-02-10T07:00:48.040194Z 0 [Note] InnoDB: 5.7.37 started; log sequence number 36134591327
2022-02-10T07:00:48.040548Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-02-10T07:00:48.041907Z 0 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.plugin' doesn't exist
2022-02-10T07:00:48.041936Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2022-02-10T07:00:48.042370Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.gtid_executed' doesn't exist
2022-02-10T07:00:48.042391Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-02-10T07:00:48.043734Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-02-10T07:00:48.043748Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2022-02-10T07:00:48.043753Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-02-10T07:00:48.043756Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-02-10T07:00:48.044304Z 0 [Warning] CA certificate ca.pem is self signed.
2022-02-10T07:00:48.044336Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2022-02-10T07:00:48.044406Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2022-02-10T07:00:48.044423Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2022-02-10T07:00:48.046215Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2022-02-10T07:00:48.046442Z 0 [Warning] InnoDB: Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T07:00:48.046460Z 0 [Warning] Failed to open optimizer cost constant tables
2022-02-10T07:00:48.046921Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-02-10T07:00:48.050380Z 0 [Warning] InnoDB: Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T07:00:48.050401Z 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
2022-02-10T07:00:48.053135Z 0 [Warning] InnoDB: Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2022-02-10T07:00:48.053164Z 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2022-02-10T07:00:48.057666Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220210 7:00:48
2022-02-10T07:00:48.060428Z 0 [Note] Event Scheduler: Loaded 0 events
2022-02-10T07:00:48.060602Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.37-0ubuntu0.18.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
编辑
另外,我使用了一些自定义参数(/etc/mysql/mysql.conf.d/mysqld.cnf
):
innodb_buffer_pool_size = 1G
innodb_undo_tablespaces = 3
innodb_undo_directory = /var/lib/mysql/undo
innodb_undo_log_truncate = ON
innodb_max_undo_log_size = 16M
innodb_undo_logs = 1
编辑2
昨晚我重新启动了三台机器中的一台上的 MySQL 服务器,看看今天早上它是否不会像前几天那样崩溃(因为它们似乎在启动后约 24 小时就停止了)。
不幸的是,MySQL 大约在同一时间再次停止了。
关机前几分钟,我检查了机器的可用 RAM,大约有 1 GB 可用。通常可用的是 RAM。PM2 几乎不消耗任何内存。
我还在三台机器中的另一台上完全重新安装了 MySQL(配置相同)。到目前为止,这台机器上没有崩溃。
编辑3
感谢 Gerrit 的最后一条评论,我发现了一些有趣的东西/var/log/dpkg.log
:
2022-02-11 06:08:17 startup packages remove
2022-02-11 06:08:17 status installed linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1
2022-02-11 06:08:17 remove linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1 <none>
2022-02-11 06:08:17 status half-configured linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1
2022-02-11 06:08:17 status half-installed linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1
2022-02-11 06:08:17 status config-files linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1
2022-02-11 06:08:17 status config-files linux-modules-5.4.0-1063-aws:amd64 5.4.0-1063.66~18.04.1
2022-02-11 06:08:17 startup packages configure
2022-02-11 06:08:17 configure mysql-server-5.7:amd64 5.7.37-0ubuntu0.18.04.1 <none>
2022-02-11 06:08:17 status half-configured mysql-server-5.7:amd64 5.7.37-0ubuntu0.18.04.1
这与 MySQL 服务器停止同时发生。
我该如何禁用这个“配置mysql-server-5.7”脚本或手动完成它来解决这个问题?
答案1
当 Ubuntu 服务器上的服务意外关闭时,可能的原因是无人值守升级,它在凌晨某个时间运行。此系统的活动可以在/var/log/unattended-upgrades/
文件和中看到/var/log/dkpg.log
。
如果此类升级陷入困境,它将在下一轮无人值守升级或任何适当升级操作中再次尝试。
升级时运行 mysql 本身并无害,因为升级脚本将停止服务并单独运行。但是,您为 mysql 所做的本地服务设置仍会对升级运行产生影响。
您可以使用以下方式检查包裹状态dpkg -l mysql-server-5.7
在这种情况下,mysql 启动消息表明 innodb 表字典的内部状态与磁盘上看到的情况不同。类似这样的消息Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. mysqld: Table 'mysql.plugin' doesn't exist
表明mysql
系统数据库受到了影响。这通常仅在 mysql 升级时才会发生变化。
启动时还有一条消息:1 redo rollback segment(s) found
这不正常,回滚段的默认设置是 96。可以使用innodb_rollback_segments
或其别名innodb_undo_logs
进行设置。此参数在较新版本的 mysql 中已完全消失。回滚段的目的是存储 innodb 引擎上的 sql 事务中更新和插入所更改的数据,并提供事务的 ACIDness。对于临时表,有单独的 32 个回滚段(不带重做)。每个更新事务和每个插入事务都需要一个单独的回滚段。因此,即使一个事务也可能需要 2 个回滚段。现在,如果您只有一个回滚段,则事务永远无法完成。这种情况可能会在一段时间内被忽视,因为许多简单代码从不使用事务(隐式事务除外),并且通常一个语句不会同时更新和插入。但迟早您会遇到这样的阻塞情况,升级脚本会卡住。此外,您的撤消表空间将无限增长,因为没有保留回滚段,截断将永远不会运行。
删除回滚段的自定义设置并重新安装服务apt install -reinstall mysql-server-5.7
或尝试使用手动运行配置脚本dpkg --configure mysql-server-5.7
。