对于mysql5.1.38之后的版本,要使用新的InnoDB Plugin存储引擎,只需在my.cnf中做如下配置:
[mysqld]
ignore-builtin-innodb
plugin-load=innodb=ha_innodb_plugin.so
plugin-load=innodb_trx=ha_innodb_plugin.so
plugin-load=innodb_locks=ha_innodb_plugin.so
plugin-load=innodb_cmp=ha_innodb_plugin.so
plugin-load=innodb_cmp_reset=ha_innodb_plugin.so
plugin-load=innodb_cmpmem=ha_innodb_plugin.so
plugin-load=innodb_cmpmem_reset=ha_innodb_plugin.so
或是在命令行下加载
mysql>install plugin innodb soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_trx soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_locks soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmp soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmp_reset soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmpmem soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmpmem_reset soname ‘ha_innodb_plugin.so’;
要想完成动态加载innodb plugin是有条件的:
1. 使用源码编译的,默认innobase没有被编译进来;使用二进制包安装的,在启动前,在my.cnf里面加入skip-innodb或是ignore_builtin_innodb。
2. 使用源码编译时,不能使用–with-mysqld-ldflags=-all-static选项,以静态方式编译库,当show global variables like ‘have_%’;的时候,输出有一项是have_dynamic_loading将是NO,这就决定mysql是否支持动态加载plugin;而二进制包安装的mysql,就是动态编译的,支持动态加载plugin,这项为Yes。
SHOW ENGINES;
SHOW PLUGINS;
mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)
mysql> show plugins;
+---------------------+--------+--------------------+---------------------+---------+
| Name | Status | Type | Library | License |
+---------------------+--------+--------------------+---------------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | ha_innodb_plugin.so | GPL |
| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
+---------------------+--------+--------------------+---------------------+---------+
15 rows in set (0.00 sec)
[mysqld]
ignore-builtin-innodb
plugin-load=innodb=ha_innodb_plugin.so
plugin-load=innodb_trx=ha_innodb_plugin.so
plugin-load=innodb_locks=ha_innodb_plugin.so
plugin-load=innodb_cmp=ha_innodb_plugin.so
plugin-load=innodb_cmp_reset=ha_innodb_plugin.so
plugin-load=innodb_cmpmem=ha_innodb_plugin.so
plugin-load=innodb_cmpmem_reset=ha_innodb_plugin.so
或是在命令行下加载
mysql>install plugin innodb soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_trx soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_locks soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmp soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmp_reset soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmpmem soname ‘ha_innodb_plugin.so’;
mysql>install plugin innodb_cmpmem_reset soname ‘ha_innodb_plugin.so’;
要想完成动态加载innodb plugin是有条件的:
1. 使用源码编译的,默认innobase没有被编译进来;使用二进制包安装的,在启动前,在my.cnf里面加入skip-innodb或是ignore_builtin_innodb。
2. 使用源码编译时,不能使用–with-mysqld-ldflags=-all-static选项,以静态方式编译库,当show global variables like ‘have_%’;的时候,输出有一项是have_dynamic_loading将是NO,这就决定mysql是否支持动态加载plugin;而二进制包安装的mysql,就是动态编译的,支持动态加载plugin,这项为Yes。
SHOW ENGINES;
SHOW PLUGINS;
mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)
mysql> show plugins;
+---------------------+--------+--------------------+---------------------+---------+
| Name | Status | Type | Library | License |
+---------------------+--------+--------------------+---------------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | ha_innodb_plugin.so | GPL |
| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL |
+---------------------+--------+--------------------+---------------------+---------+
15 rows in set (0.00 sec)