MySQL的配置文件my.cnf详解

[client]
port = 6306 #客户连接端口
socket = /data/mysql.sock #套接字文件
#default-character-set = utf8
[mysql]
#tee=/data/mysql/query.log
prompt = “[\u@\h][\d]>_” #可以自定义提示信息
connect_timeout = 5 #连接超时设置
no-auto-rehash #自动补全
#default-character-set = utf8
[mysqld]
user=mysql #默认启动用户mysql
port = 6306 #服务端口
socket = /data/mysql.sock #套接字文件
character-set-server = utf8mb4 #字符集
basedir = /usr/local/mysql-5.7 #安装目录
datadir = /data/mydata #数据目录
open_files_limit = 65535 #最大打开文件限制
back_log = 1024 #暂停请求时间内多少记录栈内
max_connections = 2000 #最大连接数
max_connect_errors = 100000 ##最大错误连接数
external-locking = FALSE # 跳过外部锁定
max_allowed_packet = 128M #最大插入和更新的大小
explicit_defaults_for_timestamp=1 #timestamp自动更新
default_authentication_plugin=mysql_native_password # 默认使用“mysql_native_password”插件认证
skip_name_resolve = 1 #禁止域名解析

log_timestamps=system #日志时间是系统时间
character-set-client-handshake = FALSE #客户端带入的其他字符集无效
character-set-server = utf8mb4 #服务字符集
collation-server = utf8mb4 #排列字符集
#_unicode_ciinit_connect=‘SET NAMES utf8mb4’
#default-character-set = utf8mb4
character-set-client-handshake = FALSE #禁止客户端带入的其他字符集
init_connect= ‘SET NAMES utf8mb4’ #初始字符集
secure_file_priv=/data #select * into 导出文件目录
table_open_cache = 2048
table_definition_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#slave-skip-errors=1032,1053,1062 #跳过复制错误代码
binlog_format = row #binlog格式
server-id = 5463245 #服务ID
log-bin = /data/my_7301/logs/mysql-bin #binlog目录
log-bin-index =/data/my_7301/logs/mysql-bin.index #binlog索引文件
binlog_cache_size = 4M #binlog缓冲大小
max_binlog_size = 1G #binlog最大
max_binlog_cache_size = 2G #binlog缓冲最大
#sync_binlog = 1
expire_logs_days = 2 #日志过期时间
#replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
#replicate-wild-ignore-table=iot_view_test_uat.%
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1062
slow_query_log = 1
slow_query_log_file = /data/my_7301/logs/slow.log
log-error = /data/my_7301/logs/error.log
long_query_time = 0.5

#timeout
interactive_timeout = 300
wait_timeout = 300
#innodb引擎相关
innodb_buffer_pool_size = 1G
innodb_buffer_pool_instances = 2
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout = 1
innodb_status_file = 1
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
innodb_lock_wait_timeout = 10
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 1G
internal_tmp_disk_storage_engine = InnoDB
innodb_stats_on_metadata = 0
innodb_status_file = 1
innodb_status_output_locks = 0
performance_schema = 1
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”

transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay-log-info-repository = TABLE
binlog_checksum = NONE
log_slave_updates = ON
binlog_row_image=FULL
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30

innodb_buffer_pool_load_at_startup =1
innodb_buffer_pool_dump_at_shutdown = 1

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
#server-1
#auto-increment-offset = 1
#auto-increment-increment = 2

#server-2
auto-increment-offset = 2
auto-increment-increment = 2
plugin_dir = /usr/local/mysql-5.7/lib/plugin
#plugin_load = “validate_password.so;rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so”
plugin_load = “rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so” #

loose_rpl_semi_sync_master_enabled = on
loose_rpl_semi_sync_master_timeout = 5000
loose_rpl_semi_sync_master_trace_level = 32
loose_rpl_semi_sync_master_wait_no_slave = on
loose_rpl_semi_sync_slave_enabled = on
loose_rpl_semi_sync_slave_trace_level = 32
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_slave_enabled = 1
loose_rpl_semi_sync_master_timeout = 5000
loose_rpl_semi_sync_master_wait_for_slave_count=1
loose_rpl_semi_sync_master_wait_point=AFTER_SYNC

#slave_preserve_commit_order = 1
slave_transaction_retries = 128
#log_timestamps = system
#show_compatibility_56 = on
slave_parallel_workers = 16
slave_parallel_type = LOGICAL_CLOCK

loose_innodb_numa_interleave = 1
#innodb_buffer_pool_dump_pct = 40
#innodb_page_cleaners = 16
#innodb_undo_log_truncate = 1
#innodb_max_undo_log_size = 2G
#innodb_purge_rseg_truncate_frequency = 128
#transaction_write_set_extraction = MURMUR32

transaction_isolation = READ-COMMITTED
#sql_mode = “STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER”
#sql_mode = “STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,ONLY_FULL_GROUP_BY”
sql_mode = “STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER”

[mysqldump]
quick
max_allowed_packet = 128M

[mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/jmalloc.so
nice=-19
sync_binlog=20
innodb_flush_log_at_trx_commit=2
open-files-limit=65535

猜你喜欢

转载自blog.csdn.net/weixin_41667152/article/details/109646616