MySQL config Tuning
Alexis
調整原則
1.一次調整一個
2.Set Global:若該變數是dynamic,則可用它在
runtime修正variables,但restart即會消失,需設
定option file
3.注意variable的關聯性
4.ram 2x不代表所有東西都2倍
innodb_buffer_pool_size
1.cache both data and index
2.512M:for normal
3.4G:for 寫入多
4.5.6 above
5.redo log
max_connections
1.>1000 is not OK(有人設2000)
2.thread pool
3.connection pool
innodb_file_per_table
1.bad performance
2.>10k table is not good
3.reclaim space as dropping, truncating or
rebuilding
innodb_flush_log_at_trx_commit
=1
1.safety
2.flush時會有多的fsyncs
3.完全ACID
innodb_flush_log_at_trx_commit
=2
1.每秒 flush committed transactions 到 redo log
2.適合replica
3.loss data as OS crash
=0
1.crash時會丟失
innodb_flush_method
1.通常O_DIRECT
2.sysbench來判斷
innodb_log_buffer_size
-flushed every 1 sec
-default is ok for medium write & shorter
transactions
-more for activity spikes or lots of blobs work
innodb_log_buffer_size
-not committed yet
-1MB
-innodb_log_waits
-larger will save disk I/O
innodb_log_file_size
larger:
-better performance
-longer recovery time
-less checkpoint flush activity
innodb_log_file_size
BUG #69477
5.6.20 5.6.22
10 times larger than
the largest BLOB +
length of other
variable length
fields
redo log BLOB’s
max is 10% of redo
log size
Query_cache_size
1.well-known bottleneck
2.better to be zero
3.good indexing, replicas, external cache
4.not good for real practice
5.Today’s machine is much faster than before
log_bin
1.for replication master
2.also got to set server_id
3.to save disk space:
a.expire_logs_days
b.purge binary logs
skip_name_resolve
1.enable it to prevent the slow DNS let you
slow
2.GRANT got to use IP address
3.skip_name_resolve
PS
1.table_cache
2.thread_cache:dont create thread for normal
operation
PS
http://dev.mysql.com/doc/refman/5.
6/en/server-system-variables.
html#sysvar_table_definition_cache

MySQL 5.6 config 優化