# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password=your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 11
################################ 指定數據庫使用user ##############################
user = mysql
################################ 創建function+view ##############################
log_bin_trust_function_creators=1
################################ performance_schema ##############################
performance_schema = 1
################################ innodb_stats_on_metadata ##############################
innodb_stats_on_metadata=0
################################ default_authentication_plugin ##############################
default_authentication_plugin=mysql_native_password
################################ common parameter ################################
# 默認innodb存儲引擎, 默認utf8字符集,默認不忽略大小寫
default-storage-engine = INNODB
#character_set_server=utf8mb4
#collation_server = utf8mb4_unicode_ci
character_set_server=utf8
collation_server = utf8_general_ci
#sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
# 文件系統中小寫表名,避免兼容性問題
lower_case_table_names=1
# 不解析dns,忽略外部鎖
#skip_name_resolve = 1
skip-name-resolve
skip-external-locking
# 數據目錄
datadir = /data/mysqldata/3306/data/
# 取消query_cache
#query_cache_type = 0
#query_cache_size = 0
# Try number of CPU's*2 for thread_concurrency , only for solaris
#thread_concurrency = 8
# table and thread cache
#table_open_cache = 2000
#table_definition_cache = 512
#thread_cache_size = 100
#事務隔離級別
transaction_isolation = READ-COMMITTED
max_heap_table_size = 32M
# max_length_for_sort_data 避免再次回表獲得數據,使用優化過的排序算法
max_length_for_sort_data = 16k
# 是否只讀
read_only=0
#關閉TIMESTAMP警告
explicit_defaults_for_timestamp = 1
#數據庫或表不可以存儲在my.cnf中指定datadir之外的分區或目錄,需支持符號鏈接
#skip-symbolic-links
log_timestamps=system
#transaction_write_set_extraction=MURMUR32
#transaction_write_set_extraction=XXHASH64
transaction_write_set_extraction=OFF
#show_compatibility_56=on
################################ connection parameter ################################
#bind_address = 0.0.0.0
back_log = 100
port = 3306
socket = /tmp/mysql.sock
tmpdir = /tmp
#最大連接數
max_connections=5000
# 加大該次數,以免is blocked的報錯
max_connect_errors = 1844674407370954751
max_allowed_packet = 512M
# 報表計算的程序是一天算一次,所以需要增大該時間以免被MySQL服務器kill會話
wait_timeout = 7200
interactive_timeout = 2880000
################################ per thread memory ################################
thread_stack = 512k
net_buffer_length = 8K
sort_buffer_size = 32M
join_buffer_size = 128M
read_buffer_size = 16M
read_rnd_buffer_size = 32M
# 最大內存臨時表大小
tmp_table_size = 64M
binlog_cache_size = 1M
################################ log parameter ################################
#錯誤日誌
log_error=/data/mysqldata/3306/data/mysql-error.log
#將影響general log和slow log的存放方式,支持TABLE|FILE
log_output=FILE
#log_error_verbosity
log_error_verbosity=2
#通用日誌,記錄所有客戶端的連接和執行的語句
general_log=OFF
general_log_file=/data/mysqldata/3306/data/mysql-general.log
#慢查
slow_query_log=1
slow_query_log_file=/data/mysqldata/3306/data/mysql-slow.log
long_query_time = 2
#如果運行的SQL語句沒有使用索引,則mysql數據庫同樣會將這條SQL語句記錄到慢查詢日誌文件中
log_queries_not_using_indexes = 1
#由於log_queries_not_using_indexes爲1,設置每分鐘記錄能夠記錄的數量
log_throttle_queries_not_using_indexes = 10
#記錄執行速度較慢的管理命令,如OPTIMEZE TABLE
log_slow_admin_statements = 1
#複製從庫記錄複製查詢的日誌###a replication slave does not write replicated queries to the slow query log
log_slow_slave_statements = 1
#查詢檢查返回少於該參數指定行的SQL不被記錄到慢查詢日誌
min_examined_row_limit = 100
################################ replication parameter ################################
log_slave_updates
relay_log=/data/mysqldata/3306/relay-log/relay_log
master_info_repository = "TABLE"
relay_log_info_repository = "TABLE"
relay_log_recovery = 1
skip-slave-start
# 設置複製過濾
replicate_ignore_table=mysql.columns_priv
replicate_ignore_table=mysql.db
replicate_ignore_table=mysql.host
replicate_ignore_table=mysql.procs_priv
replicate_ignore_table=mysql.tables_priv
replicate_ignore_table=mysql.user
replicate-wild-ignore-table = test.%
replicate-wild-ignore-table = sys.%
# 半同步配置
#plugin_dir=/usr/local/mysql/lib/plugin/
#plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
# 增加強密碼策略
#plugin_load = "validate_password.so;rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
#rpl_semi_sync_master_enabled=1
#rpl_semi_sync_master_timeout=3000
#rpl_semi_sync_slave_enabled=1
#rpl_semi_sync_master_trace_level=64
#rpl_semi_sync_slave_trace_level=64
#rpl_semi_sync_master_wait_no_slave=1
#下面這三個參數打開,則上面rpl_semi相關參數相當於同步打開
#loose_rpl_semi_sync_master_enabled = 1
#loose_rpl_semi_sync_slave_enabled = 1
#loose_rpl_semi_sync_master_timeout = 5000
# password plugin #
#validate_password_policy=STRONG
#validate-password=FORCE_PLUS_PERMANENT
# Replication Master Server (default)
# binary logging is required for replication
log_bin=/data/mysqldata/3306/binlog/mysql-bin
# binlog
autocommit=1
binlog_format=row
# binlog最大值
max_binlog_size=512M
#binlog刪除的過期時間 30天
binlog_expire_logs_seconds=2592000
# 保障二進制日誌能夠刷到磁盤 sync_binlog=1
# 我們這裏丟失一些數據沒有關係可設置爲0
sync_binlog=1
# slave庫重連間隔時間
slave_net_timeout=60
#啓用GTID
#gtid_mode = on
#enforce_gtid_consistency = 1
#當mysql啓動或重啓時,mysql在搜尋GTIDs時是如何迭代使用binlog文件的,會提升mysql執行恢復的性能
binlog_gtid_simple_recovery = 1
#複製出錯跳過
slave_skip_errors = ddl_exist_errors
#可以在binlog_format=row中記錄執行的SQL語句。
binlog_rows_query_log_events = 1
#更好的從機回放算法
slave_rows_search_algorithms = 'INDEX_SCAN,HASH_SCAN'
#基於組提交的並行複製方式
slave_parallel_type = LOGICAL_CLOCK
#複製線程數,但如果主機負載不大,很有可能發生每組提交的事務數量僅有1個,但從機回放時就會有延遲。壓力大時可設置爲16
slave_parallel_workers = 0
slave_preserve_commit_order=1
slave_transaction_retries=128
################################ MyISAM parameter ################################
key_buffer_size = 64M
myisam_sort_buffer_size = 64M
myisam_repair_threads = 1
################################ innodb parameter ################################
# innodb 獨立表空間
innodb_file_per_table=1
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir=/data/mysqldata/3306/data/
innodb_data_file_path=ibdata1:100M:autoextend
innodb_log_group_home_dir=/data/mysqldata/3306/data/
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 1G
innodb_log_buffer_size = 16M
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 2G
#保障innodb tx log innodb_flush_log_at_trx_commit = 1
# 我們這裏丟失一些數據沒有關係可設置爲2
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
# 在innodb lru list 先呆一秒再放到lru頭
innodb_old_blocks_time=1000
# 取消二階段事務
#innodb_support_xa = OFF
# O_DIRECT 刷新
innodb_flush_method=O_DIRECT
#InnoDB緩存池被劃分的區域數量,建議每個區域不小於1GB的空間
innodb_buffer_pool_instances = 2
#本地熱數據加載到InnoDB緩衝池中
innodb_buffer_pool_load_at_startup = 1
#停止MySQL服務時,InnoDB將InnoDB緩衝池中的熱數據保存到本地硬盤
innodb_buffer_pool_dump_at_shutdown = 1
#default 1024, 根據innodb_io_capacity 增加而增加
innodb_lru_scan_depth = 2000
#如果事務因爲加鎖超時,則整個事務都會回滾
innodb_rollback_on_timeout = 1
# 不開啓event
event_scheduler=0
# auto-inc 如果等於2時不會鎖表,來一個處理一個,併發最高 ,但不安全,不適合replication
innodb_autoinc_lock_mode = 1
# repair table
myisam_recover_options=force
#收集統計信息每次採樣的塊數,默認爲20
innodb_stats_persistent_sample_pages=64
# 自增ID步長
auto_increment_increment=1
auto_increment_offset=1
# innodb文件格式
#innodb_file_format = Barracuda
#innodb_file_format_max=Barracuda
innodb_io_capacity = 400
innodb_io_capacity_max = 1000
innodb_change_buffering=inserts
innodb_use_native_aio = 1
innodb_strict_mode = 1
innodb_purge_threads=4
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_undo_directory = /data/mysqldata/3306/data
#innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_neighbors = 1
#innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_sort_buffer_size = 64M
innodb_max_dirty_pages_pct = 90
innodb_log_files_in_group = 3
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 8
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
#innodb_rollback_segments=16
#innodb_spin_wait_delay=30
#innodb_sync_spin_loops=100
[mysqldump]
quick
max_allowed_packet = 160M
[mysql]
no-auto-rehash
show-warnings
prompt="8.0 \\u@\\h : \\d \\r:\\m:\\s> "
default-character-set = utf8
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout