安装TokuDB引擎
前言:TokuDB 是一个高性能、支持事务处理的 MySQL 和 MariaDB 的存储引擎。TokuDB 的主要特点是高压缩比,高 INSERT 性能,支持大多数在线修改索引、添加字段,非常适合日志型应用场景(只有insert,select,少update),下面就来看一下安装步骤
1.解压缩包
tar xvf Percona-Server-5.6.24-rel72.2-TokuDB.Linux.x86_64.ssl098e.tar.gz
cd Percona-Server-5.6.24-rel72.2-Linux.x86_64.ssl098e
cp -rpf * /opt/app/mysql/
2. 启动之前,停用transparent huge pages 如果不关闭可能会导致TokuDB内存泄露(建议写到 /etc/rc.local 中,重启仍然生效):
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
3.启动MySQL
/etc/init.d/mysql restart
4.安装插件
INSTALL PLUGIN tokudb SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_file_map SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_fractal_tree_info SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_trx SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_locks SONAME ’ha_tokudb.so’;
INSTALL PLUGIN tokudb_lock_waits SONAME ’ha_tokudb.so’;
5.查看安装结果
(twDB)root@localhost [(none)]> show plugins;
+-------------------------------+----------+--------------------+--------------+---------+
| Name | Status | Type | Library | License |
+-------------------------------+----------+--------------------+--------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| mysql_old_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL |
| XTRADB_READ_VIEW | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_INTERNAL_HASH_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_RSEG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_PER_INDEX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_PAGE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_PAGE_LRU | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_POOL_STATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_METRICS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_BEING_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_CONFIG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_INDEX_CACHE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_INDEX_TABLE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLESTATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_INDEXES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_COLUMNS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FIELDS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FOREIGN | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FOREIGN_COLS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLESPACES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_DATAFILES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CHANGED_PAGES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| TokuDB_file_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_info | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_block_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_trx | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_locks | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_lock_waits | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB | ACTIVE | STORAGE ENGINE | ha_tokudb.so | GPL |
+-------------------------------+----------+--------------------+--------------+---------+
53 rows in set (0.00 sec)
添加配置文件
[mysqld_safe]
malloc-lib= /opt/app/mysql/lib/mysql/libjemalloc.so
plugin-dir = /opt/app/mysql/lib/mysql/plugin/
plugin-load=ha_tokudb.so
[mysqld]
#tokudb
#把TokuDB datadir以及logdir和MySQL的datadir分开,也可以不分开,
tokudb-data-dir = /data/mysql/tokudbData
tokudb-log-dir = /data/mysql/tokudbLog
#TokuDB的行模式,建议用 FAST ,如果磁盘空间很紧张,建议用 SMALL
#tokudb_row_format = tokudb_small
tokudb_row_format = tokudb_fast
tokudb_cache_size = xxG ###建议内存的一半
tokudb_commit_sync = 0
tokudb_directio = 1
tokudb_read_block_size = 128K
tokudb_read_buf_size = 128K
questions
###############################
(twDB)root@localhost [sysbench]> INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';
ERROR 1123 (HY000): Can't initialize function 'tokudb'; Plugin initialization function failed.
(twDB)root@localhost [sysbench]> INSTALL PLUGIN ha_tokudb SONAME 'ha_tokudb.so';
ERROR 1127 (HY000): Can't find symbol 'ha_tokudb' in library
(twDB)root@localhost [sysbench]> INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';
ERROR 1123 (HY000): Can't initialize function 'tokudb'; Plugin initialization function failed.
(twDB)root@localhost [sysbench]>
出现这个是因为偷懒,只拷贝了Percona-Server-5.6.24-rel72.2-Linux.x86_64.ssl098e/bin lib目录到MySQL目录,解决方法就是拷贝全部文件过去,重新启动MySQL实例,再次安装就行