MySQL InnoDB storage engine core features

Buffer pool related

select @@innodb_buffer_pool_size;
+---------------------------+
| @@innodb_buffer_pool_size |
+---------------------------+
|                1073741824 |
+---------------------------+

select 1073741824/1024/1024;
+----------------------+
| 1073741824/1024/1024 |
+----------------------+
|        1024.00000000 |
+----------------------+

# innodb_buffer_pool_size 一般建议最多是物理内存的 75-80%

the innodb_flush_log_at_trx_commit (one a double standard)

The main control innodb data log buffer is written to the log file to disk and flush points, respectively 0,1,2 three values.

select @@innodb_flush_log_at_trx_commit;
+----------------------------------+
| @@innodb_flush_log_at_trx_commit |
+----------------------------------+
|                                1 |
+----------------------------------+
参数说明:

1,每次事物的提交都会引起日志文件写入、flush 磁盘的操作,确保了事务的ACID;flush 到操作系统的文件系统缓存 fsync到物理磁盘.
0,表示当事务提交时,不做日志写入操作,而是每秒钟将 log buffer 中的数据写入文件系统缓存并且秒 fsync 磁盘一次;
2,每次事务提交引起写入文件系统缓存,但每秒钟完成一次fsync磁盘操作。
--------
The default setting of 1 is required for full ACID compliance. Logs are written and flushed to disk at each transaction commit.
With a setting of 0, logs are written and flushed to disk once per second. Transactions for which logs have not been flushed can be lost in a crash.
With a setting of 2, logs are written after each transaction commit and flushed to disk once per second. Transactions for which logs have not been flushed can be lost in a crash.
-------

Innodb_flush_method=(O_DIRECT, fdatasync)


Can refer to the official document: https: //dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_flush_method
This option controls the log buffer and the data buffer is flashed when the disk through the file system cache whether

Check the status quo strategy

show variables like '%innodb_flush%';

# 参数说明
O_DIRECT  : 数据缓冲区写磁盘,不走 OS buffer
fsync     : 日志和数据缓冲区写磁盘,都走 OS buffer
O_DSYNC   : 日志缓冲区写磁盘,不走 OS buffer

Recommendations

最高安全模式:
innodb_flush_log_at_trx_commit=1
Innodb_flush_method=O_DIRECT
最高性能:
innodb_flush_log_at_trx_commit=0
Innodb_flush_method=fsync

Guess you like

Origin www.cnblogs.com/klvchen/p/12305251.html