TokuDB 安装

简介: TokuDB是MySQL和MariaDB的开源、高性能存储引擎。它通过使用分形树索引来实现这一点。它是可伸缩的,ACID和MVCC兼容的,提供基于索引的查询改进,提供在线模式修改,并减少硬盘驱动器和闪存的从延迟。----来自维基百科

安装TokuDB:
0、关闭内存大页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

查看下
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]

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

rpm -qa |grep jemalloc
jemalloc-3.6.0-1.el7.x86_64

rpm -ql jemalloc-3.6.0-1.el7.x86_64
/usr/bin/jemalloc.sh
/usr/lib64/libjemalloc.so.1
/usr/share/doc/jemalloc-3.6.0
/usr/share/doc/jemalloc-3.6.0/COPYING
/usr/share/doc/jemalloc-3.6.0/README
/usr/share/doc/jemalloc-3.6.0/VERSION
/usr/share/doc/jemalloc-3.6.0/jemalloc.html

1、从percona官网下载
https://www.percona.com/downloads/Percona-Server-LATEST/

tar xf Percona-Server-5.7.21-21-Linux.x86_64.ssl101.tar.gz
mv Percona-Server-5.7.21-21-Linux.x86_64.ssl101 tokudb57
mkdir /home/work/data/mysql3504

2、初如化
/home/work/tokudb57/bin/mysqld --defaults-file=/home/work/data/my3504.conf --basedir=/home/work/tokudb57/ --user=work --initialize-insecure

--initialize-insecure 初如化MySQL是空密码

--defaults-file= 指定配置文件,最好放在前面,不要放在最后

3、配置文件my3306.conf
加入:
[mysqld_safe]
thp-setting=never
malloc-lib=/usr/lib64/libjemalloc.so.1

3、启动
chown -R work:work /home/work/data/mysql3306/

改密码:
set password=password('123456');

/home/work/tokudb57/bin/mysqld_safe --defaults-file=/home/work/data/mysql3306/my3306.conf --user=work &

4、安装TokuDB
cd /home/work/tokudb57/bin/
ps_tokudb_admin --enable -u'root' -p -S /home/work/tmp/mysql3306.sock

/home/work/tokudb57/bin/ps_tokudb_admin --enable --user=root --password='' --socket=/home/work/tmp/mysql3306.sock
Enter password:

WARNING: This script is deprecated and will be removed in 8.0. You can use ps-admin script which has more functionality.

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 not set in the config file.
(needed only if THP is not disabled permanently on the system)

Checking TokuDB engine plugin status...
INFO: TokuDB engine plugin is not installed.

Adding thp-setting=never option into /etc/my.cnf
INFO: Successfully added thp-setting=never option into /etc/my.cnf

Installing TokuDB engine...
INFO: Successfully installed TokuDB engine plugin.

(root@(none))>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 |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| 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)

此时InnoDB还是默认引擎 重启下server,并在my3306.conf [mysqld]添加如下配置:

------------- tokudb ---------------

default-storage-engine = TokuDB
tokudb_directio = on
tokudb_cache_size = 2G
tokudb_row_format = tokudb_lzma
tokudb_commit_sync = 0
tokudb_fsync_log_period = 1000

重启后TokuDB 就是默认存储引擎了
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 |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| TokuDB | DEFAULT | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| InnoDB | YES | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| 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)

错误:
一、 初始化错误
[ERROR] InnoDB: Expected to open 4 undo tablespaces but was able to find only 0 undo tablespaces.Set the innodb_undo_tablespaces parameter to the correct value and retry. Suggested value is 0

解决:
报错原因:
在初始化数据库的时候没有指定innodb_undo_tablespaces参数
解决方法:
在初始化数据库的时候写上--defaults-file参数,在对应的配置文件中写上对应的innodb_undo_tablespaces参数

/home/work/tokudb57/bin/mysqld --defaults-file=/home/work/data/my3504.conf --basedir=/home/work/tokudb57/ --user=work --initialize-insecure

二、tokudb安装:
root@dqd-stat-mysql-slave01.bj.uc:/home/work/data# ps_tokudb_admin --enable -u'root' -p'123456' -h 127.0.0.1 -P 3504
WARNING: This script is deprecated and will be removed in 8.0. You can use ps-admin script which has more functionality.

Checking SELinux status...
INFO: SELinux is disabled.

ERROR: Failed to list mysql plugins! Please check username, password and other options for connecting to server...

用户名和密码都是正常的

解决:
/home/work/tokudb57/bin/ps_tokudb_admin --enable --user=root --password='' --socket=/home/work/tmp/mysql3306.sock

三、 Percona Server 未启动

/home/work/tokudb57/bin/ps_tokudb_admin --enable --user=root --password='' --socket=/home/work/tmp/mysql3504.sock

WARNING: This script is deprecated and will be removed in 8.0. You can use ps-admin script which has more functionality.

Checking SELinux status...
INFO: SELinux is disabled.

