线上的数据增长越来越快,数据量的增长也愈来愈大,尤其是日志类数据,这对于数据迁移、数据备份恢复而言,都是一个非常大的挑战。

于是想到了 13 年开源 tokuDB 存储引擎,来解决我们迫在眉睫的容量问题。

TokuDB 是一个高性能、支持事务处理的 MySQL 和 MariaDB 的存储引擎。TokuDB 的主要特点是高压缩比,高 INSERT 性能,支持大多数在线修改索引、添加字段,特别适合像 Zabbix 这种高 INSERT,少 UPDATE 的应用场景。

由于在 Percona 5.6 之后,tokuDB 无法单独作为一个插件直接在 MySQL 社区版上使用(可以成功安装插件,但使用时会陷入无限重启/(ㄒoㄒ)/~~),因而,本次使用 Percona MySQL 最新版 5.7.18,操作系统是 64 bit CentOS 6.9。

安装

1 依赖安装

yum install libaio-devel numactl -y

2 初始化安装和 MySQL 社区版安装一样

3 关闭 MySQL 服务,添加 tokuDB 插件配置,并启动

[mysqld_safe]

malloc-lib=/usr/lib64/libjemalloc.so.1

plugin-dir = /usr/local/mysql/lib/mysql/plugin/

plugin-load=ha_tokudb.so

注意:5.7 以后版本,为了安全,需要将 libjemalloc 复制到 /usr/lib /usr/lib64 目录下才能正确读取

4 安装 tokuDB

ps_tokudb_admin -S /tmp/mysql.sock --enable -uroot -pxxx

注意:此时可以加上 --enable-backup 热备份插件功能

5 添加 tokuDB 配置项

##tokuDB

#tokudb-data-dir = /data/mysql/mysql3306/tokudbData

#tokudb-log-dir = /data/mysql/mysql3306/tokudbLog

#TokuDB的行模式,建议用 FAST ,如果磁盘空间很紧张,建议用 SMALL

#tokudb_default: 设置默认的压缩行为。在 TokuDB 7.1.0版本,默认使用 zlib 库进行压缩,未来版本可能会改变。

#tokudb_fast: 使用 quicklz 库的压缩模式。

#tokudb_small: 使用 lzma 库的压缩模式。

#tokudb_zlib: 使用 zlib 库的压缩模式,提供了中等级别的压缩比和中等级别的CPU消耗。

#tokudb_quicklz: 使用 quicklz 库的压缩模式, 提供了轻量级的压缩比和较低基本的CPU消耗。

#tokudb_lzma: 使用 lzma 库压缩模式,提供了高压缩比和高CPU消耗。

#tokudb_uncompressed: 不使用压缩模式。

tokudb_row_format = tokudb_fast

tokudb_cache_size = 1G ###建议内存的一半

tokudb_commit_sync = 0

tokudb_directio = 1

tokudb_read_block_size = 128K

tokudb_read_buf_size = 128K

备份

1 使用 mysqldump 备份

使用 Percona 版本的 mysqldump 可以备份 tokuDB 的数据,并且额外提供了一个参数 lock-for-backup 来保证数据一致性。

eg:

mysqldump --single-transaction --lock-for-backup --master-data=2 -S /tmp/mysql.sock -uroot -p -A > xxx-2017-6-28.sql

mysqldump has also been extended with a new option, lock-for-backup (disabled by default). When used together with the --single-transaction option, the option makes mysqldump issue LOCK TABLES FOR BACKUP before starting the dump operation to prevent unsafe statements that would normally result in an inconsistent backup.

When used without the single-transaction option, lock-for-backup is automatically converted to lock-all-tables.

Option lock-for-backup is mutually exclusive with lock-all-tables, i.e. specifying both on the command line will lead to an error.

If the backup locks feature is not supported by the target server, but lock-for-backup is specified on the command line, mysqldump aborts with an error. [Link]

2 使用 tokudb-xtrabackup 备份

基于 Percona Xtrabackup 的兼容 tokuDB 的备份工具

yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel vim-common -y

git clone https://github.com/BohuTANG/tokudb-xtrabackup

cd tokudb-xtrabackup

cmake .\

-DBUILD_CONFIG=xtrabackup_release\

-DWITH_BOOST=extra/boost/boost_1_59_0.tar.gz\

-DWITH_MAN_PAGES=OFF\

-DCMAKE_INSTALL_PREFIX=/usr/local/tokudb-xtrabackup

make

make install

注意: gcc 的版本最好要 >= 4.8

eg:

/usr/local/tokudb-xtrabackup/bin/innobackupex --defaults-file=/path/to/my.cnf --user=root --password=xxx --no-timestamp /path/to/backup

/usr/local/tokudb-xtrabackup/bin/innobackupex --apply-log /path/to/backup

/usr/local/tokudb-xtrabackup/bin/innobackupex --defaults-file=/path/to/my.cnf --copy-back /path/to/backup

3 使用 tokudb-backup-plugin 备份

官方提供的一个热备份插件

ps_tokudb_admin --enable-backup -S /tmp/mysql.sock -uroot -pxxx

用此命令安装之后,确认配置文件已添加相应的配置项:

# tokudb

innodb_use_native_aio=off

[mysqld_safe]

preload-hotbackup

thp-setting=never

eg:

mysql> set tokudb_backup_dir='/path/to/backup';

实验代码

安装

[root@glon_ho ~]# cat /etc/issue

CentOS release 6.9 (Final)

Kernel \r on an \m

[root@glon_ho ~]# chkconfig iptables off

[root@glon_ho ~]# service iptables stop

[root@glon_ho ~]# getenforce

Disabled

[root@glon_ho ~]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - SELinux is fully disabled.

SELINUX=disabled

# SELINUXTYPE= type of policy in use. Possible values are:

# targeted - Only targeted network daemons are protected.

# strict - Full SELinux protection.

SELINUXTYPE=targeted

[root@glon_ho ~]# yum install libaio-devel mlocate -y

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* epel: mirror01.idc.hinet.net

* extras: mirrors.163.com

* updates: mirrors.163.com

Resolving Dependencies

--> Running transaction check

---> Package libaio-devel.x86_64 0:0.3.107-10.el6 will be installed

---> Package mlocate.x86_64 0:0.22.2-6.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================

Package Arch Version Repository Size

=============================================================================================================================================================================================

Installing:

libaio-devel x86_64 0.3.107-10.el6 base 13 k

mlocate x86_64 0.22.2-6.el6 base 86 k

Transaction Summary

=============================================================================================================================================================================================

Install 2 Package(s)

Total download size: 99 k

Installed size: 302 k

Downloading Packages:

(1/2): libaio-devel-0.3.107-10.el6.x86_64.rpm | 13 kB 00:00

(2/2): mlocate-0.22.2-6.el6.x86_64.rpm | 86 kB 00:00

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total 306 kB/s | 99 kB 00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : mlocate-0.22.2-6.el6.x86_64 1/2

Installing : libaio-devel-0.3.107-10.el6.x86_64 2/2

Verifying : libaio-devel-0.3.107-10.el6.x86_64 1/2

Verifying : mlocate-0.22.2-6.el6.x86_64 2/2

Installed:

libaio-devel.x86_64 0:0.3.107-10.el6 mlocate.x86_64 0:0.22.2-6.el6

Complete!

[root@glon_ho ~]# yum install numactl -y

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* epel: mirror01.idc.hinet.net

* extras: mirrors.163.com

* updates: mirrors.163.com

Resolving Dependencies

--> Running transaction check

---> Package numactl.x86_64 0:2.0.9-2.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================

Package Arch Version Repository Size

=============================================================================================================================================================================================

Installing:

numactl x86_64 2.0.9-2.el6 base 74 k

Transaction Summary

=============================================================================================================================================================================================

Install 1 Package(s)

Total download size: 74 k

Installed size: 171 k

Downloading Packages:

