标签:数据 eal lru max 切换 byte home sql 0.12
1、数据库是一个写频繁的系统
2、后台写、写缓存
3、commit需要写入
4、写缓存失效或者写满-->写压力陡增-->写占读的带宽
1、BBU失效
2、写入突然增加、cache满
5、日志写入、脏缓冲区写入
[root@localhost mydata]# iostat -x Linux 2.6.32-642.el6.x86_64 (localhost.chinaitsoft.com) 07/05/2017 _x86_64_ (8 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.00 0.00 0.03 0.00 0.00 99.97 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await r_await w_await svctm %util scd0 0.00 0.00 0.00 0.00 0.01 0.00 7.72 0.00 1.25 1.25 0.00 1.25 0.00 sdc 0.02 0.00 0.01 0.00 0.07 0.00 7.93 0.00 0.89 0.89 0.00 0.72 0.00 sda 0.18 0.13 0.13 0.05 5.38 1.43 37.95 0.00 6.63 3.99 13.77 2.23 0.04 sdb 0.03 0.00 0.01 0.00 0.12 0.00 8.72 0.00 1.14 0.80 35.89 0.71 0.00
mysql> show global status like ‘%pend%‘; +------------------------------+-------+ | Variable_name | Value | +------------------------------+-------+ | Innodb_data_pending_fsyncs | 0 | #被挂起的fsync | Innodb_data_pending_reads | 0 | #被挂起的物理读 | Innodb_data_pending_writes | 0 | #被挂起的写 | Innodb_os_log_pending_fsyncs | 0 | #被挂起的日志fsync | Innodb_os_log_pending_writes | 0 | #被挂起的日志写 +------------------------------+-------+ 5 rows in set (0.01 sec)
mysql> show global status like ‘%log%written‘; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | Innodb_os_log_written | 5120 | +-----------------------+-------+ 1 row in set (0.01 sec)
mysql> show global status like ‘%a%written‘; +----------------------------+---------+ | Variable_name | Value | +----------------------------+---------+ | Innodb_data_written | 1073152 | #目前为止写的总的数据量,单位字节 | Innodb_dblwr_pages_written | 7 | | Innodb_pages_written | 58 | #写数据页的数量 +----------------------------+---------+ 3 rows in set (0.01 sec)
mysql> show global status like ‘%dblwr%‘; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Innodb_dblwr_pages_written | 7 | #已经写入到doublewrite buffer的页的数量 | Innodb_dblwr_writes | 3 | #doublewrite写的次数 +----------------------------+-------+ 2 rows in set (0.00 sec)
mysql> show global status like ‘%dirty%‘; +--------------------------------+-------+ | Variable_name | Value | +--------------------------------+-------+ | Innodb_buffer_pool_pages_dirty | 0 | #当前buffer pool中脏页的数量 | Innodb_buffer_pool_bytes_dirty | 0 | #当前buffer pool中脏页的总字节数 +--------------------------------+-------+ 2 rows in set (0.01 sec) mysql> show global status like ‘i%total%‘; +--------------------------------+-------+ | Variable_name | Value | +--------------------------------+-------+ | Innodb_buffer_pool_pages_total | 8192 | #buffer pool中数据页总量 +--------------------------------+-------+ 1 row in set (0.01 sec)
mysql> show global status like ‘%t_free‘; +------------------------------+-------+ | Variable_name | Value | +------------------------------+-------+ | Innodb_buffer_pool_wait_free | 0 | +------------------------------+-------+ 1 row in set (0.01 sec) mysql> show global status like ‘%g_waits‘; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | Innodb_log_waits | 0 | +------------------+-------+ 1 row in set (0.00 sec)
mysql> show global status like ‘i%rows%‘; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Innodb_rows_deleted | 0 | | Innodb_rows_inserted | 145 | | Innodb_rows_read | 233 | | Innodb_rows_updated | 5 | +----------------------+-------+ 4 rows in set (0.01 sec) mysql> show global status like ‘%commit%‘; +----------------+-------+ | Variable_name | Value | +----------------+-------+ | Com_commit | 0 | | Com_xa_commit | 0 | | Handler_commit | 16 | +----------------+-------+ 3 rows in set (0.01 sec) mysql> show global status like ‘%rollback%‘; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Com_rollback | 0 | | Com_rollback_to_savepoint | 0 | | Com_xa_rollback | 0 | | Handler_rollback | 0 | | Handler_savepoint_rollback | 0 | +----------------------------+-------+ 5 rows in set (0.01 sec)
mysql> show variables like ‘i%depth%‘; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | innodb_lru_scan_depth | 1024 | +-----------------------+-------+ 1 row in set (0.01 sec)
mysql> show variables like ‘%io_c%‘; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | innodb_io_capacity | 200 | | innodb_io_capacity_max | 2000 | +------------------------+-------+ 2 rows in set (0.00 sec)
mysql> show variables like ‘innodb_log%‘; +-----------------------------+----------+ | Variable_name | Value | +-----------------------------+----------+ | innodb_log_buffer_size | 16777216 | | innodb_log_checksums | ON | #解决数据在io环节的出错问题,checksum值检查 | innodb_log_compressed_pages | ON | | innodb_log_file_size | 50331648 | | innodb_log_files_in_group | 2 | | innodb_log_group_home_dir | ./ | | innodb_log_write_ahead_size | 8192 | +-----------------------------+----------+ 7 rows in set (0.01 sec)
mysql> show variables like ‘%flush%commit‘; +--------------------------------+-------+ | Variable_name | Value | +--------------------------------+-------+ | innodb_flush_log_at_trx_commit | 1 | +--------------------------------+-------+ 1 row in set (0.00 sec)
关于redolog的刷盘策略:也就是用户在commit,事务提交时,处理redolog的方式(0、1、2):0:当提交事务时,并不将事务的redo log写入logfile中,而是等待master thread每秒的刷新redo log。(数据库崩溃丢失数据,丢一秒钟的事务)
1:执行commit时将redo log同步写到磁盘logfile中,即伴有fsync的调用(默认是1,保证不丢失事务)
2:在每个提交,日志缓冲被写到文件系统缓存,但不是写到磁盘的刷新(数据库宕机而操作系统及服务器并没有宕机,当恢复时能保证数据不丢失;但是文件系统(OS)崩溃会丢失数据)
mysql> show variables like ‘innodb_flush_log_at_timeout‘; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | innodb_flush_log_at_timeout | 1 | +-----------------------------+-------+ 1 row in set (0.01 sec)
mysql> show variables like ‘%dirty%pct%‘; +--------------------------------+-----------+ | Variable_name | Value | +--------------------------------+-----------+ | innodb_max_dirty_pages_pct | 75.000000 | #脏页在buffer pool中的最大占比 | innodb_max_dirty_pages_pct_lwm | 0.000000 | +--------------------------------+-----------+ 2 rows in set (0.01 sec)
在内存buffer pool空间允许的范围下,可以调大脏页允许在内存空间的占比,可解燃眉之急,降低写压力。
mysql> show variables like ‘%doub%‘; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | innodb_doublewrite | ON | +--------------------+-------+ 1 row in set (0.01 sec)
标签:数据 eal lru max 切换 byte home sql 0.12
原文地址:http://www.cnblogs.com/geaozhang/p/7392056.html