写在最前面: my.cnf配置文件通过 https://imysql.com/my-cnf-wizard.html 地址生成 具体配置文件内容下:

## my.cnf for 8.4.3版本
## 注意:个别建议可能需要根据实际情况作调整,请自行判断或联系我,本人不对这些建议结果负相应责任
## 本配置文件主要适用于MySQL 8.4.3版本
#
[client]
port	= 3306
socket	= /data/mysql8.4/mysql.sock

[mysql]
prompt = "\u@mysqldb \R:\m:\s [\d]> "
no_auto_rehash
loose-skip-binary-as-hex

[mysqld]
user	= mysql
port	= 3306
#主从复制或MGR集群中,server_id记得要不同
#另外,实例启动时会生成 auto.cnf,里面的 server_uuid 值也要不同
#server_uuid的值还可以自己手动指定,只要符合uuid的格式标准就可以
server_id = 93306
basedir	= /usr/local/mysql
datadir	= /data/mysql8.4/data
socket	= /data/mysql8.4/mysql.sock
pid_file = /data/mysql8.4/mysqldb.pid
character_set_server = UTF8MB4
skip_name_resolve = 1
#若你的MySQL数据库主要运行在境外,请务必根据实际情况调整本参数
default_time_zone = "+8:00"
#启用admin_port,连接数爆满等紧急情况下给管理员留个备用端口
admin_address = '127.0.0.1'
admin_port = 33062

#performance setttings
lock_wait_timeout = 3600
open_files_limit    = 65535
back_log = 1024
max_connections = 3000
max_connect_errors = 1000000
table_open_cache = 6000
table_definition_cache = 6000
thread_stack = 512K
sort_buffer_size = 16M
join_buffer_size = 16M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
thread_cache_size = 4500
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 96M
max_heap_table_size = 96M

###log settings
log_timestamps = SYSTEM
log_error = /data/mysql8.4/logs/error.log
log_error_verbosity = 3
slow_query_log = 1
log_slow_extra = 1
slow_query_log_file = /data/mysql8.4/logs/slow.log
long_query_time = 0.1
log_queries_not_using_indexes = 1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
#log_slow_slave_statements = 1 ##此参数被下面的log_slow_replica_statements参数替代
log_slow_replica_statements=1
log_bin = /data/mysql8.4/binlog/mysql-bin
binlog_format = ROW
sync_binlog = 1 ##MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
binlog_rows_query_log_events = 1

#expire_logs_days=7  #参数在MySQL 8.0中已经废弃移除,被参数binlog_expire_logs_seconds替代,单位为秒,默认是30天, 可以设置为604800秒,代表7天
binlog_expire_logs_seconds = 604800

#MySQL 8.0.22前,想启用MGR的话,需要设置binlog_checksum=NONE才行
binlog_checksum = CRC32

###开启Gtid设置
gtid_mode = ON
enforce_gtid_consistency = TRUE
replicate_wild_ignore_table=mysql.%
#log_slave_updates 此参数被下面的参数log_replica_updates 替代
log_replica_updates 
#slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'  参数已经在MySQL8.0.18中弃用

###myisam settings
key_buffer_size = 32M
myisam_sort_buffer_size = 128M

###replication settings
#master_info_repository = TABLE    在MySQL8.3.0被移除
#relay_log_info_repository = TABLE   在MySQL8.3.0被移除

relay_log_recovery = 1

#slave_parallel_type = LOGICAL_CLOCK #此参数被下面的replica_parallel_type参数替代
replica_parallel_type = LOGICAL_CLOCK
#slave_parallel_workers = 64  ##此参数被下面的replica_parallel_workers参数替代
replica_parallel_workers = 64 
#binlog_transaction_dependency_tracking = WRITESET 
#slave_preserve_commit_order = 1 ##此参数被下面的replica_preserve_commit_order 参数替代
replica_preserve_commit_order = 1
#slave_checkpoint_period = 2  ##此参数被下面的replica_checkpoint_period 参数替代
replica_checkpoint_period = 2
replication_optimize_for_static_plugin_config = ON
replication_sender_observe_commit_only = ON

