どうも、俺@残業中です。
今日はMySQLの全文検索エンジンmroonga(v2.03)をインストールする方法をメモメモ。
超簡単です。
公式サイトは
こちら。
MySQL(v5.5.25)はインストール済みとします。(今度こっちのインストール方法もメモメモしとかな)
まずはgroongaインストール。(yumインストール)
# rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-0.noarch.rpm
# yum install groonga-devel
ちなみにgroongaをソースからインストールする場合は
# yum install mecab-devel
しておいて
# wget http://packages.groonga.org/source/groonga/groonga-2.0.3.tar.gz
# tar zxvf groonga-2.0.3.tar.gz
# cd groonga-2.0.3
# ./configure
# make -j$(grep '^processor' /proc/cpuinfo | wc -l)
# mak install
とします。
※未検証です。
ここを参考にしてみてください。
次に辞書をインストール。(MeCabの辞書)ソースインストールした場合はmecab-develの中に入ってるかも?
# yum install mecab-ipadic
ここまででとりあえずgroongaはインストールされました。
/usr/lib以下にgroongaというディレクトリが出来てると思います。
いよいよmroongaインストール。
# wget 'https://github.com/downloads/mroonga/mroonga/mroonga-2.03.ta.gz'
# tar zxvf mroonga-2.03.ta.gz
# cd mroonga-2.03
configureしてmakeしてmake installします。
# ./configure --with-mysql-source=/path/to/mysql --with-mysql-config=/path/to/mysql/bin/mysql_config --with-default-parser=TokenMecab
# make
# make install
これでMySQLのプラグインディレクトリ以下にha_mroonga.soが生成されます。
例)/usr/local/mysql-5.5.25/lib/plugin/ha_groonga.so
mysqldを起動または再起動してmysqlにログインします。
# /path/to/mysql/bin/mysql
mysql> INSTALL PLUGIN mroonga SONAME 'ha_mroonga.so';
mysql> SHOW ENGINES;
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| mroonga | YES | CJK-ready fulltext search, column store | NO | NO | NO |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
7 rows in set (0.02 sec)
Yes!インストールでけた!
あとはCREATE TABLEする時に
ENGINE=mroonga;
をつけてね!
以上でぇぇぇえぇす。