【MySQL】Tokudb安装测试初探

  1. 云栖社区>
  2. 博客>
  3. 正文

【MySQL】Tokudb安装测试初探

yangyi_dba 2016-08-23 00:22:24 浏览637
展开阅读全文
一 前言
   TokuDB 是一个高性能、支持MVCC的MySQL 和 MariaDB 的存储引擎。TokuDB 的主要特点是数据压缩功能出色,对高写压力的支持,由美国TokuTek公司(http://www.tokutek.com/) 研发,该公司于2015年4月份被Percona收购,理所当然地提供了TokuDB版本的Percona Server。本文使用Peronca server 5.6.30 版本进行测试安装。
二 安装前的准备
    请参考官方文档 Percona Server YUM源Percona Server tokudb安装文档
三 安装步骤
3.1 关闭系统的大页
  1. echo never > /sys/kernel/mm/transparent_hugepage/enabled
  2. echo never > /sys/kernel/mm/transparent_hugepage/defrag
  3. echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
  4. echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
3.2 禁用SELINUX
root@rac2:~# >vim /etc/selinux/config 设置SELINUX=disabled
root@rac2:~# >setenforce 0
root@rac2:~# >getenforce
3.3 利用percona 的yum 源进行安装
  1. yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
  2. yum list | grep percona #检查yum源里面是否有 tokudb相关的rpm包
  3. yum install Percona-Server-tokudb-56.x86_64 -y
3.4 初始化数据库实例并启动数据库
  1. /usr/bin/mysql_install_db --user=mysql --datadir=/srv/my3306/data --basedir=/usr/ --defaults-file=/srv/my3306/my.cnf &
  2. /usr/bin/mysqld_safe --defaults-file=/srv/my3306/my.cnf --user=mysql &
3.5 使用ps_tokudb_admin安装tokudb 存储引擎 ,记得实例必须是启动状态的。
  1. root@rac2:/srv/my3306/data# >ps_tokudb_admin --enable -uroot -h127.0.0.1 -P 3306
  2. Checking SELinux status...
  3. INFO: SELinux is in permissive mode.
  4. Checking if Percona Server is running with jemalloc enabled...
  5. INFO: Percona Server is running with jemalloc enabled.
  6. Checking transparent huge pages status on the system...
  7. INFO: Transparent huge pages are currently disabled on the system.
  8. Checking if thp-setting=never option is already set in config file...
  9. INFO: Option thp-setting=never is not set in the config file.
  10.       (needed only if THP is not disabled permanently on the system)
  11. Checking TokuDB engine plugin status...
  12. INFO: TokuDB engine plugin is not installed.
  13. Adding thp-setting=never option into /etc/my.cnf
  14. INFO: Successfully added thp-setting=never option into /etc/my.cnf
  15. Installing TokuDB engine...
  16. INFO: Successfully installed TokuDB engine plugin. --> 说明Tokudb 存储引擎插件安装成功
3.6 登陆实例进行检查
  1. root@rac2:/srv/my3306/data# >my 3306
  2. Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
  3. mysql> show engines;
  4. +---------+---------+--------------------------------------------------------------+--------------+------+------------+
  5. | Engine | Support | Comment | Transactions | XA | Savepoints
  6. +---------+---------+--------------------------------------------------------------+--------------+------+------------+
  7. | TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology| YES | YES | YES |
  8. +---------+---------+---------------------------------------------------------------+-------------+------+------------+
  9. 10 rows in set (0.02 sec)
  10. mysql> SELECT @@tokudb_version;
  11. +------------------+
  12. | @@tokudb_version |
  13. +------------------+
  14. | 5.6.31-77.0 |
  15. +------------------+
  16. 1 row in set (0.00 sec)
四 测试
4.1 压缩比例
 
创建innodb 和tokudb存储引擎的表,测试插入 和文件大小。
  1. mysql> create table t_tokudb (id int,val varchar(256)) engine=tokudb default charset utf8;
  2. Query OK, 0 rows affected (0.05 sec)
  3. mysql> insert into t_tokudb(val) select val from t_tokudb;
  4. Query OK, 262144 rows affected (2.32 sec)
  5. Records: 262144 Duplicates: 0 Warnings: 0
  6. mysql> CREATE TABLE `t_innodb` (
  7.     -> `id` int(11) DEFAULT NULL,
  8.     -> `val` varchar(256) DEFAULT NULL
  9.     -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  10. Query OK, 0 rows affected (0.13 sec)
  11. mysql> insert into t_innodb select * from t_tokudb;
  12. Query OK, 1048576 rows affected (10.40 sec)
  13. Records: 1048576 Duplicates: 0 Warnings: 0
查看innodb 表和tokudb 表的大小
root@rac2:/srv/my3306/data# >du -sm _yang_t_tokudb_main_5_2_1d.tokudb
8 _yang_t_tokudb_main_5_2_1d.tokudb
root@rac2:/srv/my3306/data/yang# >du -sm t_innodb.ibd
149 t_innodb.ibd
root@rac2:/srv/my3306/data/yang# >
innodb 149M
tokudb 8M
压缩比达到惊人的 149/8 = 18:1. 因为测试例子中val 的值都是相同的,生产环境中val值不相同的会比较多,压缩比会有所减小。
4.2  存储引擎转换
  1. mysql> show create table t1 \G
  2. *************************** 1. row ***************************
  3.        Table: t1
  4. Create Table: CREATE TABLE `t1` (
  5.   `id` int(10) NOT NULL AUTO_INCREMENT,
  6.   `val` varchar(10) DEFAULT NULL,
  7.   PRIMARY KEY (`id`)
  8. ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
  9. 1 row in set (0.01 sec)

  10. mysql> alter table t1 engine=tokudb;
  11. Query OK, 4 rows affected (0.25 sec)
  12. Records: 4 Duplicates: 0 Warnings: 0
4.3 online ddl 测试
  1. mysql> alter table t_tokudb add name varchar(30) default 'a';
  2. Query OK, 0 rows affected (0.06 sec)
  3. Records: 0 Duplicates: 0 Warnings: 0
  4. mysql> alter table t_tokudb add key idx_a(name);
    Query OK, 0 rows affected (4.79 sec)
    Records: 0  Duplicates: 0  Warnings: 0
  5. mysql> alter table t_tokudb drop key idx_a;
    Query OK, 0 rows affected (0.57 sec)
    Records: 0  Duplicates: 0  Warnings: 0
 



















 

 


网友评论

登录后评论
0/500
评论
yangyi_dba
+ 关注