前言:因为现在tokuDB直接整合到Percona server里面了,下载页面直接跳转到下载Percona Server 页面了。安装方法跟以前不一样了,下面就来看一下新版本怎么安装了
##准备阶段就不说了,
#首先配置文件不能先有tokudb相关配置,因为默认是没有启用这个引擎,所以得初始化安装成功之后,启动MySQL之后才能安装该引擎。
[root@node12 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/3306/data --defaults-file=/usr/local/mysql/my.cnf
Installing MySQL system tables...2016-07-21 20:52:39 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31-77.0-log) starting as process 2173 ...
2016-07-21 20:52:39 2173 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-21 20:52:39 2173 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-21 20:52:39 2173 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-21 20:52:39 2173 [Note] InnoDB: Memory barrier is not used
2016-07-21 20:52:39 2173 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-21 20:52:39 2173 [Note] InnoDB: Using Linux native AIO
2016-07-21 20:52:39 2173 [Note] InnoDB: Using CPU crc32 instructions
2016-07-21 20:52:39 2173 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2016-07-21 20:52:39 2173 [Note] InnoDB: Completed initialization of buffer pool
2016-07-21 20:52:39 2173 [Note] InnoDB: Highest supported file format is Barracuda.
2016-07-21 20:52:39 2173 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-21 20:52:39 2173 [Note] InnoDB: Waiting for purge to start
2016-07-21 20:52:39 2173 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.31-rel77.0 started; log sequence number 1600607
2016-07-21 20:52:39 2173 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'tokudb-data-dir=/mydata/3306/tokudbData'
2016-07-21 20:52:39 2173 [ERROR] Aborting
2016-07-21 20:52:39 2173 [Note] Binlog end
2016-07-21 20:52:39 2173 [Note] InnoDB: FTS optimize thread exiting.
2016-07-21 20:52:39 2173 [Note] InnoDB: Starting shutdown...
2016-07-21 20:52:41 2173 [Note] InnoDB: Shutdown completed; log sequence number 1600617
2016-07-21 20:52:41 2173 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
看到没有,直接报错了。未知参数。注释tukodb相关选项。再次初始化
###
初始化MySQL,并启动成功之后,才开始安装
[root@node12 mysql]# /etc/init.d/mysql start
Starting MySQL (Percona Server)... [ OK ]
[root@node12 mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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>
mysql>
mysql> \q
Bye
##注意要关闭selinux,不然安装不成功
[root@node12 bin]# ps_tokudb_admin --enable -uroot -p
Enter password:
Continuing without password...
Checking SELinux status...
ERROR: SELinux is in enforcing mode and needs to be disabled (or put into permissive mode) for TokuDB to work correctly.
[root@node12 bin]# vim /etc/selinux/config
[root@node12 bin]# setenforce 0
[root@node12 bin]# getenforce
Permissive
###再次安装
[root@node12 bin]# ps_tokudb_admin --enable -uroot -p
Enter password:
Continuing without password...
Checking SELinux status...
INFO: SELinux is in permissive mode.
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.
###因为我这个是Oracle的系统,默认就关闭了透明大页,红帽子和centos系统要关闭透明大页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
并写到开启启动里面
[root@node12 bin]# mysql
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | 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 |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| 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)
mysql>
###关闭MySQL,加上自定义配置
####加上配置文件
如果你要自定义tukodb目录,你要把刚才安装命令的文件拷贝相应目录里面,不然会报错
2016-07-21 21:05:32 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31-77.0-log) starting as process 3641 ...
2016-07-21 21:05:32 3641 [Note] Plugin 'FEDERATED' is disabled.
2016-07-21 21:05:32 3641 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-21 21:05:32 3641 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-21 21:05:32 3641 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-21 21:05:32 3641 [Note] InnoDB: Memory barrier is not used
2016-07-21 21:05:32 3641 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-21 21:05:32 3641 [Note] InnoDB: Using Linux native AIO
2016-07-21 21:05:32 3641 [Note] InnoDB: Using CPU crc32 instructions
2016-07-21 21:05:32 3641 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2016-07-21 21:05:32 3641 [Note] InnoDB: Completed initialization of buffer pool
2016-07-21 21:05:32 3641 [Note] InnoDB: Highest supported file format is Barracuda.
2016-07-21 21:05:32 3641 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-21 21:05:32 3641 [Note] InnoDB: Waiting for purge to start
2016-07-21 21:05:32 3641 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.31-rel77.0 started; log sequence number 1626017
2016-07-21 21:05:32 3641 [ERROR] TokuDB: Recovery log is missing (persistent environment information is present) while looking for recovery log files in [/mydata/3306/tokudbLog]
2016-07-21 21:05:32 3641 [ERROR] TokuDB unknown error 2
2016-07-21 21:05:32 3641 [ERROR] Plugin 'TokuDB' init function returned error.
2016-07-21 21:05:32 3641 [ERROR] Plugin 'TokuDB' registration as a STORAGE ENGINE failed.
2016-07-21 21:05:32 3641 [Note] RSA private key file not found: /mydata/3306/data//private_key.pem. Some authentication plugins will not work.
2016-07-21 21:05:32 3641 [Note] RSA public key file not found: /mydata/3306/data//public_key.pem. Some authentication plugins will not work.
2016-07-21 21:05:32 3641 [Note] Server hostname (bind-address): '*'; port: 3306
2016-07-21 21:05:32 3641 [Note] IPv6 is available.
2016-07-21 21:05:32 3641 [Note] - '::' resolves to '::';
2016-07-21 21:05:32 3641 [Note] Server socket created on IP: '::'.
2016-07-21 21:05:32 3641 [Warning] 'user' entry 'root@node12' ignored in --skip-name-resolve mode.
2016-07-21 21:05:32 3641 [Warning] 'user' entry '@node12' ignored in --skip-name-resolve mode.
2016-07-21 21:05:32 3641 [Warning] 'proxies_priv' entry '@ root@node12' ignored in --skip-name-resolve mode.
2016-07-21 21:05:32 3641 [Note] Event Scheduler: Loaded 0 events
2016-07-21 21:05:32 3641 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.31-77.0-log' socket: '/mydata/3306/run/mysql.sock' port: 3306 Percona Server (GPL), Release 77.0, Revision 5c1061c
#
添加配置文件
tokudb-data-dir = /mydata/3306/tokudbData
tokudb-log-dir = /mydata/3306/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_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
optimizer_switch = 'mrr=on,mrr_cost_based=off'
[mysqld_safe]
log_error=/mydata/3306/logs/error.log
pid_file=/mydata/3306/run/mysqld.pid
malloc-lib= /usr/local/mysql/lib/mysql/libjemalloc.so
user=mysql
plugin-dir = /usr/local/mysql/lib/mysql/plugin/
plugin-load=ha_tokudb.so
##
移动tokudb文件到相应目录
[root@node12 ~]#mkdir -p /mydata/3306/{tokudbData,tokudbLog}
[root@node12 ~]#chown -R mysql.mysql /mydata/3306/
[root@node12 data]# mv __tokudb_lock_dont_delete_me_data /mydata/3306/tokudbData/
[root@node12 data]# mv __tokudb_lock_dont_delete_me_temp /mydata/3306/tokudbData/
[root@node12 data]# mv __tokudb_lock_dont_delete_me_environment /mydata/3306/tokudbData/
#log目录
[root@node12 data]# mv __tokudb_lock_dont_delete_me_logs /mydata/3306/tokudbData/
[root@node12 data]# mv __tokudb_lock_dont_delete_me_recovery /mydata/3306/tokudbData/
[root@node12 data]# mv tokudb.rollback /mydata/3306/tokudbLog/
[root@node12 tokudbLog]# ll
total 16
-rw-------. 1 mysql mysql 0 Jul 21 21:05 __tokudb_lock_dont_delete_me_logs
-rw-------. 1 mysql mysql 0 Jul 21 21:05 __tokudb_lock_dont_delete_me_recovery
-rw-rw----. 1 mysql mysql 16384 Jul 21 21:02 tokudb.rollback
###重启MySQL
[root@node12 data]#mysql
mysql> show global variables like '%toku%';
+-----------------------------------------+-------------------------+
| Variable_name | Value |
+-----------------------------------------+-------------------------+
| tokudb_alter_print_error | OFF |
| tokudb_analyze_delete_fraction | 1.000000 |
| tokudb_analyze_in_background | OFF |
| tokudb_analyze_mode | TOKUDB_ANALYZE_STANDARD |
| tokudb_analyze_throttle | 0 |
| tokudb_analyze_time | 5 |
| tokudb_auto_analyze | 0 |
| tokudb_block_size | 4194304 |
| tokudb_bulk_fetch | ON |
| tokudb_cache_size | 1073741824 |
| tokudb_cachetable_pool_threads | 0 |
| tokudb_cardinality_scale_percent | 50 |
| 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 | OFF |
| tokudb_compress_buffers_before_eviction | ON |
| tokudb_create_index_online | ON |
| tokudb_data_dir | /mydata/3306/tokudbData |
| tokudb_debug | 0 |
| tokudb_directio | ON |
| tokudb_disable_hot_alter | OFF |
| tokudb_disable_prefetching | OFF |
| tokudb_disable_slow_alter | OFF |
| tokudb_disable_slow_update | OFF |
| tokudb_disable_slow_upsert | 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 | /mydata/3306/tokudbLog |
| tokudb_max_lock_memory | 134217728 |
| tokudb_optimize_index_fraction | 1.000000 |
| tokudb_optimize_index_name | |
| tokudb_optimize_throttle | 0 |
| tokudb_pk_insert_mode | 1 |
| tokudb_prelock_empty | ON |
| tokudb_read_block_size | 131072 |
| tokudb_read_buf_size | 131072 |
| tokudb_read_status_frequency | 10000 |
| tokudb_row_format | tokudb_fast |
| 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.6.31-77.0 |
| tokudb_write_status_frequency | 1000 |
+-----------------------------------------+-------------------------+
64 rows in set (0.00 sec)
mysql> use test;
Database changed
mysql> create table test1 ( id int not null primary key , c_name char(10) not null) engine=tokudb;
Query OK, 0 rows affected (0.02 sec)
mysql>