mysql安装tokuDB

最近拿到了几个裤子比较大,用mysql自带的inndb储存太大,
而我自己的服务器也没有太多的硬盘,所以改用tokuDB进行储存.

1
本文基于宝塔一键创建的mysql5.6,CentOS 7.6

优势

高压缩比,高写入性能
在线创建索引和字段
支持事务
支持主从同步

安装tokudb

安装percona-server 源

如果服务器没有安装percona-server源,则进行安装
安装教程地址:https://www.percona.com/doc/percona-server/5.6/installation/yum_repo.html

1
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm

安装jemalloc依赖

tokuDB内存分配需要jemalloc支持,因此使用之前需要安装jemalloc

1
yum install -y jemalloc

关闭内存大页,如果不关闭可能会导致TokuDB内存泄露

1
2
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

然后打开/etc/my.cnf,添加下面代码
由于我之前安装了宝塔,所以我直接用宝塔的文件UI界面进行操作.

1
2
[mysql_safe]
malloc-lib=/usr/lib64/libjemalloc.so.1

重启服务器,启动mysql

1
2
reboot
systemctl start mysql

安装

1
yum install Percona-Server-tokudb-56.x86_64

最后启动服务,root为你的数据库用户名,passwod为你数据库的密码

1
ps_tokudb_admin --enable -uroot -ppassword -S /tmp/mysql.sock

得到输出入下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@VM-0-8-centos lighthouse]# ps_tokudb_admin --enable -uroot -ppassword -S /tmp/mysql.sock

Checking SELinux status...
INFO: SELinux is in permissive mode.

cat: mysql.pid: No such file or directory
Checking if Percona Server is running with jemalloc enabled...
WARNING: The file /proc//environ is not readable so impossible to check LD_PRELOAD for jemalloc.
Possibly running inside container so assuming jemalloc is preloaded and continuing...
If there will be an error during plugin installation try to restart mysql service and run this script again.

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.

进入mysql输入如下代码查看

1
show engines;

得到输出如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@localhost [(none)]>show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)

安装结束


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!