一般情况下,配置文件的内容,除server_id,auto_increment* 需要根据节点数来调整,
relay_log_purge需要根据架构来调整外,其他无需调整。
参数会随着版本的改动而有所变动。所以这里的配置,也不是铁律,要根据版本进行调整
,最后得到最适合自己的环境的配置。
[mysqld]
datadir=/data
socket=/var/lib/mysql/mysql.sock
init-connect='SET NAMES utf8'
character-set-server=utf8
lower_case_table_names = 1
symbolic-links=0
# Tunning settings
#innodb storage configuration
default-storage-engine=innodb
innodb_file_per_table=1
innodb_flush_log_at_trx_commit=2
innodb_flush_method=O_DIRECT
innodb_log_buffer_size=256M
innodb_log_files_in_group=8
transaction_isolation=READ-COMMITTED
# Connection configurations
max_connections=1000
max_connect_errors=10000
# query related
query_cache_type=1
query_cache_size=128M
long_query_time=1
#Memory Configuration
## For temp table
max_heap_table_size=96M
tmp_table_size=96M
## For sort / join / read
sort_buffer_size=5M
join_buffer_size=5M
read_buffer_size=5M
read_rnd_buffer_size=5M
# For Myiasm if be used
key_buffer_size=52M
# For function
log_bin_trust_function_creators=1
# master — slave configurations
server-id= 48
log-bin=mysql-bin
log-bin-index=mysql-bin.index
binlog_format = MIXED
sync-binlog=1
expire-logs-days = 14
auto_increment_offset=1 # —> 多主结构使用
auto_increment_increment=2 # —> 多主结构使用
skip-slave-start
# 配置半同步复制
plugin-load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
rpl-semi-sync-master-enabled = 1
rpl-semi-sync-slave-enabled = 1
# 配置relay log . MHA结构中需要将relay_log_purge 设置为0. 其他主从结构配置为1
relay_log_purge=1
relay_log_recover=1
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid