my.cnf配置文件参考-持续

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sld880311/article/details/83049709

下面是72GB内存生产环境中my.cnf配置文件,读者可以作为一个优化参考:

# MySQL configuration for 72G memory
[client]
port    = 3306
socket  = /tmp/mysql.sock

# The MySQL server
#########Basic##################
[mysqld]
server-id= 22
port     = 3306
user     = mysql
basedir  = /usr/local/mysql
datadir  = /mysqlData/data
tmpdir   = /mysqlData/tmp
socket   = /tmp/mysql.sock
skip-external-locking
skip-name-resolve
default-storage-engine = INNODB
character-set-server = utf8

#服务器默认的“wait_timeout”是8小时,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection
#数据库连接池如果没有配置正确,就会导致connection失效,wait_timeout与interactive_timeout要同时设置
#数据库连接池中需要配置的存活时间小于数据库中的时间,或者通过定期检查链接的状态
#wait_timeout:服务器关闭非交互连接之前等待活动的秒数。
wait_timeout = 100
#interactive_timeout:服务器关闭交互式连接前等待活动的秒数。
interactive_timeout = 100
#mysql客户端在尝试与mysql服务器建立连接时,mysql服务器返回错误握手协议前等待客户端数据包的最大时限。默认10秒。
connect_timeout = 20
back_log = 500
myisam_recover
event_scheduler = ON

#########binlog##################
log-bin = /mysqlLog/logs/mysql-bin
binlog_format = row
max_binlog_size = 28M
binlog_cache_size = 2M
expire-logs-days = 5


#########replication#############
#mysql从复制连结等待读取数据的最大时限,默认3600秒。
slave-net-timeout                  = 10
rpl_semi_sync_master_enabled       = 1
rpl_semi_sync_master_wait_no_slave = 1
rpl_semi_sync_master_timeout       = 1000
rpl_semi_sync_slave_enabled        = 1
skip-slave-start
log_slave_updates                  = 1
relay_log_recovery                 = 1

#########slow log#############
slow_query_log = 1
slow_query_log_file = /mysqlLog/logs/mysql.slow
long_query_time = 2

#########error log#############
log-error  = /mysqlLog/logs/error.log

#######per_thread_buffers############
#查看最大连接数:show variables like '%max_connections%';
#修改最大连接数:set GLOBAL max_connections = 200;(重启后失效)或则直接修改配置文件
#默认100,最大值16384
#使用命令show processlist; 可以查询相关的连接信息,显示100条,使用show full processlist; 可列出所有
max_connections=1024

max_user_connections=1000
max_connect_errors=10000
key_buffer_size = 64M
max_allowed_packet = 128M
table_cache = 3096
table_open_cache = 6144
table_definition_cache = 4096
sort_buffer_size = 512K
read_buffer_size = 512K
read_rnd_buffer_size = 512k
join_buffer_size = 512K
tmp_table_size = 64M
max_heap_table_size = 64M
query_cache_type=0
query_cache_size = 0
bulk_insert_buffer_size = 32M
thread_cache_size = 64
thread_concurrency = 32
thread_stack = 256K

######### InnoDB #############
innodb_data_home_dir = /mysqlData/data
innodb_log_group_home_dir = /mysqlLog/logs
innodb_data_file_path = ibdata1:2G:autoextend
innodb_buffer_pool_size = 50G
innodb_buffer_pool_instances = 8
innodb_additional_mem_pool_size = 16M
innodb_log_file_size = 1024M
innodb_log_buffer_size = 64M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
#事务等待获取资源等待的最长时间,超过这个时间还未分配到资源则会返回应用失败,通过以下方式可以动态设置
#set innodb_lock_wait_timeout=100;   ---------session
#set global innodb_lock_wait_timeout=100;   ---------global
#注意global的修改对当前线程是不生效的,只有建立新的连接才生效
innodb_lock_wait_timeout = 10
innodb_sync_spin_loops = 40
innodb_max_dirty_pages_pct = 90
innodb_support_xa = 1
innodb_thread_concurrency = 0
innodb_thread_sleep_delay = 500
innodb_file_io_threads    = 4
innodb_concurrency_tickets = 1000
log_bin_trust_function_creators = 1
innodb_flush_method = O_DIRECT
innodb_file_per_table
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 2000
innodb_file_format = Barracuda
innodb_purge_threads=1
innodb_purge_batch_size = 32
innodb_old_blocks_pct=75
innodb_change_buffering=all
transaction_isolation = READ-COMMITTED

[mysqldump]
quick
max_allowed_packet = 128M
myisam_max_sort_file_size = 10G

[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 256k
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 28192 

猜你喜欢

转载自blog.csdn.net/sld880311/article/details/83049709