当前位置: 首页 > 工具软件 > TokuDB > 使用案例 >

mysql tokudb引擎_在MYSQL上添加TokuDB引擎

盖斌
2023-12-01

TokuDB引擎说明:TokuDB 的主要特点是高压缩比,高 INSERT 性能,支持大多数在线修改索引、添加字段,非常适合日志型应用场景(只有insert,select,少update);

一、安装步骤

1. 解压tokudb的包

tar -zxf    Percona-Server-5.6.22-rel72.0-738.TokuDB.Linux.x86_64.tar.gz

2. 解压后,目录如下:

[root@localhost Percona-Server-5.6.22-rel72.0-738.Linux.x86_64]# ls

bin  lib  mysql-test  README-TOKUDB

注:添加配置文件如下:

配置文件

[mysqld_safe]

malloc-lib= /usr/local/mysql/lib/mysql/libjemalloc.so

plugin-dir = /usr/local/mysql/lib/mysql/plugin/

plugin-load=ha_tokudb.so

3. 把相关目录放到BASEDIR下

cp -r Percona-Server-5.6.22-rel72.0-738.Linux.x86_64/* /usr/local/mysql/

4. 启动之前,停用transparent huge pages(启动之前,停用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

5. 启动数据库

6. 检查未添加结果

show engines;

mysql>     show engines;

+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |

+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

| MyISAM             | YES     | MyISAM storage engine                                          | 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         |

| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |

| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |

|InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |

| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |

+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

9 rows in set (0.00 sec)

mysql>  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     |

| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL    | GPL     |

| InnoDB                     | ACTIVE   | STORAGE ENGINE     | 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     |

| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

| partition                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |

+----------------------------+----------+--------------------+---------+---------+

42 rows in set (0.00 sec)

mysql>

7. 手动添加plugin

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’;

root@hostname:/data/tokuDB/bin#./ps_tokudb_admin --enable --user=root--password=123456 --socket=/data/data20170414/mysql33010.sock --host=192.168.1.111

--port=33010 --defaults-file=/data/data20170414/backup-my.cnf

ps_tokudb_admin: unrecognized option '--defaults-file=/data/data20170414/backup-my.cnf'

root@hostname:/data/tokuDB/bin#./ps_tokudb_admin --enable --user=root--password=123456 --socket=/data/data20170414/mysql33010.sock --host=192.168.1.111 --port=33010

Checking if Percona server is running with jemalloc enabled...

>> Percona server is not running with jemalloc, please restart server to enable it and then run this script...

需要安装:

缺包,先安装

# yum install epel-release

然后就可以安装jemalloc了:

# yum install jemalloc

1).jemalloc的下载:

http://www.canonware.com/download/jemalloc/

使用最近版本的jemalloc:

http://www.canonware.com/download/jemalloc/jemalloc-3.5.0.tar.bz2

~$ wget

http://www.canonware.com/download/jemalloc/jemalloc-3.5.0.tar.bz2

2).解压下载下来的tar包

~$ tar jxvf jemalloc-3.5.0.tar.bz2

3).安装jemalloc shell:

~$ ./configure --prefix=/usr/local

~$ make

~$ sudo make install

RPM安装jemalloc

8. 检查添加结果

show engines;

show plugins;

 类似资料: