首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >数据库性能下降,升级到MySQL 8.0.20之后

数据库性能下降,升级到MySQL 8.0.20之后
EN

Stack Overflow用户
提问于 2020-06-19 11:28:18
回答 2查看 5.5K关注 0票数 4

在将MySQL从5.7版升级到8.0版后,我发现数据库性能明显下降。

在升级MySQL之前,CPU使用率稳定在30%+-左右,但升级后CPU使用率变得不稳定,经常出现大尖峰。

最近我测试了一些非常有趣的东西,我会继续运行一个相同的查询几次,并发现持续时间变得越来越长。如下图所示。

我读过很多文章和堆栈溢出帖子,但是没有一个解决方案是真正得到帮助的。因此,希望有人能与我分享一些关于调优MySQL8.0的想法或经验。

会非常感激的。

如果需要进一步调查,请告诉我。

配置my.ini:-

代码语言:javascript
运行
复制
key_buffer_size = 2G
max_allowed_packet = 1M

;Added to reduce memory used (minimum is 400)
table_definition_cache = 600

sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 2M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 2G
;Path to mysql install directory
basedir="c:/wamp64/bin/mysql/mysql8.0.20"
log-error="c:/wamp64/logs/mysql.log"
;Verbosity Value  1 Errors only, 2  Errors and warnings , 3 Errors, warnings, and notes
log_error_verbosity=2
;Path to data directory
datadir="c:/wamp64/bin/mysql/mysql8.0.20/data"


;slow_query_log = ON
;slow_query_log_file = "c:/wamp64/logs/slow_query.log"

;Path to the language
;See Documentation:
; http://dev.mysql.com/doc/refman/5.7/en/error-message-language.html
lc-messages-dir="c:/wamp64/bin/mysql/mysql8.0.20/share"
lc-messages=en_US

; The default storage engine that will be used when create new tables
default-storage-engine=InnoDB
; New for MySQL 5.6 default_tmp_storage_engine if skip-innodb enable
; default_tmp_storage_engine=MYISAM

;To avoid warning messages
secure_file_priv="c:/wamp64/tmp"
skip-ssl

explicit_defaults_for_timestamp=true

; Set the SQL mode to strict
sql-mode=""
;sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER"

;skip-networking

; Disable Federated by default
skip-federated

; Replication Master Server (default)
; binary logging is required for replication
;log-bin=mysql-bin

; binary logging format - mixed recommended
;binlog_format=mixed

; required unique id between 1 and 2^32 - 1
; defaults to 1 if master-host is not set
; but will not function as a master if omitted
server-id = 1

; Replication Slave (comment out master section to use this)

; New for MySQL 5.6 if no slave
skip-slave-start


; The InnoDB tablespace encryption feature relies on the keyring_file
; plugin for encryption key management, and the keyring_file plugin
; must be loaded prior to storage engine initialization to facilitate
; InnoDB recovery for encrypted tables. If you do not want to load the
; keyring_file plugin at server startup, specify an empty string.
early-plugin-load=""

;innodb_data_home_dir = C:/mysql/data/
innodb_data_file_path = ibdata1:12M:autoextend
;innodb_log_group_home_dir = C:/mysql/data/
;innodb_log_arch_dir = C:/mysql/data/

; You can set .._buffer_pool_size up to 50 - 80 %
; of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 4G

; Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 16M
innodb_log_buffer_size = 8M
innodb_thread_concurrency = 64
innodb_flush_log_at_trx_commit = 2

log_bin_trust_function_creators = 1;

innodb_lock_wait_timeout = 120
innodb_flush_method=normal
innodb_use_native_aio = true

innodb_flush_neighbors = 2
innodb_autoinc_lock_mode = 1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
; Remove the next comment character if you are not familiar with SQL
;safe-updates

[isamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M

[myisamchk]
key_buffer_size = 256M ;20M hys
sort_buffer_size_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld]
port = 3306
skip-log-bin
default_authentication_plugin= mysql_native_password

max_connections = 400
max_connect_errors = 100000

innodb_read_io_threads = 32
innodb_write_io_threads = 8
innodb_thread_concurrency = 64

硬件:- Ram: 16 Ghz :4核3.0 Ghz

显示全局状态:https://pastebin.com/FVZrgnTw

显示引擎INNODB状态:https://pastebin.com/Rewp84Gi

显示全局变量:https://pastebin.com/3v6cM6KZ

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-07-27 13:14:15

每秒速率= RPS

关于考虑my.ini mysqld部分的建议--在my.ini配置中有超过1个mysqld部分是很少见的--您在您的末尾附近的部分可以移动到mysqldump之前,以避免混淆。

代码语言:javascript
运行
复制
innodb_lru_scan_depth=100  # from 1024 to conserve 90% of CPU cycles used for function
key_buffer_size=16M  # from 1G to conserve RAM - you are not using MyISAM data tables
read_rnd_buffer_size=64K  # from 2M to reduce handler_read_rnd_next RPS of 1,872,921
innodb_io_capacity=900  # from 200 to more of your rotating drive IOPS capacity

您应该发现,随着这些更改,查询完成时间和CPU繁忙时间都会减少。

select_scan平均41 RPS,是由不可用的索引造成的,导致延迟。

其他建议,查看配置文件,网络配置文件联系方式,常见问题,额外的提示和免费下载实用程序脚本,以协助性能调优。

票数 2
EN

Stack Overflow用户

发布于 2020-07-28 12:48:21

我已经找出了根本原因,并将其发布在https://dba.stackexchange.com/questions/271785/query-performance-become-slower-after-upgrade-to-mysql-8-0-20中。

非常感谢你的回答和建议。非常感谢。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62469293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档