cat: dqd-stat-mysql-slave01.bj.uc.pid: No such file or directory
Checking if Percona Server is running with jemalloc enabled...
grep: /proc//environ: No such file or directory
which: no mysqld in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/itools/python/bin/:/home/work/local/mysql/bin:/root/opt/bin/:/home/work/opbin/xtrabackup/bin:/home/work/nodejs/bin:/root/bin)
ldd: missing file arguments
Try `ldd --help' for more information.
ERROR: Percona Server is not running with jemalloc, please restart mysql service to enable it and then run this script...

搞了老错误,又来新错误, server是启动的

解决:
root@dqd-stat-mysql-slave01.bj.uc:/home/work/data# grep "Percona Server is not running" /home/work/tokudb57/bin/ps_tokudb_admin
printf "ERROR: Percona Server is not running with jemalloc, please restart mysql service to enable it and then run this script...\n\n";
printf "ERROR: Percona Server is not running with libHotBackup.so preloaded, please restart mysql service to enable it and then run this script again...\n\n";

vim /home/work/tokudb57/bin/ps_tokudb_admin
if [ $ENABLE_TOKUBACKUP = 1 ]; then
printf "Checking if Percona Server is running with libHotBackup.so preloaded...\n"
LIBHOTBACKUP_STATUS=$(grep -c libHotBackup.so /proc/${PID_NUM}/environ)
if [ $LIBHOTBACKUP_STATUS = 0 ]; then
printf "ERROR: Percona Server is not running with libHotBackup.so preloaded, please restart mysql service to enable it and then run this script again...\n\n";
exit 1
else
printf "INFO: Percona Server is running with libHotBackup.so preloaded.\n\n";
fi
fi

打开脚本和pid 有关 ,那就回一个pid

root@dqd-stat-mysql-slave01.bj.uc:/home/work/data# grep "pid" /home/work/data/mysql3306/my3306.conf
pid-file = /home/work/tmp/mysql.pid

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
Java 编译器
Java“精度可能丢失”错误解决
在处理Java编程语言中“精度可能丢失”的警告或错误信息时,通常涉及到数据类型之间的转换,特别是从高精度类型(如long、double)转换到低精度类型(如int、short)时。本指南将帮助你理解这一问题的根源,并提供有效策略来避免或解决此类错误,确保程序正确无误地运行。我们将会探讨如何使用显式类型转换(cast),以及如何优化代码逻辑来规避潜在的数据丢失风险。
1088 0
|
11月前
|
弹性计算 运维 应用服务中间件
ECS和轻量应用服务器选哪个?阿里云轻量和ECS有什么区别?2026新手实测
阿里云ECS与轻量应用服务器核心区别:ECS功能全面、弹性强,适合企业级高负载场景;轻量服务器开箱即用、操作简单、性价比高,专为个人开发者、学生及低流量网站(博客、测试环境等)设计。2026实测对比涵盖场景、配置、带宽、计费、运维等维度,助你一键选对!
|
5月前
|
缓存 开发框架 Java
阿里云千问大模型Qwen3.7-Max功能、试用、计费、配置说明
阿里云Qwen3.7-Max是通义千问系列的纯文本旗舰大模型,专为智能体工作流、复杂推理与高强度编程场景设计,具备百万级上下文、深度思考与长周期自主执行能力,同时提供个人免费、新用户试用、按量计费与团队订阅等多元方案,适配个人、团队与企业全场景需求。
1770 0
|
8月前
|
弹性计算 监控 负载均衡
技术实践:使用阿里云ECS部署高可用Web应用架构
本文为阿里云云大使撰写的实战指南,详解如何用阿里云ECS搭建高可用电商应用:涵盖架构设计、环境部署、负载均衡、成本优化(月省27%)及故障处理。含完整脚本与性能数据,助力开发者高效上云。新用户通过链接享专属优惠👉https://www.aliyun.com/benefit?userCode=iakscw7s
799 13
|
弹性计算 安全 关系型数据库
阿里云服务器安装宝塔面板步骤图文教程
阿里云服务器安装宝塔Linux面板,先开通宝塔面板所需端口8888,在执行安装宝塔面板命令,在宝塔面板上安装LNMP环境,最后添加站点搭建网站
7101 0
阿里云服务器安装宝塔面板步骤图文教程
|
存储 算法 Linux
3分钟带你快速学会Linux tar 命令
【4月更文挑战第24天】
1161 1
3分钟带你快速学会Linux tar 命令
|
程序员 编译器
计算机语言分为三种:机器语言、汇编语言和高级语言
计算机语言分为三种:机器语言、汇编语言和高级语言
4528 0
|
安全 Linux 调度
操作系统:Linux vs Windows内核与应用对比(二)
操作系统:Linux vs Windows内核与应用对比
1189 0
|
人工智能 自然语言处理 安全
“智海-录问”法律大模型正式发布并开源在魔搭社区,行业首个法律大模型评估指标体系公开
8月21日,由中国工程院院刊《Engineering》、中国人工智能学会、中国工程院院刊信息与电子工程领域分刊《FITEE》联合主办的Engineering大讲堂暨“智行中国”第五期系列论坛在浙江大学举行,论坛围绕基座模型基础理论、AI+X垂直领域赋能应用及基座模型评测体系等问题邀请领域专家展开了深入探讨。