MYSQL 8.0.33 8 核 64G my.cnf 配置

2023-11-13 11:34:43 +08:00
 Aluhao
自建 MYSQL, 1 主 3 从,前环境使用的 my.cnf 配置文件,准备把它迁移到 AWS 去,
innodb_io_capacity 是根据当前系统购买配置时给的参数;
innodb_buffer_pool_size 是内存的 75%;
innodb_redo_log_capacity 64G 内存建议 4G
其它有些参数调整不知道是不是合理。

[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
server_id = 100
#bind_address = 127.0.0.1
basedir = /usr/local
datadir = /var/db/mysql
tmpdir = /var/db/mysql_tmpdir
log_error = /var/db/mysql/error.log
replica_load_tmpdir = /var/db/mysql_tmpdir
secure_file_priv = /var/db/mysql_secure
authentication_policy = caching_sha2_password
explicit_defaults_for_timestamp = ON
max_connections = 2000
max_connect_errors = 3000
max_allowed_packet = 512M
gtid_mode = ON
enforce_gtid_consistency = ON
innodb_file_per_table = ON
#innodb_dedicated_server = ON
innodb_sort_buffer_size = 64M
innodb_buffer_pool_size = 48G
innodb_redo_log_capacity = 4G
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_log_buffer_size = 64M
innodb_data_home_dir = /var/db/mysql
innodb_log_group_home_dir = /var/db/mysql
innodb_data_file_path = ibdata1:128M:autoextend
innodb_temp_data_file_path = ibtmp1:128M:autoextend
innodb_flush_method = O_DIRECT
innodb_io_capacity = 3000
innodb_io_capacity_max = 6000
innodb_adaptive_hash_index = OFF
sync_binlog = 1
sync_relay_log = 1
tmp_table_size = 32M
max_heap_table_size = 32M
thread_stack = 512K
thread_cache_size = 30
key_buffer_size = 256M
read_buffer_size = 8M
sort_buffer_size = 4M
join_buffer_size = 4M
read_rnd_buffer_size = 4M
binlog_cache_size = 16M
binlog_expire_logs_auto_purge = OFF
binlog_expire_logs_seconds = 3280000000
log_replica_updates = ON
log_bin = master
relay_log = relay
#relay_log_purge = ON
#relay_log_recovery = ON
skip_name_resolve = ON
net_buffer_length = 32k
net_retry_count = 16380
#read_only = ON
#super_read_only = ON
#performance_schema = OFF
event_scheduler = OFF
mysqlx = OFF
mysqlx_port = 33060
mysqlx_socket = /tmp/mysqlx.sock
mysqlx_bind_address = 127.0.0.1,::1
[mysqldump]
max_allowed_packet = 1G
quote_names
quick
2235 次点击
所在节点    MySQL
11 条回复
atonganan
2023-11-13 13:55:22 +08:00
max_allowed_packet = 512M
不够用把 。
ab
2023-11-13 14:13:11 +08:00
搭车问一下,如有重复项,是前置的优先,还是前置的?
atonganan
2023-11-13 14:23:05 +08:00
@ab 同一区域的重复项,最后一个生效
ab
2023-11-13 14:30:12 +08:00
@atonganan 谢谢
Aluhao
2023-11-13 16:16:31 +08:00
@atonganan
max_allowed_packet = 512M
设置过大会不会引发什么问题,我看文档有建议设置成 1G
SunsetYe
2023-11-14 16:51:14 +08:00
迁移到 AWS 的话可以考虑直接用 RDS ?
Aluhao
2023-11-14 20:26:58 +08:00
@SunsetYe RDS 太贵了
MoMMM
2023-11-15 11:20:26 +08:00
请教下新的配置中,注释掉诸如 join_buffer_size 等一系列相关的 buffer_size 的考虑是什么?
Aluhao
2023-11-16 10:10:47 +08:00
@MoMMM 缓冲区设置较大可能会触发将这些缓冲区分页到磁盘,会极大地减慢数据库的速度并造成瓶颈。
Aluhao
2023-11-16 10:12:07 +08:00
@MoMMM MySQL 的文档警告说:较大的值可能会显着减慢内存分配速度。
E1n
2023-12-22 21:31:22 +08:00
max_allowed_packet = 512M 合理吗默认数值是 1G 吧,Mysql InnoDB Cluster 方案要求为 2G ,现在生产是 2G:)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/991402

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX