Mysql配置文件参数设置及优化

来源:互联网 发布:mac翻墙浏览器 编辑:程序博客网 时间:2024/05/21 17:02

服务器环境:Centos 7.3 内存 32G 500G SSD
Mysql 版本:5.7.17

一、配置文件实例

[mysqld]datadir=/data/mysqldatasocket=/tmp/mysql.socksymbolic-links=0skip-name-resolvelog_error = /data/mysqldata/mysql-error.logcharacter-set-server = utf8mb4long_query_time = 1     #慢查询日志触发时间slow_query_log = 1      #启用慢日志slow_query_log_file = /data/mysqldata/mysql-slow.logsql_mode = NO_ENGINE_SUBSTITUTIONmax_allowed_packet = 512M   #Server接受的最大数据包大小performance_schema = 0wait_timeout = 28800sql_mode='NO_ENGINE_SUBSTITUTION'#myisam引擎配置myisam_sort_buffer_size = 512M  #MyISAM表发生变化时重新排序所需的缓冲。query_cache_size= 1024M     #指定MySQL查询结果缓冲区的大小。query_cache_type=1      #为1是使用缓存,查询总是先到查询缓存中查找,即使使用了sql_no_cache仍然查询缓存,因为sql_no_cache只是不缓存查询结果,而不是不使用查询结果。group_concat_max_len=4096back_log=1024max_heap_table_size=256Mtable_open_cache =4096thread_cache_size=128sort_buffer_size=8Mread_buffer_size=8Mread_rnd_buffer_size = 8Mopen_files_limit=400000max_connections=8000tmp_table_size = 128Mpid-file=/data/mysqldata/mysql.pid#innodb引擎的配置innodb_flush_method=O_DIRECTinnodb_io_capacity=2000     #刷新脏页的数量innodb_io_capacity_max=6000 #限制每秒刷新的脏页上限innodb_lru_scan_depth=2000  #从每个buffer pool instance的lru上扫描的深度,调大该值有助于多释放些空闲页,避免用户线程去做single page flush。default_storage_engine = InnoDBinnodb_file_per_table = 1innodb_buffer_pool_dump_at_shutdown = 1innodb_buffer_pool_load_at_startup = 1innodb_buffer_pool_size = 25G   #缓存用户表及索引数据的最主要缓存空间,对 Innodb 整体性能影响也最大。innodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 16innodb_purge_threads = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 5Minnodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120interactive_timeout = 28800innodb_additional_mem_pool_size = 16Minnodb_sort_buffer_size = 512M#binlog配置log-bin = /data/mysqldata/log-bin   #binlog路径binlog_format = MIXED   #binlog格式max_binlog_cache_size = 64M #max_binlog_size = 1G    #单个binlog文件的大小expire_logs_days = 3relay-log-info-repository=TABLEmaster-info-repository=TABLE[mysql]no-auto-rehashdefault-character-set=utf8prompt=mysql \\d>

二、参数说明

Myisam引擎

选项 缺省值 推荐值 说明 query_cache_type mysql默认为关闭 off 这个变量有三个取值:0,1,2,分别代表了off、on、demand。是0,那么query cache 是关闭的。如果是1,那么查询总是先到查询缓存中查找,即使使用了sql_no_cache仍然查询缓存,因为sql_no_cache只是不缓存查询结果,而不是不使用查询结果。如果是2,DEMAND。只要query_cache_type没有关闭,sql查询总是会使用查询缓存,如果缓存没有命中则开始查询的执行计划到表中查询数据。 col 2 is centered zebra stripes are neat

InnoDB引擎

选项 缺省值 推荐值 说明 col 3 is right-aligned col 2 is centered zebra stripes are neat

三、优化思想

http://blog.csdn.net/yang1982_0907/article/details/20123055
http://www.linuxidc.com/Linux/2016-03/128829.htm

参数解析:

原创粉丝点击