- 论坛徽章:
- 0
|
mysql:innodb引擎部分参数性能调整
InnoDB做为MySQL目前最广泛的事务存储引擎,很多地方的设计和Oracle都是共通的。
下面是windows上一个MySQL默认的参数查询结果:
mysql> show variables like 'Innodb%';
+---------------------------------+------------------------+
| Variable_name | Value |
+---------------------------------+------------------------+
| innodb_additional_mem_pool_size | 2097152 |
| innodb_autoextend_increment | 8 |
| innodb_buffer_pool_awe_mem_mb | 0 |
| innodb_buffer_pool_size | 8388608 |
| innodb_checksums | ON |
| innodb_commit_concurrency | 0 |
| innodb_concurrency_tickets | 500 |
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir | |
| innodb_doublewrite | ON |
| innodb_fast_shutdown | 1 |
| innodb_file_io_threads | 4 |
| innodb_file_per_table | OFF |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_flush_method | |
| innodb_force_recovery | 0 |
| innodb_lock_wait_timeout | 50 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_arch_dir | |
| innodb_log_archive | OFF |
| innodb_log_buffer_size | 1048576 |
| innodb_log_file_size | 10485760 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | .\ |
| innodb_max_dirty_pages_pct | 90 |
| innodb_max_purge_lag | 0 |
| innodb_mirrored_log_groups | 1 |
| innodb_open_files | 300 |
| innodb_rollback_on_timeout | OFF |
| innodb_support_xa | ON |
| innodb_sync_spin_loops | 20 |
| innodb_table_locks | ON |
| innodb_thread_concurrency | 8 |
| innodb_thread_sleep_delay | 10000 |
+---------------------------------+------------------------+
innodb_additional_mem_pool_size
用于缓存InnoDB数据字典及其他内部结构的内存池大小,类似于Oracle的library cache。这不是一个强制参数,可以被突破。
innodb_buffer_pool_size
内存缓冲池大小,用于缓存表和索引数据等。类似于Oracle的buffer cache,如果可能,尽可能的设置大一点。
innodb_log_buffer_size
日志缓冲区大小,类似于Oracle的log buffer
innodb_log_file_size
日志文件大小。默认会创建2个5M大小的名为ib_logfile0和ib_logfile1的文件。日志文件的数目由参数innodb_log_files_in_group指定。存放位置由innodb_log_group_home_dir指定。
innodb_data_file_path
指定InnoDB表空间数据文件名,大小以及其他属性。所有文件的加起来不能少于10M。多个数据文件之间以逗号分割,属性之间以冒号分割。默认创建一个大小10MB名为ibdata1的可自动扩展的数据文件,一般在生产环境中都需要根据实际情况指定,由于往表空间中添加数据文件需要停机,尽量在规划的时候做好准备,如果可以的话最好开启最后一个数据文件的自动增长属性。数据文件的个数在规划的时候还需要考虑另外一个innodb_open_files参数。
innodb_file_per_table
取值为ON或者OFF。是否为每个table使用单独的数据文件保存。如果系统中表的个数不多,并且没有超大表,使用该参数可以使得各个表之间的维护相对独立,有一定的好处。
innodb_autoextend_increment
当自动扩展表空间被填满之时,每次扩展空间的大小,默认值是8(单位MB)。该参数可以动态修改:
mysql> set global innodb_autoextend_increment=10;
Query OK, 0 rows affected (0.01 sec)
innodb_status_file
定期将show inndb status的结果输出保存到文件中,建议开启以便分析性能。
2007 12:53] mike mike
Description:
The variable "innodb_autoextend_increment" does not seem to report the proper value. The
top value it will display is 1000; I assume that is bytes.
From the manual:
"The increment is 8MB at a time by default. It can be modified by changing the
innodb_autoextend_increment system variable."
I have it set in my my.cnf for 128M (assuming it will grow on demand by 128 meg chunks) -
however, I noticed that my database wasn't growing that large, it was always idling around
4,096KB free.
How to repeat:
Here is my configuration:
+---------------------------------+-------------------------+
| Variable_name | Value |
+---------------------------------+-------------------------+
| have_innodb | YES |
| innodb_additional_mem_pool_size | 33554432 |
| innodb_autoextend_increment | 1000 |
| innodb_buffer_pool_awe_mem_mb | 0 |
| innodb_buffer_pool_size | 536870912 |
| innodb_checksums | ON |
| innodb_commit_concurrency | 0 |
| innodb_concurrency_tickets | 500 |
| innodb_data_file_path | ibdata:1024M:autoextend |
| innodb_data_home_dir | /var/lib/mysql/ |
| innodb_doublewrite | ON |
| innodb_fast_shutdown | 1 |
| innodb_file_io_threads | 4 |
| innodb_file_per_table | ON |
| innodb_flush_log_at_trx_commit | 0 |
| innodb_flush_method | |
| innodb_force_recovery | 0 |
| innodb_lock_wait_timeout | 50 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_arch_dir | |
| innodb_log_archive | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_max_dirty_pages_pct | 90 |
| innodb_max_purge_lag | 0 |
| innodb_mirrored_log_groups | 1 |
| innodb_open_files | 300 |
| innodb_support_xa | ON |
| innodb_sync_spin_loops | 20 |
| innodb_table_locks | ON |
| innodb_thread_concurrency | 2 |
| innodb_thread_sleep_delay | 10000 |
+---------------------------------+-------------------------+
Easy to repeat:
mysql> show variables like 'innodb_autoextend_increment';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| innodb_autoextend_increment | 1000 |
+-----------------------------+-------+
1 row in set (0.00 sec)
mysql> SET GLOBAL innodb_autoextend_increment = 15;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_autoextend_increment';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| innodb_autoextend_increment | 15 |
+-----------------------------+-------+
1 row in set (0.00 sec)
mysql> SET GLOBAL innodb_autoextend_increment = 999999;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_autoextend_increment';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| innodb_autoextend_increment | 1000 |
+-----------------------------+-------+
1 row in set (0.00 sec)
mysql>
obviously if this has no effect in the CLI it has no effect from my.cnf.
Suggested fix:
People suggest using innodb_autoextend_increment=50M in multiple places around the net.
I've done that, but obviously can't confirm that it is working (at least from the
variable itself)
From what I can tell it does not work properly either (phpMyAdmin for example reports out
how many KB free the InnoDB engine/file has) - I definately think there is an issue with
the variable not reporting the right status; or perhaps the variable isn't working
itself. Unless there is some sort of conflicting mechanism when innodb_file_per_table is
used, then there should be something in the docs about it.
[8 Jan 2007 14:30] Heikki Tuuri
The manual says:
"
innodb_autoextend_increment
The increment size (in MB) for extending the size of an auto-extending tablespace when it
becomes full. The default value is 8.
"
Thus, 1000 corresponds to 1000 MB. The default is 8 MB.
[21 Jan 2007 6:32] mike mike
okay, so is 1000MB an invalid number? does it not accept "M" as a quantifier? as in 50M is
not 50, but will ignore that value?
if so, a LOT of people's examples around the net are incorrect. it should for sanity's
sake match the syntax for any other variable. |
|