Mysql configuration optimization

1. Innodb configuration optimization

Thread parameter configuration:

sort_buffer_size (sort buffer), join_buffer_size (join buffer size), read_buffer_size (read buffer size), read_rnd_buffer_size (index buffer size)

 

mysql innodb system parameter configuration:

innodb_buffer_pool_size=1024M #innodb buffer pool size, set the size of the cache used by innodb, set about 80% of the memory, the general setting and the size of the data volume are always the same (total memory - memory required by each thread * number of connections - memory reserved by the system) 

 

innodb_log_file_size controls the size of a single transaction log file

innodb_log_files_in_group controls the number of transaction log files

innodb_log_buffer_size log buffer size 32M 64M 

innodb_flush_log_at_trx_commit=2 #Set to 0, the contents of the log buffer are written to the log every second, and flush to the disk. Set to 1. After each transaction is committed, write the contents of the log buffer to the transaction log and to the disk, and set 2 to commit each transaction. Write the log buffer content to the transaction log, but not to disk, set the mechanical hard disk to 2, and the solid-state hard disk to 1

innodb_flush_method=O_DIRECT informs the operating system not to cache data and write data directly to disk.

innodb_file_per_table=1 Open independent tablespace

innodb_doublewrite=1 Enable double write cache to prevent data loss

expire_logs_days=0 The number of days binlog logs are saved

max_allowed_packet=1073741824 The maximum size of the packet received by mysql

read_only=1 prohibits any account without super permission from modifying permissions, generally enable this option in the slave library

sql_mode can specify the standard canonical optional value of sql:

STRICT_TRANS_TABLES will break sql if the given data cannot be inserted into the transaction
NO_ENGINE_SUBSTITUTION If the storage engine specified in create table is unavailable, let the table creation fail, not the default storage engine to create the table
only_full_group_by requires that fields without group by in the query cannot be queried
no_zreo_date table is not allowed to store values ​​such as 0000-00-00 in dates

 sync_binlog controls how mysql flushes the binlog to the disk. The default 0 is for the system to decide when to flush the binlog, and it is set to 1. Refreshing the binlog after each transaction is completed affects performance, but data security

 

tmp_table_size and max_heap_table_size control the size of the memory temporary table, the two parameter values ​​should be consistent, and do not set too large to prevent memory overflow

 

max_connections mysql maximum number of connections, the default is 100, usually modified to 2000 or more

 

Second, the impact of database design on performance:

1. Excessive denormalization creates too many columns

2. Excessive normalization causes too many table associations

3. Using an inappropriate partition table in the trading system

4. Use foreign keys to ensure data integrity

 

Performance optimization order:

1. Database design and sql statement

2. Configuration of database storage engine and parameters

3. System selection and optimization

4. Hardware upgrade

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326021214&siteId=291194637
Recommended