numactl-2.0.9-2.el6.x86_64.rpm | 74 kB 00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : numactl-2.0.9-2.el6.x86_64 1/1

Verifying : numactl-2.0.9-2.el6.x86_64 1/1

Installed:

numactl.x86_64 0:2.0.9-2.el6

Complete!

[root@glon_ho ~]#

[root@glon_ho ~]# cd /opt/

[root@glon_ho opt]# tar -zxf /vagrant_data/Percona-Server-5.7.18-15-Linux.x86_64.ssl101.tar.gz

[root@glon_ho opt]#

[root@glon_ho local]# sudo groupadd mysql

[root@glon_ho local]# sudo useradd -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql

[root@glon_ho local]# id mysql

uid=501(mysql) gid=501(mysql) groups=501(mysql)

[root@glon_ho local]# chown -R mysql:mysql /usr/local/mysql

[root@glon_ho local]# chown -R mysql:mysql /usr/local/mysql/

[root@glon_ho local]# ll mysql/

total 128

drwxr-xr-x 2 mysql mysql 4096 May 25 10:01 bin

-rw-r--r-- 1 mysql mysql 17987 May 25 08:03 COPYING

-rw-r--r-- 1 mysql mysql 34520 May 25 09:44 COPYING.AGPLv3

-rw-r--r-- 1 mysql mysql 17987 May 25 09:44 COPYING.GPLv2

-rw-r--r-- 1 mysql mysql 1703 May 25 10:03 COPYING-jemalloc

drwxr-xr-x 2 mysql mysql 4096 May 25 10:01 docs

drwxr-xr-x 3 mysql mysql 4096 May 25 10:01 include

drwxr-xr-x 5 mysql mysql 4096 May 25 10:01 lib

drwxr-xr-x 4 mysql mysql 4096 May 25 10:01 man

drwxr-xr-x 10 mysql mysql 4096 May 25 10:01 mysql-test

-rw-r--r-- 1 mysql mysql 2211 May 25 09:44 PATENTS

-rw-r--r-- 1 mysql mysql 4442 May 25 09:44 README.md

-rw-r--r-- 1 mysql mysql 2478 May 25 08:03 README.MySQL

drwxr-xr-x 28 mysql mysql 4096 May 25 10:01 share

drwxr-xr-x 2 mysql mysql 4096 May 25 10:01 support-files

[root@glon_ho local]# mkdir /data/mysql/mysql3306/{data,logs,tmp} -p

[root@glon_ho local]# chown -R mysql:mysql /data/

[root@glon_ho local]# cd

[root@glon_ho ~]# ls

my3306.cnf

[root@glon_ho ~]# mv my3306.cnf /data/mysql/mysql3306/

[root@glon_ho ~]# chown -R mysql:mysql /data/mysql/mysql3306/

[root@glon_ho ~]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --initialize

[root@glon_ho ~]# vim /etc/profile

...

export PATH=$PATH:/usr/local/mysql/bin

"/etc/profile" 80L, 1881C written

[root@glon_ho ~]# source /etc/profile

[root@glon_ho ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

[root@glon_ho ~]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf &

[1] 2634

[root@glon_ho ~]#

[root@glon_ho ~]# ps aux| grep mysql

mysql 2634 8.1 13.1 2616584 269924 pts/0 Sl 07:46 0:01 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf

root 2679 0.0 0.0 105368 880 pts/0 S+ 07:47 0:00 grep mysql

[root@glon_ho ~]# grep 'password' /data/mysql/mysql3306/data/error.log

2017-07-03T06:43:34.915585Z 1 [Note] A temporary password is generated for root@localhost: NxJDq-a=&2tf

[root@glon_ho ~]# mysql -S /tmp/mysql3306.sock -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.18-15-log

Copyright (c) 2009-2017 Percona LLC and/or its affiliates

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.01 sec)

mysql> select user,host from mysql.user;

+-----------+-----------+

| user | host |

+-----------+-----------+

| mysql.sys | localhost |

| root | localhost |

+-----------+-----------+

2 rows in set (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> \q

Bye

[root@glon_ho ~]# cp /usr/local/mysql/lib/mysql/libjemalloc.so.1 /usr/lib/

[root@glon_ho ~]# cp /usr/local/mysql/lib/mysql/libjemalloc.so.1 /usr/lib64/

[root@glon_ho ~]# vim /data/mysql/mysql3306/my3306.cnf

...

[mysqld_safe]

#malloc-lib=/usr/local/mysql/lib/mysql/libjemalloc.so.1

malloc-lib=/usr/lib64/libjemalloc.so.1

plugin-dir = /usr/local/mysql/lib/mysql/plugin/

plugin-load=ha_tokudb.so

nice=-19

open-files-limit=65535

default-time-zone = '+8:00'

"/data/mysql/mysql3306/my3306.cnf" 158L, 4025C written

[root@glon_ho ~]# sh upds.sh

[root@glon_ho ~]# mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld

2017-07-03T07:02:34.225085Z mysqld_safe Logging to '/data/mysql/mysql3306/data/error.log'.

2017-07-03T07:02:34.361730Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3306/data

[root@glon_ho ~]# ps aux| grep mysql

root 4586 0.8 0.0 108256 1604 pts/0 S 08:02 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3306/my3306.cnf

mysql 5622 16.8 14.6 1941052 301660 pts/0 S

root 5667 0.0 0.0 105372 892 pts/0 S+ 08:02 0:00 grep mysql

[root@glon_ho ~]#

[root@glon_ho ~]# ps_tokudb_admin -S /tmp/mysql3306.sock --enable -uroot -p123456

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 enabled (should be disabled).

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.

Disabling transparent huge pages for the current session...

INFO: Successfully disabled transparent huge pages for this session.

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@glon_ho ~]# sh en.sh

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.7.18-15-log Percona Server (GPL), Release 15, Revision bff2cd9

Copyright (c) 2009-2017 Percona LLC and/or its affiliates

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@tokudb_version;

+------------------+

| @@tokudb_version |

+------------------+

| 5.7.18-15 |

+------------------+

1 row in set (0.00 sec)

mysql> show engines;

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

| Engine | Support | Comment | Transactions | XA | Savepoints |

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

| MyISAM | YES | MyISAM storage engine | 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 |

| PERFORMANCE_SCHEMA | YES | Performance Schema | 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 |

| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |

| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

10 rows in set (0.00 sec)

mysql> show plugins;

+-------------------------------+----------+--------------------+--------------+---------+

| Name | Status | Type | Library | License |

+-------------------------------+----------+--------------------+--------------+---------+

| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |

| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |

| sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL |

| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |

| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |

| InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL |

| XTRADB_READ_VIEW | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| XTRADB_INTERNAL_HASH_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| XTRADB_RSEG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| XTRADB_ZIP_DICT | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| XTRADB_ZIP_DICT_COLS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMP_PER_INDEX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CMP_PER_INDEX_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_BUFFER_PAGE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_BUFFER_PAGE_LRU | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_BUFFER_POOL_STATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_TEMP_TABLE_INFO | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_METRICS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_DEFAULT_STOPWORD | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_BEING_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_CONFIG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_INDEX_CACHE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_FT_INDEX_TABLE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_TABLESTATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_INDEXES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_COLUMNS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_FIELDS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_FOREIGN | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_FOREIGN_COLS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_TABLESPACES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_DATAFILES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_CHANGED_PAGES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| INNODB_SYS_VIRTUAL | ACTIVE | INFORMATION SCHEMA | NULL | GPL |

| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |

| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |

| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |

| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |

| ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL |

| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |

| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |

| ngram | ACTIVE | FTPARSER | NULL | GPL |

| TokuDB | ACTIVE | STORAGE ENGINE | ha_tokudb.so | GPL |

| TokuDB_file_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_fractal_tree_info | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_fractal_tree_block_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_trx | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_locks | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_lock_waits | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

