CentOS 5.8にコンパイル済みのTokuDB入りMySQLをインストールするよ
これはすんなりいきましたよ。
参照したのは
Documentation, Collateral and White Papers | Tokutek
の
TokuDB for MySQL 5.5 Users Guide(pdf)
基本的にはデフォルトだと/usr/local/mysqlにインストールする作りになってました。
あと、あらかじめmysqlユーザーとか作っておいてね。
インストール環境
# cat /etc/redhat-release CentOS release 5.8 (Final) # uname -a Linux hostname 2.6.18-308.13.1.el5 #1 SMP Tue Aug 21 17:10:18 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
手順
ダウンロードと解凍
TokuDB Community Edition Downloads | Tokutek
の
TokuDB 7.1.5 for MySQL 5.5.36, 64-bit Linux
をダウンロード
/usr/local/src
に設置
からの
# cd /usr/local/src # tar zxvf ./mysql-5.5.36-tokudb-7.1.5-linux-x86_64.tar.gz # mv ./mysql-5.5.36-tokudb-7.1.5-linux-x86_64 /usr/local/mysql
my.cnf設定
好きなので良いと思うんですが
# cd /usr/local/mysql # cp ./support-files/my-innodb-heavy-4G.cnf ./my.cnf # vi ./my.cnf ここで文字コード設定や必要な設定を
MySQL初期設定
# cd /usr/local/mysql # ./scripts/mysql_install_db \ --user=mysql chown -R mysql:mysql .
mysqld立ち上げ
# /usr/local/mysql/support-files/mysql.server start
ここで
mysql error while loading shared libraries: libaio.so.1: cannot open shar ed object file: No such file or directory
というエラーが出たので
yum -y install libaio libaio-devel
足りないモジュールをyumでインストール。
で、再度スタート
# cd /usr/local/mysql # ./support-files/mysql.server start
MySQL起動確認
# ps aux | grep mysql root 31436 0.0 0.0 64016 1284 pts/0 S 17:02 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/hostname.pid mysql 32090 1.4 2.3 3019076 288036 pts/0 Sl 17:02 0:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/hostname.err --open-files-limit=8192 --pid-file=/usr/local/mysql/data/hostname.pid --socket=/tmp/mysql.sock --port=3306
立ち上がってる!
TokuDB確認
# /usr/local/mysql/bin/mysql mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MyISAM | DEFAULT | MyISAM storage engine | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | TokuDB | YES | Tokutek 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 | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ mysql> show plugins; | TokuDB | ACTIVE | STORAGE ENGINE | 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_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あった!
show enginesでTokuDBが無かった場合
# /usr/local/mysql/bin/mysql mysql> install plugin tokudb soname 'ha_tokudb.so'; mysql> install plugin tokudb_file_map soname 'ha_tokudb.so'; mysql> install plugin tokudb_fractal_tree_info soname 'ha_tokudb.so'; mysql> install plugin tokudb_fractal_tree_block_map soname 'ha_tokudb.so'; mysql> install plugin tokudb_trx soname 'ha_tokudb.so'; mysql> install plugin tokudb_locks soname 'ha_tokudb.so'; mysql> install plugin tokudb_lock_waits soname 'ha_tokudb.so';
TokuDB用に設定ファイル更新
デフォルトのストレージエンジンをTokuDBに
・my.cnf書き換え # vi /usr/local/mysql/my.cnf > default-storage-engine = MYISAM < default-storage-engine = TokuDB ・再起動 # /usr/local/mysql/support-files/mysql.server restart Shutting down MySQL... SUCCESS! Starting MySQL.. SUCCESS! ・確認 # /usr/local/mysql/bin/mysql mysql> use test; mysql> CREATE TABLE `create_test` ( `hoge` int(10) unsigned NOT NULL DEFAULT '0', `fuga` varchar(120) NOT NULL DEFAULT '' ); *************************** 1. row *************************** Table: create_test Create Table: CREATE TABLE `create_test` ( `hoge` int(10) unsigned NOT NULL DEFAULT '0', `fuga` varchar(120) NOT NULL DEFAULT '' ) ENGINE=TokuDB DEFAULT CHARSET=latin1 mysql> INSERT INTO create_test(`hoge`, `fuga`) VALUES(1,'foo'); Query OK, 1 row affected (0.04 sec) mysql> SELECT * FROM `create_test`; +------+------+ | hoge | fuga | +------+------+ | 1 | foo | +------+------+ mysql> show create table `create_test`\G;
できましたね!
複数のバージョンのMySQLを扱う為に
ダウンロードと解凍の時点で、違うディレクトリに設置
例) /usr/local/mysqls/mysql_tokudb_built
my.cnf設定の前にファイル書き換え
/usr/local/mysql -> /usr/local/mysqls/mysql_tokudb_built /tmp/mysql.sock -> /tmp/mysql_tokudb_built.sock
対象ファイルは/usr/local/mysqls/mysql_tokudb_built以下の
bin/mysqld_safe bin/msql2mysql bin/mysqlaccess bin/mysql_config bin/mysqld_multi docs/INFO_BIN include/my_config.h include/mysql_version.h support-files/my-large.cnf support-files/my-huge.cnf support-files/mysql.server support-files/my-innodb-heavy-4G.cnf support-files/my-medium.cnf support-files/mysql-log-rotate support-files/my-small.cnf
です。
まあこんな感じで書き換えて
cd /usr/local/mysqls/mysql_tokudb_built perl -pi -e 's!/usr/local/mysql!/usr/local/mysqls/mysql_tokudb_built!g;s!/tmp/mysql.sock!/tmp/mysql_tokudb_built.sock!g' \ bin/mysqld_safe \ bin/msql2mysql \ bin/mysqlaccess \ bin/mysql_config \ bin/mysqld_multi \ docs/INFO_BIN \ include/my_config.h \ include/mysql_version.h \ support-files/my-large.cnf \ support-files/my-huge.cnf \ support-files/mysql.server \ support-files/my-innodb-heavy-4G.cnf \ support-files/my-medium.cnf \ support-files/mysql-log-rotate \ support-files/my-small.cnf
他には、my.cnfのserver-id変更やポート番号変更、
MySQL初期化作業の際に
/usr/local/mysqls/mysql_tokudb_built/scripts/mysql_install_db \ --basedir=/usr/local/mysqls/mysql_tokudb_built \ --user=mysql
とする位であとは同様の流れです。
なお、/usr/local/mysqls/mysql_tokudb_built/bin/mysqlで起動する場合、毎回socketファイルを指定してあげる必要があります。
/usr/local/mysqls/mysql_tokudb_built/bin/mysql --socket=/tmp/mysql_tokudb_built.sock