MY.CNF

#
[client]
port    = 3306
socket    = /var/lib/mysql/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 = 3306
#basedir    = /usr/local/mysql
#datadir    = /mysqldata/mysqldata3306
datadir=/var/lib/mysql
socket    = /var/lib/mysql/mysql.sock
pid_file = /var/run/mysqld/mysqld.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
table_open_cache=12000
innodb_open_files=65535
back_log = 1024
max_connections = 1000
max_connect_errors = 1000000
table_open_cache = 20000
table_definition_cache = 20000
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 = 1500
interactive_timeout = 200
wait_timeout = 200
tmp_table_size = 96M
max_heap_table_size = 96M
explicit_defaults_for_timestamp=true
sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#log settings
log_timestamps = SYSTEM
log_error = /var/lib/mysql/error.log
log_error_verbosity = 3
slow_query_log = 1
#log_slow_extra = 1
#slow_query_log_file = /mysqldata/mysqldata3306/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_bin = /mysqldata/mysqldata3306/mybinlog
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
#binlog_expire_logs_seconds = 604800
#MySQL 8.0.22前,想启用MGR的话,需要设置binlog_checksum=NONE才行
#binlog_checksum = CRC32
#gtid_mode = ON
#enforce_gtid_consistency = TRUE
#log-bin=master-bin            # 二进制日志文件名
#binlog_format=row            # 其他格式可能造成数据不一致
log-slave-updates=ON            # 是否记录从服务器同步数据动作
gtid_mode=ON                # 开启GTID功能
enforce-gtid-consistency=ON        # 开启强制GTID一致性
master-info-repository=TABLE        # 记录IO线程读取已经读取到的master binlog位置,用于slave宕机后IO线程根据文件中的POS点重新拉取binlog
relay-log-info-repository=TABLE        # 记录SQL线程读取Master binlog的位置,用于Slave 宕机后根据文件中记录的pos点恢复sql线程
sync-master-info=1            # 启用确保无信息丢失;任何一个事务提交后, 将二进制日志的文件名及事件位置记录到文件中
slave-parallel-workers=2        # 设置从服务器的复制线程数,0表示关闭多线程复制功能
binlog-checksum=CRC32            # 设置binlog校验算法
master-verify-checksum=1        # 设置主服务器是否校验
slave-sql-verify-checksum=1        # 设置从服务器是否校验
binlog-rows-query-log_events=1        # 用于在二进制日志记录事件相关的信息,可降低故障排除的复杂度
sync_binlog=1                # 保证master crash safe,该参数必须设置为1
innodb_flush_log_at_trx_commit=1    # 保证master crash safe,该参数必须设置为1

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

#replication settings
relay_log_recovery = 1
#slave_parallel_type = LOGICAL_CLOCK
slave_parallel_workers = 64           #可以设置为逻辑CPU数量的2倍
#binlog_transaction_dependency_tracking = WRITESET
#slave_preserve_commit_order = 1
#slave_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 = 40G
innodb_buffer_pool_instances = 4
innodb_data_file_path = ibdata1:12M:autoextend
innodb_file_per_table = 1
#innodb_flush_log_at_trx_commit = 1 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能
innodb_log_buffer_size = 32M
innodb_log_file_size = 1G #如果线上环境的TPS较高,建议加大至1G以上,如果压力不大可以调小
innodb_log_files_in_group = 3
#loose-innodb_redo_log_capacity = 3G
innodb_max_undo_log_size = 4G
# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_open_files = 65535
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
#innodb_print_ddl_logs = 1
innodb_status_file = 1
#注意: 开启 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
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值