After optimization of MySQL 5.6 my.cnf standard configuration (4-core 16G Centos6.5 x64)

[Client] 
Port = 3306 
Socket = /var/lib/mysql/mysql.sock 

[MySQL] 
# The condition setting section configured to start MySQL service; in this case, no-auto-rehash ensure that the service is started faster than . 
the rehash-Auto-NO 

[mysqld] 
User MySQL = 
Port = 3306 
Socket = /var/lib/mysql/mysql.sock 
the basedir = / usr / local / MySQL 
DATADIR = / Data / MySQL / Data / 
open_files_limit = 10240 

The back_log = 600 
# before MYSQL temporarily stop responding to new requests, the number of requests in a short time can be the presence of the stack. If the system has a lot of connections in a short time, you need to increase the value of the parameter, the parameter value specifies the size of the incoming TCP / IP connections listen queue. The default value is 80. 

3000 = max_connections 
#MySQL allow for maximum process connections, if Too Many Connections mistakes often prompted, you need to increase this value. Default 151 

max_connect_errors = 6000 
Set the maximum number of connections per host's request to abort #, when more than this number, MYSQL server connection request to host the ban until the mysql server is restarted or by flush hosts command to clear the information about this host. Default 100

= FALSE-locking External 
# using -skip-external-locking MySQL option to avoid external locking. This option is enabled by default 

max_allowed_packet = 32M 
maximum transmission network # provided a message transfer amount. The system default is 4MB, the maximum is 1GB, to be set a multiple of 1024. 

= 2M #sort_buffer_size 
# sort_buffer_size level connection is a parameter, the first time the need to use the buffer in each connection (the session) when set time allocation memory. 
#Sort_Buffer_Size not the better, as is the level of connection parameters, oversized set + high concurrency may run out of system memory resources. For example: 500 connections will consume 500 * sort_buffer_size (8M) = 4G memory 
#Sort_Buffer_Size 2KB over time, it will use mmap () instead of malloc () to perform memory allocation, resulting in reduced efficiency. Default 2M, default values are sufficient 

#join_buffer_size 2M = 
# for the inter-associative cache table size, and sort_buffer_size as the corresponding allocation parameter memory is connected to each of the exclusive. Default 2M, default values are sufficient 

the thread_cache_size = 300 
# default 38
# Thread cache server can reuse this value represents the number of threads stored in the cache, the cache when disconnected if there is space, then the client thread will be placed in the cache, if the thread again requested, then the request will read from the cache, if the cache is empty or a new request, then the thread will be re-created, if there are many new threads, increase this value can improve system performance by comparing Connections and Threads_created state variables, We can see the effect of this variable. Provided the following rules: 1GB memory configured 8,2GB configured 16,3GB memory configured 32,4GB or higher, more configurable. 

=. 8 #thread_concurrency 
# default is 10, 10 using the first observation 
# Set thread_concurrency correct value or not, a great impact on the performance of mysql, in a case where a plurality of CPU (or multi-core), the error of the set value thread_concurrency will lead mysql can not take full advantage of multi-cpu (or multi-core), in the case of the work appeared in the same time only a cpu (or nuclear). thread_concurrency should be set to twice the number of CPU core such as a dual-core CPU, a thread_concurrency then be 4;. two pairs of cores cpu, the value should be 8 thread_concurrency
 
the query_cache_size = 64M
# In the MyISAM engine optimization, this is also an important parameter optimization parameters. But also to some of the problems exposed explosion. Increasing the machine's memory, the value of the parameters used to assign more and more. When this parameter increase also led to a series of problems. We first analyze query_cache_size works: the case of a SELECT query in the working DB, DB will make that statement cached, when once again came to the same SQL DB in a call, DB did not change in the list of the the results returned from the cache to the Client. There is a construction related point is that when utilizing Query_cache DB work, the statement related to the requirements of Table There is no change at this time. If the table that changes occur, Query_cache in the data and how to handle it? First, the table should Query_cache and related statements all set to fail, and then update the writing. So if Query_cache very large, the query structure of the table and more, also slow query fails, an update will be very slow or Insert, Update or so to see how Insert is so slow. Therefore, the amount of write or update the database relatively large amount of the system, the parameter is not suitable for dispensing large. And in high concurrency, written large systems, it is recommended to ban this function. 

query_cache_limit = 4M 
buffer size # can be used to specify a single query, the default is 1M 

query_cache_min_res_unit = 2K 
# default is 4KB, a larger value is good for large data queries, but if your queries are small data query, it is likely to cause memory fragmentation and wasteful 
# Qcache_free_blocks query cache fragmentation rate = / Qcache_total_blocks * 100% 
# If the query cache fragmentation rate of more than 20%, are to be cached fragments with FLUSH qUERY cACHE, or try to reduce query_cache_min_res_unit, if your queries are small data amount of words.
# Query cache utilization = (query_cache_size - Qcache_free_memory) / * 100% query_cache_size 
# query cache utilization of 25% or less, then the explanation provided query_cache_size too large, can be appropriately reduced; Qcache_lowmem_prunes query cache utilization above 80% and> 50 word description query_cache_size may be a bit small, or is too fragmented. 
# Query cache hit ratio = (Qcache_hits - Qcache_inserts) / Qcache_hits 100% * 

#-default = MyISAM Storage Engine- 
#default_table_type # = InnoDB open failure 

#thread_stack = 192K 
# MYSQL Set each thread stack size, the default value is large enough, normal operation can be satisfied. May be set in the range of 128K to 4GB, the default is 256KB, the default observation 

transaction_isolation = the READ-COMMITTED 
. # Set the default transaction isolation levels available the following levels: READ UNCOMMITTED- READ COMMITTE- Read Uncommitted Read Committed REPEATABLE READ - may be repeat read SERIALIZABLE - serial 

tmp_table_size = 256M
# Tmp_table_size default size is 32M. If a temporary table exceeds this size, MySQL generates a form The table tbl_name is full of mistakes, if you do many advanced GROUP BY query, add tmp_table_size value. If this value is exceeded, it will be written to disk temporary tables. 
= 256M max_heap_table_size 
 
expire_logs_days. 7 = 
the key_buffer_size = 2048M
# buffer size for a given batch index, it can be better to increase processing performance index, for about 4GB server memory, this parameter can be set to 256MB or 384MB. 

1M = read_buffer_size 
# default 128K 
# MySql read into the buffer size. Request table for assigning a sequential scans read into the buffer, MySql allocate some memory buffer for it. read_buffer_size variable controls the size of the buffer. If the request for a sequential scan of the table are very frequent, and often you think scanning too slow, its performance can be improved by increasing the value of the variable, and memory buffer size. And sort_buffer_size as the corresponding allocation parameter memory is connected to each of the exclusive. 

= 16M of read_rnd_buffer_size 
# MySql random read (query) buffer size. When reading a row in any order (e.g., sorted order), assigning a random read buffer. When ordering inquiries, MySql will first scan it again this buffer to avoid disk seeks, speed up the search, if needed sorting large amounts of data, it should adjust the value. But MySql will release the buffer space for each client connection, it should be possible to set the appropriate value to avoid memory overhead is too large. 

= 64M bulk_insert_buffer_size 
# Bulk insert data cache size, can improve the efficiency of insertion, the default is 8M

myisam_sort_buffer_size = 128M 
reordering # MyISAM table changes needed to cushion the default 8M 
 
myisam_max_sort_file_size = 10G 
# MySQL to rebuild the index when the maximum allowed temporary files the size (when REPAIR, ALTER TABLE or LOAD DATA INFILE).
# If the file size is greater than this value, the index will create buffer (slower) by key 

#myisam_max_extra_sort_file_size = 10G 5.6 is no such value 
#myisam_repair_threads = the default is 1 1 
# If a table has more than one index, MyISAM can to fix them to use more than one thread through a parallel sort. 
# this is for users with more CPU and memory a lot of cases, is a good choice. 

