1. 程式人生 > >mysql5.6的my.cfg

mysql5.6的my.cfg

client]
port = 3306
default-character-set=utf8
#character-set-server = utf8
socket = /data/mysql/mysql.sock

[mysqld]
##############################
#不進行反解析
###############################
skip-name-resolve

##########################
#summary
##########################
port = 3306
datadir = /data/mysql/data
socket = /data/mysql/mysql.sock
user = mysql

#################################
#timestamp
##################################
explicit_defaults_for_timestamp=true


#############################
#connection
############################
max_connections = 2000
max_user_connections = 1900
max_connect_errors = 6000
max_allowed_packet = 40M


#############################
#log bin
###############################
server-id=1
log-bin=/data/mysql/mysql-bin
binlog_format = row
#log-slave-updates   
#級聯複製,從庫擴充套件需要·


###############################
# table_open
##############################
table_open_cache=8000


###################################
# thread_cache
####################################
thread_cache_size=16
thread_stack =512K


##################################
#buffer
####################################
sort_buffer_size = 4M


##############################
#read
###############################
read_buffer_size = 2M
read_rnd_buffer_size = 12M


###################################
#timeout 下面兩個值要一樣
##################################
wait_timeout=400
interactive_timeout=400  

#######################################
#relay-log  slave mysql需要
########################################
relay-log-index = /data/mysql/mysqld-relay-bin
relay-log-info-file = /data/mysql/relay-log.info
relay-log = /data/mysql/mysqld-relay-bin

###################################
#log general  一般日誌
###################################
#general_log = on
#general_log_file=/data/log/mysql.log
expire_logs_days=30   

#用於binlog日誌,過期時間

#########################
#log error
#######################
log-error=/data/log/mysql-err.log


########################
#slow 慢查詢
#####################
slow_query_log=on
slow_query_log_file=/data/mysql/mysql-slow.log
long_query_time=5
log_queries_not_using_indexes =on

###############################################
# password
##############################################
plugin-load=validtae_password.so
validate-password=FORCE_PLUS_PERMANENT
validate_password_policy=0
validate_password_length=6

#skip-grant-tables

#################################################
# semi 半同步
################################################
rpl_semi_sync_master_enabled=ON

#rpl_semi_sync_slave_enabled=ON

################################################
#innodb
##############################################
innodb_buffer_pool_instances = 3
innodb_file_per_table = 1
innodb_buffer_pool_size = 6G     
#//絕大數innodb引擎 實體記憶體50%-80%
innodb_thread_concurrency = 8   
#//併發量,一般可以當cup使用高,要調節
innodb_max_dirty_pages_pct = 50
# //髒頁重新整理


################################################
#innodb_flush和sync_binlog為1保持資料一致性,每次事務提交都會把log buffer 刷到檔案中,並呼叫檔案‘flush’操作重新整理到磁碟,資料庫對IO要求非常高。硬體提供IOPS比較差,可能資料庫併發受到硬體IO問題無法提升
###############################################
innodb_flush_log_at_trx_commit=1
sync_binlog=1
innodb_log_file_size=200M
binlog_cache_size=1M    

#預設是32K
binlog_stmt_cache_size=64K

#預設是32K
tmp_table_size=64M

#預設是16M


#//不能太大,恢復起來時間長,不能太小,頻繁切換日誌, 可以看每分鐘產生日誌大小成60,一小時的來設定
#innodb_log_buffer_size=  //預設16M

#innodb_data_file_path =ibdata1:12M:autoextend
#//防止在高併發下,資料庫受影響


#skip-federated

[mysqld_safe]
open-files-limit = 8192
pid-file=/data/mysql/mysql.pid