| TokuDB_background_job_status | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |

+-------------------------------+----------+--------------------+--------------+---------+

58 rows in set (0.00 sec)

mysql> show global variables like "%tokudb%";

+-----------------------------------------+-------------------------+

| Variable_name | Value |

+-----------------------------------------+-------------------------+

| tokudb_alter_print_error | OFF |

| tokudb_analyze_delete_fraction | 1.000000 |

| tokudb_analyze_in_background | ON |

| tokudb_analyze_mode | TOKUDB_ANALYZE_STANDARD |

| tokudb_analyze_throttle | 0 |

| tokudb_analyze_time | 5 |

| tokudb_auto_analyze | 30 |

| tokudb_block_size | 4194304 |

| tokudb_bulk_fetch | ON |

| tokudb_cache_size | 1051711488 |

| tokudb_cachetable_pool_threads | 0 |

| tokudb_cardinality_scale_percent | 100 |

| tokudb_check_jemalloc | ON |

| tokudb_checkpoint_lock | OFF |

| tokudb_checkpoint_on_flush_logs | OFF |

| tokudb_checkpoint_pool_threads | 0 |

| tokudb_checkpointing_period | 60 |

| tokudb_cleaner_iterations | 5 |

| tokudb_cleaner_period | 1 |

| tokudb_client_pool_threads | 0 |

| tokudb_commit_sync | ON |

| tokudb_compress_buffers_before_eviction | ON |

| tokudb_create_index_online | ON |

| tokudb_data_dir | |

| tokudb_debug | 0 |

| tokudb_dir_cmd | |

| tokudb_dir_cmd_last_error | 0 |

| tokudb_dir_cmd_last_error_string | |

| tokudb_dir_per_db | ON |

| tokudb_directio | OFF |

| tokudb_disable_hot_alter | OFF |

| tokudb_disable_prefetching | OFF |

| tokudb_disable_slow_alter | OFF |

| tokudb_empty_scan | rl |

| tokudb_enable_partial_eviction | ON |

| tokudb_fanout | 16 |

| tokudb_fs_reserve_percent | 5 |

| tokudb_fsync_log_period | 0 |

| tokudb_hide_default_row_format | ON |

| tokudb_killed_time | 4000 |

| tokudb_last_lock_timeout | |

| tokudb_load_save_space | ON |

| tokudb_loader_memory_size | 100000000 |

| tokudb_lock_timeout | 4000 |

| tokudb_lock_timeout_debug | 1 |

| tokudb_log_dir | |

| tokudb_max_lock_memory | 131463936 |

| tokudb_optimize_index_fraction | 1.000000 |

| tokudb_optimize_index_name | |

| tokudb_optimize_throttle | 0 |

| tokudb_prelock_empty | ON |

| tokudb_read_block_size | 65536 |

| tokudb_read_buf_size | 131072 |

| tokudb_read_status_frequency | 10000 |

| tokudb_row_format | tokudb_zlib |

| tokudb_rpl_check_readonly | ON |

| tokudb_rpl_lookup_rows | ON |

| tokudb_rpl_lookup_rows_delay | 0 |

| tokudb_rpl_unique_checks | ON |

| tokudb_rpl_unique_checks_delay | 0 |

| tokudb_strip_frm_data | OFF |

| tokudb_support_xa | ON |

| tokudb_tmp_dir | |

| tokudb_version | 5.7.18-15 |

| tokudb_write_status_frequency | 1000 |

+-----------------------------------------+-------------------------+

65 rows in set (0.02 sec)

mysql> \q

Bye

[root@glon_ho ~]#

[root@glon_ho ~]# vim /data/mysql/mysql3306/my3306.cnf

...

##tokuDB

#TokuDB的行模式,建议用 FAST ,如果磁盘空间很紧张,建议用 SMALL

tokudb_row_format = tokudb_fast

tokudb_cache_size = 1G

tokudb_commit_sync = 0

tokudb_directio = 1

tokudb_read_block_size = 128K

