TokuDB 安装

安装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;
EngineSupportCommentTransactionsXASavepoints
PERFORMANCE_SCHEMAYESPerformance SchemaNONONO
MRG_MYISAMYESCollection of identical MyISAM tablesNONONO
CSVYESCSV storage engineNONONO
BLACKHOLEYES/dev/null storage engine (anything you write to it disappears)NONONO
MyISAMYESMyISAM storage engineNONONO
TokuDBYESPercona TokuDB Storage Engine with Fractal Tree(tm) TechnologyYESYESYES
InnoDBDEFAULTPercona-XtraDB, Supports transactions, row-level locking, and foreign keysYESYESYES
ARCHIVEYESArchive storage engineNONONO
MEMORYYESHash based, stored in memory, useful for temporary tablesNONONO
FEDERATEDNOFederated MySQL storage engineNULLNULLNULL

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;
EngineSupportCommentTransactionsXASavepoints
PERFORMANCE_SCHEMAYESPerformance SchemaNONONO
MRG_MYISAMYESCollection of identical MyISAM tablesNONONO
CSVYESCSV storage engineNONONO
BLACKHOLEYES/dev/null storage engine (anything you write to it disappears)NONONO
MyISAMYESMyISAM storage engineNONONO
TokuDBDEFAULTPercona TokuDB Storage Engine with Fractal Tree(tm) TechnologyYESYESYES
InnoDBYESPercona-XtraDB, Supports transactions, row-level locking, and foreign keysYESYESYES
ARCHIVEYESArchive storage engineNONONO
MEMORYYESHash based, stored in memory, useful for temporary tablesNONONO
FEDERATEDNOFederated MySQL storage engineNULLNULLNULL

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值