[groonga-dev,00851] groongaのビルド方法のドキュメンテーションを改善してください

Back to archive index

磯部 和広 k-iso****@rozet*****
2012年 5月 14日 (月) 19:29:00 JST


いつもお世話になっております。

教えて頂いたオプションでビルドし直し、期待通りの動作になりました。
ありがとうございます!

さて、首題の件なのですが・・・

■概要■

1. 「groongaの」ソースからのインストール方法が記載されていません
2. makeの際の多重度を指定した方が早くなるので記載すべきではないでしょうか?
3. mroongaのmake方法が正しくないです・・・

下記、経緯と詳細です

ドキュメンテーションの改善の為に、手順化しておきました。
※CentOS等のRedHat系用ですが
※一か所、自分のユーザー名「k-isobe」が出現しています

■詳細■

>少し面倒なのですが、 groongaを
>--with-match-escalation-threshold=-1付きで
>configure してビルドするとそのような挙動にできます。

下記を参考に作業しました。

2.11. ソースコードからのインストール
http://mroonga.github.com/ja/docs/install.html#install-from-the-source-code

が、何故かダウンロードしたMySQLのソースが腐っており、tarで展開できません
でした。
※WindowsのPCにてダウンロードし、SCPでサーバーに転送したのですが・・・
※ダウンロードの試行錯誤だけで1時間を無駄にしました・・・
※日本の2サイト、USの1サイトで同じ腐り方をしていました。

MySQLのビルドについては、下記を参考にしました。

mysql-5.5.15をソースからインストール
http://d.hatena.ne.jp/hekyou/20110905/p1

このように、Linuxからwgetすると大丈夫なようです。

※これはmroongaではなくMySQLの問題ですが、ソースの取得やコンパイルも
 面倒なので、ドキュメンテーションに載っていると良いかな、と思いました。

ちなみに、下記手順となります。
=====================================
sudo yum -y install cmake ncurses-devel bison
CPUs=$(egrep '^processor' /proc/cpuinfo | wc -l)
mkdir -p ~/GZ
cd ~/GZ
wget
http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.24.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
cd /dev/shm
tar xzf ~/GZ/mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
make -j$(expr $CPUs + 1)
cd ..
sudo chown k-isobe /usr/local/src
mv mysql-5.5.24 /usr/local/src/
if (! grep mysql /etc/group) ; then sudo groupadd mysql ; fi
if (! grep mysql /etc/passwd) ; then sudo useradd mysql -g mysql -s
/sbin/nologin ; fi
sudo /usr/local/mysql/scripts/mysql_install_db
--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
sudo chown -R mysql:mysql /usr/local/mysql
if [ ! -f /etc/my.cnf ] ; then sudo cp
/usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf ; fi
if ( ! grep innodb_file_per_table /etc/my.cnf) ; then sudo sed -i -e
's/\[mysqld\]/\[mysqld\]\ninnodb_file_per_table/' /etc/my.cnf ; fi
if [ ! -f /etc/init.d/mysqld ] ; then sudo cp
/usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld ; \
sudo chmod +x /etc/rc.d/init.d/mysqld ; sudo chkconfig --add mysqld ;
sudo chkconfig mysqld on ; sudo /etc/rc.d/init.d/mysqld start ; fi
=====================================

※cmakeというのを今回初めて知りました。
 makeの際の出力が、色々な色で出てきて面白かったです・・・
※手順の「sudo chown k-isobe /usr/local/src」は汎用的では無いですね・・・
すいません


が、groongaのサイトのインストールのページを見ても、ソースからのインス
トール方法がありません。

2. インストール
http://groonga.org/ja/docs/install.html

色々検索して、何とか下記に辿りつき、ソースを入手しました。

wget http://packages.groonga.org/source/groonga/groonga-2.0.2.tar.gz
<https://github.com/mroonga/mroonga/downloads>

ビルドは下記手順で行いました。
=====================================
cd ~/GZ
wget http://packages.groonga.org/source/groonga/groonga-2.0.2.tar.gz
cd /dev/shm
tar xzf ~/GZgroonga-2.0.2.tar.gz
cd groonga-2.0.2
./configure --with-match-escalation-threshold=-1
echo $?
make -j$(expr $CPUs + 1)
sudo make install
echo $?
cd ..
mv groonga-2.0.2 /usr/local/src/
=====================================
これは問題無いです。

makeの際の-j(Jobs)オプションは、CPU数+1とCPU数+2の
2つの説がありますが、今回は保守的に+1としました。

が、mroongaのconfigureが下記エラーで失敗します。

checking for GROONGA... no
configure: error: Package requirements (groonga >= 2.0.2) were not met:

No package 'groonga' found

これに関しては、下記を参考にしました。

MySQL 5.5 に mroonga を組込む
http://d.hatena.ne.jp/takjoe/20120109/1326114952

で、configureを下記に変更しました。

GROONGA_CFLAGS="-I/usr/local/src/groonga-2.0.2/include" \
GROONGA_LIBS="-L/usr/lib -lgroonga" \
./configure \
--with-mysql-source=/usr/local/src/mysql-5.5.24 \
--with-mysql-config=/usr/local/mysql/bin/mysql_config

で、ようやくビルド出来ました。

手順は下記となります。
=====================================
cd ~/GZ
wget https://github.com/downloads/mroonga/mroonga/mroonga-2.02.tar.gz
cd /dev/shm
tar xzf ~/GZ/mroonga-2.02.tar.gz
cd mroonga-2.02/
GROONGA_CFLAGS="-I/usr/local/src/groonga-2.0.2/include" \
GROONGA_LIBS="-L/usr/lib -lgroonga" \
./configure \
--with-mysql-source=/usr/local/src/mysql-5.5.24 \
--with-mysql-config=/usr/local/mysql/bin/mysql_config
make -j$(expr $CPUs + 1)
sudo make install
echo $?
cd ..
mv mroonga-2.02 /usr/local/src/
=====================================

■動作検証■

下記のように、正しく動作します。
ありがとうございました!

※下記で使われている「tables」「desc」「do_sql」「count」は
  自作のコマンドライン用SQLラッパーです。

[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ export DB=test
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ tables
test_data
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ desc test_data
+-------------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+------+------+-----+---------+-------+
| english | text | NO | MUL | NULL | |
| japanese | text | NO | | NULL | |
| japanese_splitted | text | NO | MUL | NULL | |
+-------------------+------+------+-----+---------+-------+
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ do_sql "truncate table test_data"
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ do_sql "insert into test_data
values('inflammable liquid','引火性液体','引火性 液体')"
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ SQL_COMMON_J="test_data where
match(japanese_splitted) against"
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ for s in 引 引火 引火性 火 火性 性 ;
do echo -e "$s\t" $(count "$SQL_COMMON_J ('\"$s\"' in boolean mode)"); done
引 0
引火 0
引火性 1
火 0
火性 0
性 0
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ SQL_COMMON_E="test_data where
match(english) against"
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$ for s in i in inf inflamm inflammable
nf able ; do echo -e "$s\t" $(count "$SQL_COMMON_E ('\"$s\"' in boolean
mode)"); done
i 0
in 0
inf 0
inflamm 0
inflammable 1
nf 0
able 0
[k-isobe @ PMJ-MySQL1 mroonga-2.02]$



groonga-dev メーリングリストの案内
Back to archive index