tokudb_read_buf_size = 128K

[mysqld_safe]

malloc-lib=/usr/lib64/libjemalloc.so.1

plugin-dir = /usr/local/mysql/lib/mysql/plugin/

plugin-load=ha_tokudb.so

nice=-19

open-files-limit=65535

default-time-zone = '+8:00'

"/data/mysql/mysql3306/my3306.cnf" 158L, 4009C written

[root@glon_ho ~]# sh down.sh

mysqladmin: [Warning] Using a password on the command line interface can be insecure.

2017-07-03T07:10:34.861225Z mysqld_safe mysqld from pid file /data/mysql/mysql3306/data/mysql.pid ended

[root@glon_ho ~]#

[root@glon_ho ~]# sh upds.sh

[root@glon_ho ~]# mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld

2017-07-03T07:10:46.379879Z mysqld_safe Logging to '/data/mysql/mysql3306/data/error.log'.

2017-07-03T07:10:46.414953Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3306/data

[root@glon_ho ~]# sh en.sh

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.18-15-log Percona Server (GPL), Release 15, Revision bff2cd9

Copyright (c) 2009-2017 Percona LLC and/or its affiliates

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show engines;

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

| Engine | Support | Comment | Transactions | XA | Savepoints |

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

| MyISAM | YES | MyISAM storage engine | 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 |

| PERFORMANCE_SCHEMA | YES | Performance Schema | 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 |

| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |

| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |

+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

10 rows in set (0.00 sec)

mysql> create database toku;

Query OK, 1 row affected (0.01 sec)

mysql> use toku

Database changed

mysql> create table t (id int, name varchar(32)) engine=tokudb;

Query OK, 0 rows affected (0.14 sec)

mysql> show create table t\G

*************************** 1. row ***************************

Table: t

Create Table: CREATE TABLE `t` (

`id` int(11) DEFAULT NULL,

`name` varchar(32) DEFAULT NULL

) ENGINE=TokuDB DEFAULT CHARSET=utf8 ROW_FORMAT=TOKUDB_QUICKLZ

1 row in set (0.02 sec)

mysql> insert into t values (1,'Eason Chan'),(2,'Andy Lau');

