系统:Red Hat Enterprise Linux Server release 6.3 (Santiago)
数据库:Percona-Server-5.6.29-rel76.2-Linux.x86_64.ssl101.tar.gz
1. 准备
libjemalloc library
安装 jemalloc,确保 jemalloc 的版本在3.3.0 或者更高。通过yum或者rpm包安装的MySQL5.6 需要额外安装 Percona-Server-tokudb-56-5.6.36-rel82.1.el6.x86_64.rpm 包,安装过程中会自动装上 jemalloc,但是通过 Percona-Server-5.6.29-rel76.2-Linux.x86_64.ssl101.tar.gz 安装的MySQL就方便的多。
在 $MYSQL_HOME/lib/mysql/ 下有 jemalloc
[mysql@dbmspressd201 ~]$ ll lib/mysql/
total 1856
lrwxrwxrwx 1 mysql mysql 16 Aug 11 17:07 libjemalloc.so -> libjemalloc.so.1
-rwxr-xr-x 1 mysql mysql 1893761 Aug 11 17:07 libjemalloc.so.1
drwxr-xr-x 3 mysql mysql 4096 Aug 11 17:07 plugin
直接修改 my.cnf 文件即可
[mysqld_safe]
malloc-lib=/home/mysql/lib/mysql/libjemalloc.so.1
配置完成后,需要重启数据库
$ /home/mysql/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf &
[1] 2587
$ 170813 17:06:00 mysqld_safe Adding '/home/mysql/lib/mysql/libjemalloc.so.1' to LD_PRELOAD for mysqld
170813 17:06:00 mysqld_safe Logging to '/mysql/data/mysql_error.err'.
170813 17:06:00 mysqld_safe Starting mysqld daemon with databases from /mysql/data/
Transparent huge pages
transparent huge pages 打开的时候,TokuDB是无法使用的
cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
always [never]
需要用 root 权限执行以下操作,来关闭 transparent huge page
[root@dbmspressd201 ~]# echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
[root@dbmspressd201 ~]# echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
不关闭的话,报错日志如下
2017-08-13 17:06:04 3577 [ERROR] TokuDB: Huge pages are enabled, disable them before continuing
2017-08-13 17:06:04 3577 [ERROR] ************************************************************
2017-08-13 17:06:04 3577 [ERROR]
2017-08-13 17:06:04 3577 [ERROR] @@@@@@@@@@@
2017-08-13 17:06:04 3577 [ERROR] @@' '@@
2017-08-13 17:06:04 3577 [ERROR] @@ _ _ @@
2017-08-13 17:06:04 3577 [ERROR] | (.) (.) |
2017-08-13 17:06:04 3577 [ERROR] | ` |
2017-08-13 17:06:04 3577 [ERROR] | > ' |
2017-08-13 17:06:04 3577 [ERROR] | .----. |
2017-08-13 17:06:04 3577 [ERROR] .. |.----.| ..
2017-08-13 17:06:04 3577 [ERROR] .. ' ' ..
2017-08-13 17:06:04 3577 [ERROR] .._______,.
2017-08-13 17:06:04 3577 [ERROR]
2017-08-13 17:06:04 3577 [ERROR] TokuDB will not run with transparent huge pages enabled.
2017-08-13 17:06:04 3577 [ERROR] Please disable them to continue.
2017-08-13 17:06:04 3577 [ERROR] (echo never > /sys/kernel/mm/transparent_hugepage/enabled)
2017-08-13 17:06:04 3577 [ERROR]
2017-08-13 17:06:04 3577 [ERROR] ************************************************************
2017-08-13 17:06:04 3577 [ERROR] Plugin 'TokuDB' init function returned error.
2017-08-13 17:06:04 3577 [ERROR] Plugin 'TokuDB' registration as a STORAGE ENGINE failed.
2017-08-13 17:06:04 3577 [Note] Shutting down plugin 'TokuDB'
2. 安装
2.1 通过yum安装
yum install Percona-Server-tokudb-56.x86_64
2.2 直接启用TokuDB
使用 $MYSQL_HOME/bin 下的 ps_tokudb_admin 安装(5.6.22-72.0后引入)
./ps_tokudb_admin --enable -uroot -h127.1
Checking SELinux status...
INFO: SELinux is disabled.
Checking if Percona Server is running with jemalloc enabled...
INFO: Percona Server is running with jemalloc enabled.
Checking transparent huge pages status on the system...
INFO: Transparent huge pages are currently disabled on the system.
Checking if thp-setting=never option is already set in config file...
INFO: Option thp-setting=never is set in the config file.
Checking TokuDB engine plugin status...
INFO: TokuDB engine plugin is not installed.
Installing TokuDB engine...
INFO: Successfully installed TokuDB engine plugin.
5.6.29的安装与官网的安装结果显示的稍有不同,以下贴出官网的结果
Checking if Percona server is running with jemalloc enabled...
>> Percona server is running with jemalloc enabled.
Checking transparent huge pages status on the system...
>> Transparent huge pages are currently disabled on the system.
Checking if thp-setting=never option is already set in config file...
>> Option thp-setting=never is not set in the config file.
>> (needed only if THP is not disabled permanently on the system)
Checking TokuDB plugin status...
>> TokuDB plugin is not installed.
Adding thp-setting=never option into /etc/mysql/my.cnf
>> Successfuly added thp-setting=never option into /etc/mysql/my.cnf
Installing TokuDB engine...
>> Successfuly installed TokuDB plugin.
查看安装结果
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
查看 TokuDB 的版本
mysql> SELECT @@tokudb_version;
+------------------+
| @@tokudb_version |
+------------------+
| 5.6.29-76.2 |
+------------------+
1 row in set (0.00 sec)
手动安装
Percona Server 5.6.22-71.0 的时候。。。可以手动安装。。。木有测试过。。。
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';
INSTALL PLUGIN tokudb_background_job_status SONAME 'ha_tokudb.so'