安裝TokuDB 1, 建立mysql數據目錄 #順便把臨時目錄建立好 mkdir -p /data/mysql/tmp groupadd -r mysql useradd -g mysql -r -s /sbin/nologin -M -d /data/mysql mysql chown -R mysql:mysql /data/mysql 2, 編輯配置文件vim /etc/my.cnf [mysqld] datadir=/data/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 bind-address=xx(替換爲內網IP地址) #unique_checks=OFF #tokudb_commit_sync=OFF #tokudb_fsync_log_period=1000 max_connections=1000 #default-storage-engine=TokuDB #先把這一條配置註釋掉,由於這時候還沒安裝TokuDB,不註釋的話mysql會啓動失敗,等安裝完TokuDB引擎後再打開這行配置 tmpdir=/data/mysql/tmp/ #修改臨時數據存放目錄(默認是tmp下面,若是查日誌時臨時數據比較大的話會差不到,會報警磁盤不夠。) [mysqld_safe] thp-setting=never log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid 3, 安裝 yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm yum install Percona-Server-tokudb-56.x86_64 4, 啓動 # (如需安裝多實例)初始化數據庫實例並啓動數據庫 # /usr/bin/mysql_install_db --user=mysql --datadir=/data/mysql_toku_3307 --basedir=/usr/ --defaults-file=/data/mysql_toku_3307/my.cnf & # /usr/bin/mysqld_safe --defaults-file=/data/mysql_toku_3307/my.cnf --user=mysql & # mysql_install_db 4.1初始化數據庫: /usr/bin/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/ service mysql start 5, 增長用戶 echo "insert into mysql.user (Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values('%','xx',password('xx'),'','','');grant all privileges on *.* to 'xx'@'%' identified by 'xx';flush privileges; " | mysql -uroot 6, 安裝TokuDB引擎 ps_tokudb_admin --enable -uxx -pxx -h內網IP地址 7, 設置TokuDB爲默認引擎 SET global default_storage_engine=TokuDB; (須要從新登陸mysql才能看到生效) 8, 查看是否安裝成功 show engines; 查看版本 SELECT @@tokudb_version; 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 | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | TokuDB | DEFAULT | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES | #看這個 | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | InnoDB | YES | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES | +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+ 10 rows in set (0.00 sec) mysql> SELECT @@tokudb_version; +------------------+ | @@tokudb_version | +------------------+ | 5.6.38-83.0 | #看版本 +------------------+ 1 row in set (0.00 sec) 9.修改系統文件描述符的數量 vim /etc/security/limits.conf * soft nproc 655300 * hard nproc 655300 * soft nofile 655300 * hard nofile 655300 10.把/etc/my.cnf 裏面的#default-storage-engine=TokuDB 註釋打開並重啓mysql /etc/init.d/mysql restart