最近サボり気味

[Ubuntu][MySQL] Ubuntu+Senna+MySQLで全文検索エンジンの設定

6月 24th, 2008 Posted in MySQL, ubuntu

UbuntuにSennaを使ってMySQLで全文検索を行うためのインストールを行いました。

○MeCabインストール

以下よりソースをダウンロード

$ tar zxvf mecab-0.97.tar.gz
$ cd mecab-0.97
$ ./configure --with-charset=utf8 (※下記参照)
$ make
$ su
$ sudo make install

※configureで以下のようなエラーが出たら
checking if g++ supports namespaces (required) ... no
checking if g++ environment provides all required features... no
configure: error: Your compiler is not powerful enough to compile MeCab.
If it should be, see config.log for more information of why it failed.

これを実行して再度configureする

$ sudo apt-get install g++

○IPA辞書をインストール

以下よりソースをダウンロード(mecab-ipadic)

$ tar zxvf mecab-ipadic-2.7.0-20070801.tar.gz
$ cd mecab-ipadic-2.7.0-20070801
$ ./configure --with-charset=utf8
$ make (※下記参照)
$ su
$ sudo make install

※makeで以下のようなエラーが出たら

"/usr/local/libexec/mecab/mecab-dict-index: error while loading shared libraries: libmecab.so.1: cannot open shared object file: No such file or directory"

以下を実行

$ sudo ldconfig

それからmakeを行なってください

○Sennaインストール

以下よりソースをダウンロード

$ tar zxvf senna-1.1.3.tar.gz
$ cd senna-1.1.3
$ ./configure  --prefix=/usr
$ make
$ su
$ sudo make install

文字コードのエンコードを設定

$ mkdir /var/senna
$ vi /var/senna/senna.conf

として、senna.confに

DEFAULT_ENCODING utf-8

の記述を追加する。

○MySQLのインストール

・インストール

以下よりソースをダウンロード。
今回はソースからビルドする(tritonn.1.0.10-mysql-5.0.51a.tar.gz)

$ tar zxvf tritonn-1.0.10-mysql-5.0.51a.tar.gz
$ cd tritonn-1.0.10-mysql-5.0.51a
(以下、オプションは参考で)
$ CXXFLAGS="-I/usr/local/include" \
  LDFLAGS="-L/usr/local/lib" \
  ./configure \
  --prefix=/usr/local/mysql \
  --with-senna \
  --enable-assembler \
  --with-charset=utf8 \
  --with-unix-socket-path=/var/lib/mysql/mysql.sock \
  --with-mysqli=/usr/local/mysql/bin/mysql_config \
  --enable-embedded-mysqli \
  --with-embedded-server \
  --with-extra-charsets=binary,utf8,cp932,eucjpms,ujis,ucs2,latin1,sjis \
  --without-readline \
  --enable-thread-safe-client
$ make
$ su
$ sudo make install

・初期設定

$ sudo groupadd mysql
$ sudo useradd mysql -g mysql -s /bin/false -d /home/mysql mysql
$ install -d -o mysql -g mysql -m 2750 /usr/local/mysql/data
$ install -d -o mysql -g mysql -m 2755 /var/lib/mysql

・MySQLの初期化(mysqlテーブルなど作成)

$ sudo ./scripts/mysql_install_db --user=mysql ls --datadir=/usr/local/mysql/data
$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-networking &
 
 (別ターミナルで)
$ sudo /usr/local/mysql/bin/mysqladmin -uroot password パスワード
$ /usr/local/mysql/bin/mysql -uroot -p
 (パスワード入力)
 mysql>
 (↑になれば成功)

・MySQLの起動

/etc/bash.bashrc や /etc/profile などに

export PATH=$PATH:/usr/local/mysql/bin

を追加。

$ sudo cp -p ./support-files/mysql.server /etc/init.d/mysql
$ sudo /etc/init.d/mysql start

自動で起動するようにも設定しておく。Ubuntuのデフォルトのランレベルは2だったので以下のように設定しました。

$sudo -sf /etc/init.d/mysql /etc/rc2.d/S50mysql

50の部分は適当に変えてください。chkconfigのようなコマンドを知らないのでこれで対応しました。
  1. 2 Responses to “[Ubuntu][MySQL] Ubuntu+Senna+MySQLで全文検索エンジンの設定”

  2. By Mario on 12月 28, 2009

    checking for termcap functions library… configure: error: No curses/termcap library found

    sudo apt-get install libncurses5-dev

    configure: error: Could not find system readline or libedit libraries
    Use –with-readline or –with-libedit to use the bundled
    versions of libedit or readline

    sudo apt-get install libreadline6-dev

    sed ‘/^#/ s|y\.tab\.c|sql_yacc.cc|’ y.tab.c >sql_yacc.cct && mv sql_yacc.cct sql_yacc.cc
    sed: can’t read y.tab.c: No such file or directory
    make[2]: *** [sql_yacc.cc] Error 2

  3. By Mario on 12月 28, 2009

    説明が素晴らしくて助かりました!

    先ほどコメントをまとめていた間に「Submit」を押してしまいました。

    Ubuntu9.10をインストールした直後の状態で、mecab0.98+senna1.1.4+tritonn1.0.12-mysql5.0.87をインストールしながら、以下のような問題が発生しました:

    checking for termcap functions library… configure: error: No curses/termcap library found

    と出ったら、以下を実行して、再度Configureする
    sudo apt-get install libncurses5-dev

    そして、以下のようなエラーが出ったら
    configure: error: Could not find system readline or libedit libraries
    Use –with-readline or –with-libedit to use the bundled
    versions of libedit or readline

    これを実行して、再度Configureする
    sudo apt-get install libreadline6-dev

    最後は、以下のようなものが出ったら
    sed ‘/^#/ s|y\.tab\.c|sql_yacc.cc|’ y.tab.c >sql_yacc.cct && mv sql_yacc.cct sql_yacc.cc
    sed: can’t read y.tab.c: No such file or directory
    make[2]: *** [sql_yacc.cc] Error 2

    sudo apt-get install bison
    を実行して、再度Configureする

    以上です。

Post a Comment