Mysql参数配置

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld_safe]
log-error=/bak/logs/mysql/mysql-error.log
pid-file=/var/run/mysqld.pid

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
port = 3306
datadir=/opt/data
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

#Performance
wait_timeout = 7200
interactive_timeout = 7200
open_files_limit=65535
back_log=600
max_connections = 2000
max_connect_errors = 6000
max_allowed_packet = 256M
performance_schema = 0

# Query Cache
query_cache_type=0
#query_cache_size=32M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# replication
server_id=20
log-bin=mysql-bin
expire_logs_days=7
log-slave-updates=true # slave更新是否记入日志  slave提升为master时不能有此选项
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
binlog_format=row
binlog_cache_size=2M
max_binlog_size=512M
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
slave_net_timeout=60 # 备库与主库失败重连时间

character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

# slow log
long_query_time=0.05
slow_query_log=1
slow_query_log_file=/bak/logs/mysql/slowquery.log
#将所有没有使用带索引的查询语句全部写到慢查询日志中
#log_queries_not_using_indexes=1
#每分钟允许记录到slow log的且未使用索引的SQL语句次数
log_throttle_queries_not_using_indexes=50

# InnoDB engine
innodb_print_all_deadlocks = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 4G
innodb_flush_method = O_DIRECT
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_log_buffer_size =32M
innodb_read_io_threads=8
innodb_write_io_threads=4
#innodb_io_capacity=200       # default 200
# 0表示不限制进入内核线程数量
innodb_thread_concurrency = 0
# 线程并发 它只在Solaris < 9 的系统中有用 从mysql5.6.1开始,这个选项就被废了  5.7 没这个参数
thread_concurrency = 10
# 0 把日志缓冲写到日志文件,并且每秒刷新一次,但是事务提交时不做任何事   写入最快
# 1 把日志缓冲写到日志文件,并且每次事务提交都刷新到持久化存储.默认     写入慢但安全
# 2 每次提交把日志缓冲刷新到日志文件,但是并不刷新.InnoDB每秒做一次刷新 写入最快
innodb_flush_log_at_trx_commit = 2
innodb_buffer_pool_dump_at_shutdown = ON  # 关闭时dump缓冲池
innodb_buffer_pool_load_at_startup  = ON  # 启动时load缓冲池

# 内存临时表
tmp_table_size = 128M
max_heap_table_size = 128M
# MyISAM 索引缓冲
key_buffer_size = 128M
#服务器线程缓存值 默认28
thread_cache_size = 100

#buffers 以下指每个线程缓冲大小
read_buffer_size=4M
read_rnd_buffer_size=8M
sort_buffer_size=4M
join_buffer_size=8M
# MyISAM 批量插入数据缓存
bulk_insert_buffer_size = 8M

# ThreadPool
thread_handling=pool-of-threads
#thread_pool_size=32
thread_pool_oversubscribe=10


你可能感兴趣的:(Mysql参数配置)