Innodb相关的一些有用的参数
今天就写写innodb相关的一些参数吧,如下:
首先是查看innodb的版本:
mysql 20:55:04>>show variables like '%innodb_version%';
+----------------+-----------+
| Variable_name | Value |
+----------------+-----------+
| innodb_version | 5.7.16-10 |
+----------------+-----------+
1 row in set (0.01 sec)
innodb中读写IO的线程个数:
mysql 20:55:19>>show variables like '%innodb_%io_thread%';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| innodb_read_io_threads | 4 |
| innodb_write_io_threads | 4 |
+-------------------------+-------+
2 rows in set (0.00 sec)
innodb中用于回收undo页的purge线程个数:
mysql 20:58:12>>show variables like '%innodb_purge_thread%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| innodb_purge_threads | 4 |
+----------------------+-------+
1 row in set (0.00 sec)
innodb中的buffer_pool的大小
mysql 20:59:38>>show variables like '%innodb_buffer_pool_size%';
+-------------------------+------------+
| Variable_name | Value |
+-------------------------+------------+
| innodb_buffer_pool_size | 1073741824 |
+-------------------------+------------+
1 row in set (0.00 sec)
innodb中缓冲池的个数:
mysql 21:00:48>>show variables like '%innodb_buffer_pool_instance%';
+------------------------------+-------+
| Variable_name | Value |
+------------------------------+-------+
| innodb_buffer_pool_instances | 8 |
+------------------------------+-------+
1 row in set (0.01 sec)
观察各个缓冲池的状态的sql语法:
mysql 21:03:42>>select pool_id,pool_size,free_buffers,database_pages from information_schema.innodb_buffer_pool_stats;
+---------+-----------+--------------+----------------+
| pool_id | pool_size | free_buffers | database_pages |
+---------+-----------+--------------+----------------+
| 0 | 8191 | 7165 | 994 |
| 1 | 8191 | 7327 | 827 |
| 2 | 8191 | 7222 | 937 |
| 3 | 8191 | 7126 | 1030 |
| 4 | 8191 | 7114 | 1042 |
| 5 | 8191 | 7204 | 955 |
| 6 | 8191 | 7141 | 1015 |
| 7 | 8191 | 7211 | 948 |
+---------+-----------+--------------+----------------+
8 rows in set (0.00 sec)
查看innodb缓冲池中的LRU队列的中间点位置:
mysql 21:06:14>>show variables like '%innodb_old_blocks_pct%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_old_blocks_pct | 37 |
+-----------------------+-------+
1 row in set (0.00 sec)
需要注意的是,这里的37是指37%的意思,也就是LRU列表的3/8处。
innodb中的redo log 缓冲:
mysql 21:06:24>>show variables like '%innodb_log_buffer_size%'; +------------------------+----------+
| Variable_name | Value |
+------------------------+----------+
| innodb_log_buffer_size | 16777216 |
+------------------------+----------+
1 row in set (0.01 sec)
这个值一般设置为8M或者16M,我们只需要保证每秒产生的事务量在这个大小之内即可,因为每一秒种innodb会将重做日志缓冲刷新到日志文件中。
LRU列表中可用数据页的默认数量参数:
mysql 21:08:20>>show variables like '%innodb_lru_scan_depth%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_lru_scan_depth | 1000 |
+-----------------------+-------+
1 row in set (0.00 sec)
当LRU列表中的数据页小于这个数量的时候,innodb会将LRU列表尾部的数据页移除
缓冲池中脏页所占用的百分比参数:
mysql 21:14:51>>show variables like '%innodb_max_dirty_pages_pct';
+----------------------------+-----------+
| Variable_name | Value |
+----------------------------+-----------+
| innodb_max_dirty_pages_pct | 75.000000 |
+----------------------------+-----------+
1 row in set (0.00 sec)
一旦脏页所占用的百分比大于这个数值,innodb将立即对缓冲池进行刷新到磁盘的操作。