#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"
#MGR本地节点IP:PORT,请自行替换
loose-group_replication_local_address = "172.16.16.10:33061"
#MGR集群所有节点IP:PORT,请自行替换
loose-group_replication_group_seeds = "172.16.16.10:33061,172.16.16.11:33061,172.16.16.12: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_unreachable_majority_timeout = 30
loose-group_replication_member_expel_timeout = 5
loose-group_replication_autorejoin_tries = 288

#innodb settings
transaction_isolation = REPEATABLE-READ
innodb_buffer_pool_size = 1024M
innodb_buffer_pool_instances = 4
innodb_data_file_path = ibdata1:12M:autoextend
innodb_flush_log_at_trx_commit = 1 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能
#innodb_log_file_size = 1G 参数被弃用,使用innodb_redo_log_capacity参数替代
##innodb_log_files_in_group = 3 ##参数被弃用,使用innodb_redo_log_capacity参数替代
innodb_redo_log_capacity= 3g
innodb_log_buffer_size = 32M #mysql8.4默认值为64M,mysql8.0默认值为16M,官方建议最小也得设置为16M
innodb_max_undo_log_size = 4G
innodb_undo_directory = /data/mysql8.4/undolog
#innodb_undo_tablespaces = 95 参数已经弃用,默认总是创建2个undo文件,需要更多的undo文件,需要手动创建: CREATE UNDO TABLESPACE

# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000 #mysql8.4中默认1000;mysql8.0中默认200
innodb_io_capacity_max = 8000 #MySQL8.4中默认值2*innodb_io_capacity;mysql8.0中默认值2*innodb_io_capacity,最小默认值为2000
innodb_flush_sync = 0  #这个参数默认是开启的,但是开启innodb_io_capacity和innodb_io_capacity_max时,参数innodb_flush_sync就要禁用。
innodb_flush_neighbors = 0
innodb_write_io_threads = 8 #mysql8.4默认值是4;mysql8.0默认值是4  最大值为64
innodb_read_io_threads = 8  #CPU逻辑核数/8,默认最低为 4,最小默认值为4,最大值为64;mysql8.0默认值为4
innodb_parallel_read_threads = 8 #mysql8.4 CPU逻辑核数/8,默认最低为 4,mysql8.0默认值为4
innodb_purge_threads = 4  #mysql8.4默认值:CPU逻辑核数 <=16 时为 1,否则为 4;#mysql8.0默认值为4
innodb_page_cleaners = 4  #mysql8.4默认值和innodb_buffer_pool_instances值一样;#mysql8.0默认值为4
innodb_doublewrite_files =2 #mysql8.4默认值为2;mysql8.0默认值为innodb_buffer_pool_instances*2
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50 ##默认值为90
innodb_flush_method = O_DIRECT #mysql8.4中系统支持时为 O_DIRECT,否则 fsync;#mysql8.0默认为fsync
innodb_lru_scan_depth = 4000 ##默认值为1024,最小值为100
innodb_checksum_algorithm = crc32
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
innodb_stats_on_metadata = 0
innodb_undo_log_truncate = 1
innodb_print_ddl_logs = 1
innodb_status_file = 1
innodb_use_fdatasync = 1 #mysql8.4默认时开启,mysql8.0默认是关闭

#注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快
innodb_status_output = 0
innodb_status_output_locks = 1
innodb_sort_buffer_size = 67108864
innodb_adaptive_hash_index = OFF
#提高索引统计信息精确度
innodb_stats_persistent_sample_pages = 500
innodb_adaptive_hash_index = 0
loose-sql_generate_invisible_primary_key = ON

#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"

#pfs settings
performance_schema = 1
#performance_schema_instrument = '%memory%=on'
loose-performance_schema_instrument = '%lock%=on'

[mysqldump]
quick

相关参数说明来自MySQL8.4官方手册: https://downloads.mysql.com/docs/refman-8.4-en.pdf#%5B%7B%22num%22%3A46751%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C36%2C720%2Cnull%5D 以及参考文章:https://blog.csdn.net/n88Lpo/article/details/141877197