TokuDB 安装

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 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/

wget https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7.21-21/binary/tarball/Percona-Server-5.7.21-21-Linux.x86_64.ssl101.tar.gz

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

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
关系型数据库 MySQL 数据库
MySQL Innodb Purge简介
前言 为什么MySQL InnoDB需要Purge操作?明确这个问题的答案,首先还得从InnoDB的并发机制开始。为了更好的支持并发,InnoDB的多版本一致性读是采用了基于回滚段的的方式。另外,对于更新和删除操作,InnoDB并不是真正的删除原来的记录,而是设置记录的delete mark为1。
8640 1
|
7月前
|
存储 关系型数据库 MySQL
⑩【MySQL】存储引擎详解, InnoDB、MyISAM、Memory。
⑩【MySQL】存储引擎详解, InnoDB、MyISAM、Memory。
79 0
|
7月前
|
存储 SQL 关系型数据库
MySQL之深入InnoDB存储引擎——Checkpoint机制
一、引入 由于页的操作首先都是在缓冲池中完成的,那么如果一条DML语句改变了页中的记录,那么此时页就是脏的,即缓冲池中页的版本要比磁盘的新。那么数据库需要将新版本的页刷新到磁盘。倘若每次一个页发生变化就刷新,那么开销会很大,若热点数据集中在某几个页中,那么数据库的性能将变得非常差。 同时如果在缓冲池将新版本的页刷新到磁盘时发生了宕机,那么数据就不能恢复了。为了避免发生数据丢失的问题,当前事务数据库普遍都采用了 Write Ahead Log 策略,即当事务提交时,先写重做日志,再修改页。当由于发生宕机而导致数据丢失时,通过重做日志来完成数据的恢复,从而满足事务的持久性要求。
|
7月前
|
存储 SQL 关系型数据库
MySQL之深入InnoDB存储引擎——redo日志
我们知道数据的修改首先是在Buffer Pool中进行的,之后再定时刷到磁盘中。那么如果在事务提交后还没刷新到磁盘中,系统就崩溃了,那么此时数据就丢失了,这就不满足事务的持久性了。而如果我们考虑每次提交之后,都同步将事务中所有的页面刷新到磁盘,这样确实可以保证持久性,但是这种方法存在以下两种问题:
|
存储 关系型数据库 MySQL
MySQL引擎:InnoDB VS MyISAM
MySQL引擎:InnoDB VS MyISAM
|
存储 SQL 安全
深入学习 Mysql 引擎 InnoDB、MyISAM
MySQL 引擎 InnoDB 和 MyISAM 是 MySQL 中常用的两种存储引擎,它们具有不同的特点,请看正文一一介绍。
393 0
深入学习 Mysql 引擎 InnoDB、MyISAM
|
存储 缓存 关系型数据库
【Mysql-InnoDB系列】InnoDB架构
mysql官方文档,8.0版本,InnoDB架构的深度学习
126 0
|
监控 MySQL 关系型数据库
|
SQL 存储 关系型数据库
|
存储 关系型数据库