gavin.zheng 发表于 2024-4-23 09:18:11

MySQL内存持续上升,没有释放

MySQL版本:Ver 8.0.35 for Linux on x86_64 (MySQL Community Server - GPL)

OS:Ubuntu 22.04.4 LTS
CPU:8H
Memory:16G

my.cnf

socket = /data/mysql/mysql.sock


prompt = "\u@mysqldb \R:\m:\s [\d]> "
no-auto-rehash


single-transaction


malloc-lib = /usr/lib/x86_64-linux-gnu/libjemalloc.so.2


#basic settings#
server-id = 100
port = 3306
user = mysql
autocommit = 1
socket = /data/mysql/mysql.sock
character_set_server=utf8mb4
datadir=/data/mysql/
basedir=/usr/local/mysql/
explicit_defaults_for_timestamp = 1
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
transaction_isolation = READ-COMMITTED
max_allowed_packet = 64M
event_scheduler = 1
#connection#
interactive_timeout = 1800
wait_timeout = 1800
lock_wait_timeout = 1800
skip_name_resolve = 1
max_connections = 1024
max_user_connections = 256
max_connect_errors = 1000000
#table cache performance settings#
table_open_cache = 4096
table_definition_cache = 4096
table_open_cache_instances = 64
#session memory settings#
read_buffer_size = 2M
read_rnd_buffer_size = 2M
sort_buffer_size = 2M
tmp_table_size = 2M
join_buffer_size = 2M
thread_cache_size = 64
#log settings#
log_error = error.log
log_bin = binlog
log_error_verbosity = 2
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_replica_statements = 1
log_throttle_queries_not_using_indexes = 10
binlog_expire_logs_seconds = 864000
long_query_time = 2
min_examined_row_limit = 100
log-bin-trust-function-creators = 1
binlog_cache_size= 2M
########innodb settings########
innodb_page_size = 16k
innodb_buffer_pool_size = 9G
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 4096
innodb_lock_wait_timeout = 5
innodb_io_capacity = 20000
innodb_io_capacity_max = 24000
innodb_flush_method = O_DIRECT
innodb_flush_neighbors = 0
innodb_redo_log_capacity = 4G
innodb_log_buffer_size = 64M
innodb_purge_threads = 4
innodb_thread_concurrency = 0
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 64M
innodb_write_io_threads = 8
innodb_read_io_threads = 4
innodb_file_per_table = 1
innodb_stats_persistent_sample_pages = 64
innodb_autoinc_lock_mode = 2
innodb_online_alter_log_max_size=100M
innodb_open_files=4096
innodb_flush_log_at_trx_commit = 1
#replication settings#
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
binlog_format = ROW
binlog_rows_query_log_events = 1
relay_log = relay.log
relay_log_recovery = 1
log_replica_updates = 1
replica_skip_errors = ddl_exist_errors
replica_parallel_workers = 8
replica_preserve_commit_order = 1
replica_transaction_retries = 128
binlog_gtid_simple_recovery = 1
log_timestamps = system
#mgr settings
loose-plugin_load_add = 'mysql_clone.so'
loose-plugin_load_add = 'group_replication.so'
loose-group_replication_group_name = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1"
loose-group_replication_local_address = "10.20.12.106:33061"
loose-group_replication_group_seeds = '10.20.12.106:33061,10.20.12.107:33061,10.20.12.108:33061'
loose-group_replication_start_on_boot = OFF
loose-group_replication_bootstrap_group = OFF
loose-group_replication_exit_state_action = READ_ONLY
loose-group_replication_flow_control_mode = "DISABLED"
loose-group_replication_single_primary_mode = ON
loose-group_replication_communication_max_message_size = 10M
loose-group_replication_transaction_size_limit = 1G
loose-group_replication_arbitrator = 0
loose-group_replication_single_primary_fast_mode = 1
loose-group_replication_request_time_threshold = 20000
loose-group_replication_recovery_get_public_key = 1
report-host = "10.20.12.106"
#perforamnce_schema settings#
performance-schema-instrument='memory/%=COUNTED'
performance_schema_digests_size = 40000
performance_schema_max_table_handles = 40000
performance_schema_max_table_instances = 40000
performance_schema_max_sql_text_length = 4096
performance_schema_max_digest_length = 4096
loose_innodb_numa_interleave = 1
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 8
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 4G
innodb_purge_rseg_truncate_frequency = 128

#innodb monitor settings
innodb_monitor_enable = "module_innodb"
innodb_monitor_enable = "module_server"
innodb_monitor_enable = "module_dml"
innodb_monitor_enable = "module_ddl"
innodb_monitor_enable = "module_trx"
innodb_monitor_enable = "module_os"
innodb_monitor_enable = "module_purge"
innodb_monitor_enable = "module_log"
innodb_monitor_enable = "module_lock"
innodb_monitor_enable = "module_buffer"
innodb_monitor_enable = "module_index"
innodb_monitor_enable = "module_ibuf_system"
innodb_monitor_enable = "module_buffer_page"
innodb_monitor_enable = "module_adaptive_hash"


参考叶老师的深入浅出MGR搭建的MGR集群。目前master节点内存使用率大约89%,从启动数据库就一直处于上升趋势。有一些慢查询,但是慢查询应该不会导致内存一直上升,请帮忙看看,谢谢。

yejr 发表于 2024-4-23 11:05:22

有几篇参考可以先看下
- https://greatsql.cn/blog-10-1218.html
- https://greatsql.cn/thread-560-1-1.html
- https://greatsql.cn/thread-447-1-1.html
- https://greatsql.cn/thread-167-1-1.html
页: [1]
查看完整版本: MySQL内存持续上升,没有释放