注意:根据自己环境进行参数的调整。
[client]
port = 3307
socket = /data/mysql8.0.35/3307/tmp/mysql.sock
[mysqldump]
quick
max_allowed_packet = 64M
[mysql]
prompt="\u@\h: \R:\m:\s [\d]> "
no-auto-rehash
[mysqld]
###### BASIC SETTINGS ######
server-id = 303307
user = mysql
port = 3307
basedir = /data/mysql8.0.35/install
tmpdir = /data/mysql8.0.35/3307/tmp
datadir = /data/mysql8.0.35/3307/data
pid-file = /data/mysql8.0.35/3307/tmp/mysql.pid
socket = /data/mysql8.0.35/3307/tmp/mysql.sock
character-set-server = utf8mb4
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
max_allowed_packet = 32M
open_files_limit = 65535
sql_mode = NO_ENGINE_SUBSTITUTION
group_concat_max_len = 1024000
lock_wait_timeout = 120
skip_name_resolve = 1
#不区分大小写
lower-case-table-names = 1
default_time_zone = "+8:00" #沿用5.7的密码认证
default_authentication_plugin = mysql_native_password
log_bin_trust_function_creators = 1
###### PASSWORD POLICY AND CONNECT CONTROL ######
plugin_dir=/data/mysql8.0.35/install/lib/plugin
plugin-load-add = validate_password.so
###### CACHES AND CONNECTS SESSION ######
table_definition_cache = 2048
table_open_cache = 10240
table_open_cache_instances = 16
read_buffer_size = 4M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
tmp_table_size = 16M
max_heap_table_size = 64M
thread_cache_size = 128
thread_stack = 512K
key_buffer_size = 4M
max_length_for_sort_data = 8096
bulk_insert_buffer_size = 4M
###### CONNECTION SETTINGS ######
interactive_timeout = 300
wait_timeout = 300
max_connections = 3000
max_user_connections = 0
max_connect_errors = 1000
back_log = 2048
###### LOG SETTINGS ######
log-error = /data/mysql8.0.35/3307/logs/error.log
slow_query_log_file = /data/mysql8.0.35/3307/logs/slow.log
log-bin = /data/mysql8.0.35/3307/binlog/mysql-bin
relay-log = /data/mysql8.0.35/3307/relaylog/mysql-relay-bin
slow_query_log = 1
long_query_time = 1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 1000
log_slow_admin_statements = 1
log_slow_slave_statements = 1
binlog_format = row
binlog_row_image = full
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
# binlog过期时间,8.0已废弃
# expire_logs_days = 7
skip_slave_start = 1
max_relay_log_size = 500M
relay_log_recovery = 1
relay-log-purge = 1
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_timestamps = SYSTEM
binlog_checksum = 1
gtid_mode = on
log_slave_updates = 1
enforce_gtid_consistency = 1
binlog_gtid_simple_recovery = 1
#log security
#sync_binlog = 1
#innodb_flush_log_at_trx_commit = 1
sync_binlog = 1000
innodb_flush_log_at_trx_commit = 2
###### REPLICATION SETTINGS ###### 并行复制
slave_parallel_type = LOGICAL_CLOCK
slave_parallel_workers = 4
slave_preserve_commit_order = on
#binlog-transaction-dependency-tracking = commit_order
#如果在同一台主机部署多个实例,并启动增强半同步,需指定以下参数
mysqlx_socket=/data/mysql/tmp/mysqlx.sock
mysqlx_port = 13308
###### semi sync replication settings ###### 增强半同步复制
#plugin_dir=/data/mysql8.0.35/install/lib/plugin
#plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
#loose_rpl_semi_sync_master_enabled = 1
#loose_rpl_semi_sync_slave_enabled = 1
#loose_rpl_semi_sync_master_timeout = 5000
###### INNODB SETTINGS ######
#企业级部署,可以直接初始化10G
innodb_buffer_pool_size = 7G
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
#innodb_data_file_path = ibdata1:128M;ibdata2:128M:autoextend
innodb_lru_scan_depth = 4096
innodb_lock_wait_timeout = 10
innodb_io_capacity = 10000
innodb_io_capacity_max = 15000
innodb_flush_method = O_DIRECT
#innodb_undo_tablespaces已废弃,innodb默认创建2个undo表空间,如果需要更多,后期使用CREATE UNDO TABLESPACE命令进行添加
#innodb_undo_tablespaces = 127
innodb_max_undo_log_size = 4G
innodb_undo_log_truncate = 1
innodb_flush_neighbors = 0
innodb_log_file_size = 2G
innodb_log_files_in_group = 5
innodb_log_buffer_size = 32M
#在mysql8.0已废弃innodb_large_prefix
#innodb_large_prefix = 1
innodb_thread_concurrency = 0
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_purge_threads = 4
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_page_cleaners = 8
innodb_sort_buffer_size = 32M
innodb_file_per_table = 1
innodb_stats_persistent_sample_pages = 64
innodb_autoinc_lock_mode = 2
innodb_online_alter_log_max_size = 4G
innodb_open_files = 65535
innodb_checksum_algorithm = crc32
innodb_rollback_on_timeout = 1
#内部临时表的存储引擎,在mysql8.0.16中已废弃
#internal_tmp_disk_storage_engine = InnoDB
innodb_status_file = 1
innodb_status_output = 0
innodb_status_output_locks = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
innodb_flush_sync = 0
innodb_max_dirty_pages_pct = 50
innodb_stats_on_metadata = 0
###### some var for MySQL 8 ######
log_error_verbosity = 3
innodb_print_ddl_logs = 1
#binlog过期时间,604800秒 即7天
binlog_expire_logs_seconds = 604800
innodb_dedicated_server = OFF
###### PERFORMANCE_SCHEMA SETTINGS ######
performance_schema = 1
performance_schema_instrument = '%=on'
performance_schema_digests_size = 40000
performance_schema_max_table_instances = 40000
performance_schema_max_sql_text_length = 4096
performance_schema_max_digest_length = 4096
performance-schema-instrument='stage/%=ON'
performance-schema-consumer-events-stages-current=ON
performance-schema-consumer-events-stages-history=ON
performance-schema-consumer-events-stages-history-long=ON
performance-schema-consumer-events-transactions-history-long=ON
###### INNODB MONITOR ###### 监控
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"
###### group replication settings ######
read_only=1
#super_read_only=1
binlog_transaction_dependency_tracking = WRITESET
transaction-write-set-extraction = XXHASH64
binlog_transaction_dependency_history_size = 25000
loose-group_replication_auto_increment_increment = 1
# report_host = 127.0.0.1 # optional for group replication
binlog_checksum = NONE # only for group replication
loose-group_replication_group_name = 'd8316b12-a119-4850-bdb1-37275c5a3f3f' #用于配置组复制的组名
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = 192.168.111.30:13307 #本地组复制成员的 IP 地址和端口号
loose-group_replication_group_seeds = "192.168.111.30:13307,192.168.111.31:13307,192.168.111.32:13307" #组复制集群的种子成员的 IP 地址和端口号
loose_group_replication_ip_whitelist= "192.168.111.0/24" #允许连接到组复制成员的 IP 地址列表,限制允许访问 Group Replication 成员的客户端 IP 地址
loose-group_replication_bootstrap_group = off
#set single primary
loose_group_replication_single_primary_mode = on
loose_group_replication_enforce_update_everywhere_checks = off
# turn off Flow control
loose_group_replication_flow_control_mode = DISABLED
loose_group_replication_unreachable_majority_timeout = 30 #网络不可达时,10秒后被踢出集群,状态变为error
loose_group_replication_transaction_size_limit = 20971520 #允许的事务大小,建议20M,默认不限制
loose_group_replication_autorejoin_tries = 3 #auto-rejoin,重试加入集群,8.0.16以上支持
loose_group_replication_compression_threshold = 131072
loose_group_replication_member_weight = 50 #权重在主库可以设置为60
#compress binlog, ratio: 50% #以下2个参数仅适用于8.0.20及以上版本
binlog_transaction_compression = on
binlog_transaction_compression_level_zstd = 10
###### 参数配置######
#基本参数
#port=
#server_id=
#innodb_buffer_pool_size=
#read_buffer_size=
#read_rnd_buffer_size=
#sort_buffer_size=
#join_buffer_size=
#tmp_table_size=
#mgr配置
#loose_group_replication_group_name=
#loose_group_replication_local_address=
#report_host=
#loose_group_replication_group_seeds=
#loose_group_replication_ip_whitelist=