Percona Server 5.7.14下安装TokuDB存储引擎

Percona Server 5.7.14下安装TokuDB存储引擎
官方文档https://www.percona.com/doc/percona-server/5.7/tokudb/tokudb_installation.html

认识一下TokuDB相关的文件
file1: _test_t1_key_bc_90_3_1b.tokudb --索引(bc)文件
file2: _test_t1_main_90_2_1b.tokudb --主文件
file3: _test_t1_status_90_1_1b.tokudb --表元数据文件

tokudb.directory --表/索引文件信息
tokudb.environment --TokuDB版本号信息
tokudb.rollback --undo记录
log000000000001.tokulog27 --redo记录
__tokudb_lock_dont_delete_me_* --文件锁,保证同一个datadir只能被一个TokuDB进程使用

TokuDB与InnoDB相比有哪些优势?
高压缩,写入快,支持大多数在线修改索引,添加字段,适合像zabbix这种高写入,少更新的应用场景

禁用transparent_hugepage
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

修改my.cnf配置
#tokudb
malloc-lib= /usr/local/mysql/lib/mysql/libjemalloc.so
plugin-dir = /usr/local/mysql/lib/mysql/plugin
plugin-load=ha_tokudb.so

#把TokuDB datadir以及logdir和MySQL的datadir分开,美观点,也可以不分开,注释掉本行以及下面2行即可
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 = 44G

#TokuDB其他大部分配置其实可以不用修改的,只需要几个关键配置即可
tokudb_commit_sync = 0
tokudb_directio = 1
tokudb_read_block_size = 128K
tokudb_read_buf_size = 128K

[mysqld_safe]
malloc-lib=/usr/local/mysql/lib/mysql/libjemalloc.so.1

启动MySQL
/etc/init.d/mysqld start

验证
root@localhost [(none)]>show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| 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 |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)

root@localhost [(none)]>show variables like 'tokudb_version';
+----------------+----------+
| Variable_name | Value |
+----------------+----------+
| tokudb_version | 5.7.14-8 |
+----------------+----------+
1 row in set (0.01 sec)

insert性能测试
root@localhost [zabbix]>show create table t1\G
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=TokuDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 ROW_FORMAT=TOKUDB_QUICKLZ
1 row in set (0.00 sec)

root@localhost [zabbix]>show create table t2\G
*************************** 1. row ***************************
Table: t2
Create Table: CREATE TABLE `t2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

insert 10000条记录
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t1.sql

Enter password:

real 0m0.524s

[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t2.sql
Enter password:

real 0m1.362s

insert 100000条记录
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t1.sql
Enter password:

real 0m1.109s
user 0m0.072s
sys 0m0.081s
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t2.sql
Enter password:

real 0m3.069s

insert 100w条记录
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t1.sql
Enter password:

real 0m19.270s

[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t2.sql
Enter password:

real 0m20.723s

insert200w条记录
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t1.sql
Enter password:

real 1m18.243s
[root@localhost ~]# time mysql -S /tmp/mysql.sock -uroot -p zabbix < t1.sql
Enter password:

real 1m29.229s

insert200w条记录后数据大小比较
TokuDB: 20M Oct 8 19:43 _zabbix_t1_main_1027d_1_1d_B_0.tokudb
InnoDB: 88M Oct 8 19:45 t2.ibd

 

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