[client]
port = 3306
socket = /data/mysql/mysql/mysql.sock
default-character-set=utf8mb4
[database]
character_set_database=utf8mb4
[mysql]
prompt = "\u@mysqldb \R:\m:\s [\d]> "
no_auto_rehash
[mysqld]
#-------------------------------基础配置-------------------------
server-id=64
log-bin=/data/mysql/binlogs/binlog
port = 3306
socket = /data/mysql/mysql/mysql.sock
basedir = /usr/lib64/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/mysql/mysql.pid
log-error = /data/mysql/logs/mysql.err
symbolic-links=0
#字符集#
character-set-server=utf8mb4
collation-server= utf8mb4_general_ci
init_connect='SET NAMES utf8mb4 COLLATE utf8mb4_general_ci'
character-set-client-handshake = false
#不区分大小写#
lower_case_table_names=1
#MySQL 应该支持的 sql 语法,对数据的校验等等,限制一些所谓的' 不合法'的操作#
sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
#sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES
wait_timeout=31536000
interactive_timeout=31536000
#最大连接数和最大的用户连接数#
max_connections=9999
max_user_connections=8888
#跳过主机名解析#
skip-name-resolve
#设置默认时区
default_time_zone = '+8:00'
innodb_file_per_table=1
log_bin_trust_function_creators = 1
explicit_defaults_for_timestamp=0
innodb-strict-mode=0
#启用admin_port,连接数爆满等紧急情况下给管理员留个后门
admin_address = '127.0.0.1'
admin_port = 33062
#-------------------------------基础配置 end---------------------
#default_authentication_plugin=mysql_native_password
#-------------------------------优化参数-------------------------
innodb_data_file_path = ibdata1:1G:autoextend
#InnoDB使用后台线程处理数据页上读写I/O(输入输出)请求的数量,默认为4,推荐改为cpu核数的一半
innodb_read_io_threads=4
innodb_write_io_threads=4
innodb_purge_threads = 4
innodb_page_cleaners = 4
#io
innodb_io_capacity = 300
innodb_io_capacity_max = 800
#缓冲池大小,单位为B,如果服务只作为数据库机器,推荐设置为服务器总可用内存的70%
innodb_buffer_pool_size=8192M
innodb_buffer_pool_instances = 4
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_flush_log_at_trx_commit = 1
#用于生成撤消记录的事务使用的回滚段数 InnoDB,参数别名:innodb_rollback_segments
innodb_max_undo_log_size = 4G
innodb_undo_directory = /data/mysql/undo
innodb_undo_tablespaces = 8
innodb_undo_log_truncate = 1
#redo
innodb_log_buffer_size = 32M
#innodb_log_file_size = 2G
#innodb_log_files_in_group = 3
innodb_lru_scan_depth = 4000
#每个session 分配的内存
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
sync_binlog = 1
sort_buffer_size = 4M
join_buffer_size = 4M
binlog_checksum = 1
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
#myisam_repair_threads = 1
#限制server接受的数据包大小
max_allowed_packet = 1024M
#bin-log能够使用的最大cache内存大小,使用的前提是开启了bin-log
max_binlog_cache_size = 4G
#bin-log日志保留天数
binlog_expire_logs_seconds = 7
#0不记录警告信息,1将警告信息一并记录到错误日志中
#log_warnings = 1
#GROUP_CONCAT函数用于将多个字符串连接成一个字符串,设置最大拼接长度
group_concat_max_len = 10240
#事务隔离级别,只有在事务提交后,才会对另一个事务产生影响
transaction_isolation = READ-COMMITTED
#不能使用链接文件
#skip-symbolic-links
#不使用系统锁定,避免 MySQL的外部锁定,减少出错几率增强稳定性
skip-external-locking
#MySql的连接数达到max_connections时,新来的请求将会被存在堆栈中
back_log = 200
#mysql最大连接错误数
max_connect_errors = 99999
max_error_count = 65535
#文件描述符限制
open_files_limit = 10000
#事务锁超时时间
lock_wait_timeout = 120
#数据读取超时时间
net_read_timeout = 120
#数据库写超时时间
net_write_timeout = 120
#可以重新利用保存在缓存中线程的数量
thread_cache_size = 300
#使数据库能使用LOAD DATA INFILE语句
local_infile = 1
#全文索引的最小搜索长度
ft_min_word_len = 1
#表高速缓存的大小
table_open_cache = 2048
#每个连接线程被创建时,MySQL给它分配的内存大小
thread_stack = 256K
#最大脏页的百分数,脏页所占百分比超过这个值,把页中的已更新数据写入到磁盘文件中
innodb_max_dirty_pages_pct = 70
#写入操作是直接从mysql innodb buffer到磁盘的,并不用通过操作系统的缓冲
innodb_flush_method = O_DIRECT
#多线程并发提交的数量
innodb_commit_concurrency = 0
#提高插入数据速度
bulk_insert_buffer_size = 64M
#-------------------------------优化参数 end----------------------
#-------------------------------慢查询日志优化--------------------
#开启慢查询日志
slow_query_log
#慢查询日志存放路径
slow_query_log_file = /data/mysql/logs/slow.log
#不记录没有带索引的查询语句到慢查询日志中
log_queries_not_using_indexes = 0
#不记录执行缓慢的管理sql
log_slow_admin_statements = 0
#不记录从库上执行的慢查询语句
#log_slow_slave_statements = 0
#设定每分钟记录到日志的未使用索引的语句数目
log_throttle_queries_not_using_indexes = 10
#慢查询时间0.5秒
long_query_time = 0.5
#-------------------------------慢查询日志优化 end---------------
#----------------------replication 优化--------------------------
#启动relaylog的自动修复功能,避免由于网络之类的外因造成日志损坏,主从停止。
#master_info_repository = TABLE
#relay_log_info_repository = TABLE
#开启gitd,
gtid_mode = on
enforce-gtid-consistency = on
binlog_transaction_dependency_tracking = WRITESET
replica_preserve_commit_order = 1
replica_checkpoint_period = 2
#数据库多级同步时需开启
log_replica_updates
#binlog日志的模式,仅需记录哪条数据被修改了
binlog_format = row
#当slave从库宕机后,自动放弃所有未执行的relay-log
relay_log_recovery = 1
#replica-parallel-type=LOGICAL_CLOCK
replica-parallel-workers=8
relay-log-purge = 1
#在MySQL重启或启动的时候寻找GTIDs过程中,控制binlog 如何遍历的算法
binlog_gtid_simple_recovery = 1
#slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'
#将这个两个数据库的事件从中继日志过滤
#replicate-wild-ignore-table = mysql.%
#replicate-wild-ignore-table = performance_schema.%
#--------------------replication end-----------------------------
#--------------------qcache end----------------------------------
[mysqldump]
#不缓冲查询,直接导出到标准输出
quick
#server接受的数据包大小
max_allowed_packet = 64M
[mysql]
#不重新进行哈希运算,使mysql启动更快
no-auto-rehash
default-character-set = utf8mb4
#myisam引擎的一些优化
[isamchk]
key_buffer = 50M
sort_buffer_size = 50M
read_buffer = 8M
write_buffer = 8M
[myisamchk]
key_buffer = 50M
sort_buffer_size = 50M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
log-error=/data/mysql/log.err
评论