MySQL 8 InnoDB 启动时间较长

MySQL 8 InnoDB 启动时间较长

几个月前我从 Ubuntu 18.04 升级到了 20.04。因此 MySQL 从 5.7.33 升级到了 8.0.23。

我注意到升级后 MySQL 启动很慢。

2021-02-24T09:20:16.972632Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.23-0ubuntu0.20.04.1).
2021-02-24T09:23:19.459483Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23-0ubuntu0.20.04.1)  (Ubuntu).
2021-02-24T09:28:43.738171Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23-0ubuntu0.20.04.1) starting as process 999
2021-02-24T09:28:44.973719Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-24T09:33:02.352311Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-24T09:33:06.424798Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-02-24T09:33:07.646778Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-24T09:33:07.647106Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-24T09:33:08.295842Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23-0ubuntu0.20.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

速度减慢似乎源于“InnoDB初始化”。

MySQL 包含 70 个数据库(Wordpress),用于开发项目,但并未积极使用。

我也注意到其他 3 台服务器也出现了这种速度减慢的情况。(但没有那么严重,而且包含的数据库也较少。)

由于这种速度减慢,网站在 Innodb 初始化期间显示“数据库连接”错误。

究竟是什么原因导致这种速度减慢?是否有任何参数可以加快此过程?

编辑:实际配置

#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql



# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
tmpdir      = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size     = 16M
# max_allowed_packet    = 64M
# thread_stack      = 256K

# thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP

# max_connections        = 151

# table_open_cache       = 4000

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file        = /var/log/mysql/query.log
# general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
# slow_query_log        = 1
# slow_query_log_file   = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id     = 1
# log_bin           = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
max_binlog_size   = 100M
# binlog_do_db      = include_database_name
# binlog_ignore_db  = include_database_name

skip-name-resolve
table_open_cache = 4000
join_buffer_size = 8M
tmp_table_size = 64M
key_buffer_size = 48M
max_heap_table_size = 64M
innodb_buffer_pool_size = 1500M
innodb_buffer_pool_instances = 1
innodb_log_file_size = 190M

相关内容