myisam_recover 
# automatically not properly closed check and repair MyISAM table 
Skip-name-Resolve 
lower_case_table_names. 1 = 
Server-ID. 1 = 

innodb_additional_mem_pool_size = 16M 
# this parameter is used to set the size of the memory pool InnoDB stored data directory information and other internal data structures, similar to Oracle the library cache. This is not a mandatory parameter, can be broken. 

innodb_buffer_pool_size = 2048M
# This is very important for Innodb table. Innodb compared to MyISAM tables are more sensitive to buffer. MyISAM can be run under the default settings key_buffer_size can, however Innodb was like a snail in innodb_buffer_pool_size default settings. Also Innodb data and indexes are cached, the operating system without having to leave too much memory, so if you only need Innodb, then you can set it up to 70-80% of available memory. There are some rules apply to key_buffer - if you have small data, and does not surge, so no need to put too much innodb_buffer_pool_size set
#innodb_log_buffer_size = 16M using the default 8M

#innodb_data_file_path = ibdata1: 1024M: autoextend set too high lead to an error, the default 12M observation 
# tablespace files important data 

#innodb_file_io_threads = 4 is not clear, use the default 
number of threads # file IO, usually 4, but in Windows, you can set large. 


8 = innodb_thread_concurrency 
# server CPU is set to have a few a few, it is recommended to use the default setting, usually 8. 

innodb_flush_log_at_trx_commit = 2 
# If this parameter is set to 1, will be submitted after the transaction log is written to disk every time. To provide performance, it can be set to 0 or 2, but to bear the risk of losing data in the event of a failure. Set to 0 for the transaction log written to the log file, and the log file to disk per second refresh time. 2 is set to indicate that the transaction log is written to the log at the time of submission, but the log file flushed to disk every time.  
#innodb_max_dirty_pages_pct = 90 was observed using the default 75

# This parameter determines the size of the log file more memory used, in units of M. A larger buffer can improve performance, but an unexpected failure will lose data .MySQL between developers recommend setting to 8 M 

#innodb_log_file_size using default = 128M 48M 
# This parameter determines the size of the data log files, units of M, larger setting can improve performance, but also increases the time required to recover a failed database 

#innodb_log_files_in_group = 3 using the default 2 
# to improve performance, MySQL can log files in a circular fashion writes multiple files. The recommended setting is 3M 

# Recommended Reading http://www.taobaodba.com/html/221_innodb_max_dirty_pages_pct_checkpoint.html 
number # Buffer_Pool in Dirty_Page share a direct impact on the closing time of InnoDB. Innodb_max_dirty_pages_pct parameters can directly control the ratio of share of Buffer_Pool the Dirty_Page, and fortunately innodb_max_dirty_pages_pct can be changed dynamically. Therefore, the first transfer of small innodb_max_dirty_pages_pct before closing the InnoDB, forced Flush block period, it is possible to greatly shorten the turn-off time MySQL. 

= 120 innodb_lock_wait_timeout 
# default 50 seconds
# InnoDB has its own built-in deadlock detection mechanism that can cause the transaction to roll back incomplete. However, if you use MyISAM InnoDB combination of lock tables statement or a third-party transaction engine, InnoDB does not recognize the deadlock. To eliminate this possibility, innodb_lock_wait_timeout can be set to an integer value that indicates the MySQL allows other transactions from modifying those who want to wait until the final data of the transaction is rolled back by how long (in seconds) 

innodb_file_per_table = 0 
# default is No 
# alone shared space table (off) 

[the mysqldump] 
Quick 
# the max_allowed_packet = 32M 
 
[the mysqld_safe] 
log-error = / Data / MySQL / mysql_oldboy.err
PID =-File / Data / MySQL / mysqld.pid 

the sql_mode = NO_ENGINE_SUBSTITUTION, the STRICT_TRANS_TABLES

  

Guess you like

Origin www.cnblogs.com/peteremperor/p/10949070.html