Query OK, 2 rows affected (0.05 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from t;

+------+------------+

| id | name |

+------+------------+

| 1 | Eason Chan |

| 2 | Andy Lau |

+------+------------+

2 rows in set (0.00 sec)

mysql>

mysql> create table t2 (id int, name varchar(32));

Query OK, 0 rows affected (0.05 sec)

mysql> show create table t2\G

*************************** 1. row ***************************

Table: t2

Create Table: CREATE TABLE `t2` (

`id` int(11) DEFAULT NULL,

`name` varchar(32) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8

1 row in set (0.00 sec)

mysql> insert into t2 values (1,'Eason Chan'),(2,'Andy Lau');

Query OK, 2 rows affected (0.09 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from t2;

+------+------------+

| id | name |

+------+------------+

| 1 | Eason Chan |

| 2 | Andy Lau |

+------+------------+

2 rows in set (0.00 sec)

mysql> \q

Bye

[root@glon_ho ~]#

tokudb 安装mysql_tokuDB 安装与备份小记相关推荐

  1. tokudb 安装mysql_tokuDB存储引擎的安装、配置、使用及注意事项 | 学步园

    平台支持: TokuDB 只能在 64-bit Linux 下使用. 最小内存要求: TokuDB 需要至少1GB 的物理内存,当然这里建议最好是 2GB . 1.安装mysql(可以是mariadb ...

  2. jstack 脚本 自动日志_GitLab从安装到全自动化备份一条龙

    原文地址[1]欢迎star 需求 1.在新服务器上安装并搭建好gitlab2.手动+自动将旧服务器上的gitlab备份3.手动+自动将gitlab备份包scp到新服务器上4.手动+自动恢复新服务器上的 ...

  3. kubeadm安装的Kubernetes etcd备份恢复

    kubeadm安装的Kubernetes etcd备份恢复 [TOC] 1. 事件由来 2018年9月16日台风过后,我的一套kuernetes测试系统,etcd启动失败,经过半天的抢救,仍然无果(3 ...

  4. 制品仓库 Nexus 安装、配置、备份、使用

    目录 1.1 Nexus 优点 1.2 Nexus 仓库类型 2. 安装 Nexus 2.1 设置持久化目录 2.2 拉取 Nexus docker 镜像 2.3 运行并启动 Nexus 3. 系统配 ...

  5. android备份:apk安装过程及原理,备份已安装应用的apk包技术实现方案

    安卓设备上备份已安装应用的apk包技术实现方案 需求的目的 在只有安装应用, 没有该应用的apk,而我们又想活取应用apk,用来分享给别人,或是应用的备份, 说是应用的增量升级的, 怎么办? 本文将告 ...

  6. git简介、安装、基本操作——Git折腾小记

    这两天刚完成了一个小项目,整理资料发现现在写代码跟文档又没有版本控制的意识,刚好前两天电脑出问题,差点所有代码跟文档全丢掉,所以这两天又在自己的台式机上架起了git,做所谓的代码服务器,之前折腾过一次 ...

  7. 我家云/粒子云Rockchip RK3328将Android安装到eMMC和备份系统的指南

    我家云/粒子云Rockchip RK3328将Android安装到eMMC和备份系统的指南 Guide to install Android into eMMC Windows 7/8/10 指南 来 ...

  8. 安装python38_debian8安装python3.7

    Debian默认安装的python版本分别是2.7和3.4,但是Python3.4都快要退出舞台了,为了项目需求得提升一下python版本,想来想去最好还是用最新版本的python吧. 为了防止因卸载 ...

  9. python3.6.5安装-linux安装python3.6.5

    inux下因为默认带python了,如果要升级版本的,要先把系统自带的python改名或者卸载掉,再安装你要的python版本,centos下由于yum依赖自带的python2.6,所有不能卸载. p ...

最新文章

  1. listview winfrom 表头_winform ListView点击行表头,排序
  2. spring cloud bus AMQP学习笔记
  3. java mvc 获取session_Spring MVC----获取session/request
  4. linux grpc,grpc linux下的编译使用-Go语言中文社区
  5. 日本电影《摇摆》:男人之间的心灵碰撞
  6. java 数据网格,easyui数据网格
  7. css布局方式_收藏!40 个 CSS 布局技巧
  8. 【英语学习】【WOTD】zero-sum 释义/词源/示例
  9. DSB2017第一名代码尝试运行(记录自用)(四)
  10. os库的基本使用(复习)
  11. matlab的火山图,如何用EXCEL画一张帅气的火山图?
  12. 罗永浩“卖艺”还债:所有命运馈赠的礼物,都早已在暗中标好了价格
  13. 关于关联规则的一些资料
  14. 手机已连接但无法访问互联网,碰到这个情况怎么破?想不到是这样
  15. websphere安装was8.5
  16. 极速进阶,小i智慧学堂联合复旦大学教授推出人工智能冬令营
  17. 怎么查看linux有多少内存插槽,linux 查看内存插槽数、最大容量和频率
  18. 芯片CP/FT测试的基本概念理解
  19. 用python的matplotlib和numpy库绘制股票K线均线的整合效果(含从网络接口爬取数据和验证交易策略代码)...
  20. TCP/UDP协议首部格式

热门文章

  1. 【微信小程序】scroll-tab-view滑动选项卡的实现
  2. Vim中如何切换窗口?
  3. Revit二次开发——云服务器
  4. python第二次作业
  5. ArcGIS Pro地图和场景
  6. win10怎样进网站服务器,win10怎么进服务器地址
  7. 录音转文字助手该怎么使用?这里教你操作方法
  8. JS判断浏览器(精短)
  9. flink sql 异常:INTEGER and VARCHAR(2147483647) does not have common type no
  10. 通过sendmail服务器配置域外转发到qq邮箱