生產環境的MYSQL配置

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

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
user            = mysql
port            = 3306
basedir         = /usr
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
collation_server=utf8_bin
character_set_server=utf8
event_scheduler=ON
max_connect_errors=1000
key_buffer_size         = 16M
max_allowed_packet      = 300M
wait_timeout=28800000
interactive_timeout = 28800000
thread_stack            = 192K
thread_cache_size       = 8
myisam-recover-options  = BACKUP
query_cache_limit       = 1M
query_cache_size        = 16M
#expire_logs_days       = 10
max_binlog_size   = 100M

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
validate_password = off
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 服務器的ID,必須唯一,一般設置自己的IP
server_id=2011
# # 複製過濾:不需要備份的數據庫(MySQL庫一般不同步)
binlog-ignore-db=mysql

# # 爲每個 session 分配的內存,在事務過程中用來存儲二進制日誌的緩存
binlog_cache_size=1M
# # 主從複製的格式(mixed,statement,row,默認格式是 statement)
binlog_format=mixed
# # 二進制日誌自動刪除/過期的天數。默認值爲 0,表示不自動刪除。
expire_logs_days=7
# ## 跳過主從複製中遇到的所有錯誤或指定類型的錯誤,避免 slave 端複製中斷。 
# ## 如:1062 錯誤是指一些主鍵重複,1032 錯誤是因爲主從數據庫數據不一致
# #slave_skip_errors=1062
slave-skip-errors = all   #跳過所有的錯誤錯誤,繼續執行復制操作
# 作爲從服務器時的中繼日誌
#relay_log=edu-mysql-relay-bin
# log_slave_updates 表示 slave 將複製事件寫進自己的二進制日誌
log_slave_updates=1
# 主鍵自增規則,避免主從同步ID重複的問題
auto_increment_increment=2  # 自增因子(每次加2)
auto_increment_offset=2     # 自增偏移(從1開始),單數

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章