LoginSignup
11
10

More than 5 years have passed since last update.

CentOS 6.5にMariaDB+Mroonga をインストールする

Posted at

はじめに

2014/11にリリースされたMariaDB 10.0.15から、Mroongaがバンドルされるようになりました。やったー!参考

となりましたが、直前までソースからのインストールを試していたので、2014年納めとして記事にしてみます。

事前準備

make, cmakeに必要なものをインストールしておきます。

$ sudo yum -y install openssl-devel libevent-devel ncurses-devel cmake make

MariaDBをインストールする

ソースのダウンロード

Mroongaが対応しているMariaDBのソースを取ってくる。
※最新版でのインストールがうまくできなかったため、少し前のバージョンになっております。

$ cd ~/src
$ wget --passive https://downloads.mariadb.org/f/mariadb-10.0.13/source/mariadb-10.0.13.tar.gz
$ tar zxvf mariadb-10.0.13.tar.gz

ソースのビルド&インストール

$ cd mariadb-10.0.13
$ cmake . \
   -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
   -DDEFAULT_CHARSET=utf8 \
   -DDEFAULT_COLLATION=utf8_general_ci \
   -DENABLED_LOCAL_INFILE=true \
   -DWITH_INNOBASE_STORAGE_ENGINE=1 \
   -DWITH_EXTRA_CHARSETS=all \
   -DWITH_READLINE=ON

$ make
$ sudo make install

インストール後の諸設定

mysqlユーザを追加して、権限を設定します。

$ sudo groupadd -g 27 mysql
$ sudo useradd -u 27 -g 27 -M -d /usr/local/mysql -s /bin/bash mysql

$ cd /usr/local/mysql
$ sudo chown -R mysql. .

$ sudo mkdir /var/lib/mysql
$ sudo chown -R mysql. /var/lib/mysql

初期設定を行います。

$ sudo cp /etc/my.cnf /etc/my.cnf.org
$ sudo vi /etc/my.cnf                      # 環境に合わせて適宜変更

$ sudo scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql --defaults-file=/etc/my.cnf
$ sudo cp support-files/mysql.server /etc/init.d/mysql

MariaDB起動

$ sudo /etc/init.d/mysql start

環境変数設定ファイルを編集してパスを通しておきます。
/etc/profileの最終行に追記。

$ sudo vi /etc/profile

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

パスを有効化。

$ source /etc/profile

ログイン確認。

$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.13-MariaDB-log Source distribution

Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

rootのパスワードを設定しておきます。

MariaDB

MariaDB [(none)]> use mysql;
MariaDB [mysql]> SET PASSWORD FOR root@localhost=PASSWORD('xxxxxx');
MariaDB [mysql]> delete from user where User='root' and Password='';

サービス登録もしておきます

$ sudo chkconfig --add mysql
$ sudo chkconfig mysql on
$ sudo chkconfig --list mysql    # 2,3,4,5 がonになっていればOK
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Mroongaのインストール

公式の手順に従って粛々と進めます。

Groongaのインストール

まずはGroongaのリポジトリを指定して、yumでGroongaをインストールします。

$ sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
$ sudo yum makecache
$ sudo yum install -y groonga groonga-devel

MySQL互換のノーマライザーもMroongaを使うために必須なので入れておきます。
groonga-normalizer-mysql-develの方を入れておかないとMroongaでnormalizerが使用できないようです。

$ sudo yum install -y groonga-normalizer-mysql groonga-normalizer-mysql-devel

ソースのダウンロード

Mroongaのソースをとってきます。

$ cd ~/src
$ wget http://packages.groonga.org/source/mroonga/mroonga-4.08.tar.gz
$ tar xvzf mroonga-4.08.tar.gz

ソースのビルド&インストール

configureで指定しているwith-mysql-sourceはMariaDBのソースの展開先を絶対パスで指定してください。

$ cd mroonga-4.08

$ ./configure \
    --with-mysql-source=/home/vagrant/src/mariadb-10.0.13 \
    --with-mysql-config=/usr/local/mysql/bin/mysql_config
$ make
$ sudo make install

MroongaをMySQLに登録します。

$ mysql -u root -p < /usr/local/share/mroonga/install.sql

インストールの確認

SHOW ENGINESでMroongaが確認できていればOKです。

MariaDB
MariaDB [(none)]> SHOW ENGINES;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                                         | NO           | NO   | NO         |
| MRG_MyISAM         | YES     | Collection of identical MyISAM tables                                      | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| Mroonga            | YES     | CJK-ready fulltext search, column store                                    | NO           | NO   | NO         |
| Aria               | YES     | Crash-safe tables with MyISAM heritage                                     | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

インストール完了です。
チュートリアルにあるSQLを投げてみて、SQLエラーやワーニングが出ないことを確認してください。

normalizerの挙動を確認する場合、こちらで紹介されている動作サンプルが参考になりました。

参考サイト

Mroonga ドキュメント
CentOS 6.5 - DB サーバ MariaDB 構築(ソースインストール)!
MariaDBをソースからインストールする方法

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10