Mroongaインストール(対象：MySQL5.5, MySQL5.6, Maria5.5, Maria10)


MroongaをMySQL5.5, MySQL5.6, Maria5.5, Maria10へインストールしたときのメモ 

環境はCentOS6.5, 設定はほぼデフォルト、なるべくDebugモード.

## インストール順番

1) DB
2) Groonga
3) groonga-normalizer-mysql
4) Mroonga


## Configure設定

### MySQL5.5 (DEBUG MODE)

```
cmake . -DCMAKE_INSTALL_PREFIX=$HOME/db/mysql55 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=yes
```

### MySQL5.6 (DEBUG MODE)

```
cmake . -DCMAKE_INSTALL_PREFIX=$HOME/db/mysql56 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=yes
```

### MariaDB5.5

```
cmake . -DCMAKE_INSTALL_PREFIX=$HOME/db/maria55 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
```

### MariaDB10.0

```
cmake . -DCMAKE_INSTALL_PREFIX=$HOME/db/maria10 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 
```

### Groonga (DEBUG MODE)

```
./configure  CFLAGS="-O0 -g3" CXXFLAGS="-O0 -g3" --enable-debug
```

### groonga-normalizer-mysql

```
./configure CFLAGS="-O0 -g3" CXXFLAGS="-O0 -g3" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
```


### Mroonga (MySQL5.5用, DEBUGモード)

```
./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CFLAGS="-g3 -O0" CXXFLAGS="-g3 -O0" --with-debug --prefix=$HOME/db/mysql55 --with-mysql-source=$HOME/db_src/mysql-5.5.36 --with-mysql-config=$HOME/db/mysql55/bin/mysql_config
```

### Mroonga (MySQL5.6用, DEBUGモード)

```
./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CFLAGS="-g3 -O0" CXXFLAGS="-g3 -O0" --with-debug --prefix=$HOME/db/mysql56 --with-mysql-source=$HOME/db_src/mysql-5.6.16 --with-mysql-config=$HOME/db/mysql56/bin/mysql_config
```

### Mroonga (MariaDB5.5用)

```
./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CFLAGS="-g3 -O0" CXXFLAGS="-g3 -O0" --prefix=$HOME/db/maria55 --with-mysql-source=$HOME/db_src/mariadb-5.5.35 --with-mysql-config=$HOME/db/maria55/bin/mysql_config
```

#### Mroonga (MariaDB10.0用)

```
./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CFLAGS="-g3 -O0" CXXFLAGS="-g3 -O0" --prefix=$HOME/db/maria10 --with-mysql-source=$HOME/db_src/mariadb-10.0.8 --with-mysql-config=$HOME/db/maria10/bin/mysql_config
```

## DB 設定

### MySQL5.5

```
cp support-files/my-small.cnf my.cnf

./scripts/mysql_install_db --basedir=$HOME/db/mysql55 --defaults-file=$HOME/db/mysql55/my.cnf --datadir=$HOME/db/mysql55/data  --log-error=$HOME/db/mysql55/log/log.err --pid-file=$HOME/tmp/mysql55.pid
```

起動

```
./bin/mysqld_safe --defaults-file=$HOME/db/mysql55/my.cnf --basedir=$HOME/db/mysql55 --datadir=$HOME/db/mysql55/data --log-error=$HOME/db/mysql55/log/log.err --pid-file=$HOME/tmp/mysql55.pid &
```

### MySQL5.6

```
cp support-files/my-default.cnf my.cnf

./scripts/mysql_install_db --basedir=$HOME/db/mysql56 --defaults-file=$HOME/db/mysql56/my.cnf --datadir=$HOME/db/mysql56/data --log-error=$HOME/db/mysql56/log/log.err --pid-file=$HOME/tmp/mysql56.pid
```

起動

```
./bin/mysqld_safe --defaults-file=$HOME/db/mysql56/my.cnf --basedir=$HOME/db/mysql56 --datadir=$HOME/db/mysql56/data  --log-error=$HOME/db/mysql56/log/log.err --pid-file=$HOME/tmp/mysql56.pid &
```

### Maria5.5

```
cp support-files/my-small.cnf my.cnf

./scripts/mysql_install_db --basedir=$HOME/db/maria55 --defaults-file=$HOME/db/maria55/my.cnf --datadir=$HOME/db/maria55/data  --log-error=$HOME/db/maria55/log/log.err --pid-file=$HOME/tmp/maria55.pid
```

起動

```
./bin/mysqld_safe  --defaults-file=$HOME/db/maria55/my.cnf --basedir=$HOME/db/maria55 --datadir=$HOME/db/maria55/data  --log-error=$HOME/db/maria55/log/log.err --pid-file=$HOME/tmp/maria55.pid &
```

### Maria10.0

```
cp support-files/my-small.cnf my.cnf

./scripts/mysql_install_db --basedir=$HOME/db/maria10 --defaults-file=$HOME/db/maria10/my.cnf --datadir=$HOME/db/maria10/data  --log-error=$HOME/db/maria10/log/log.err --pid-file=$HOME/tmp/maria10.pid
```

起動

```
./bin/mysqld_safe  --defaults-file=$HOME/db/maria10/my.cnf --basedir=$HOME/db/maria10 --datadir=$HOME/db/maria10/data  --log-error=$HOME/db/maria10/log/log.err --pid-file=$HOME/tmp/maria10.pid &
```

終了

```
bin/mysqladmin -uroot shutdown
```

## MroongaをDBへ導入

それぞれのDBを起動して、クライアント接続してMroongaをそれぞれのDBに導入する

```
mysql -uroot 

INSTALL PLUGIN mroonga SONAME 'ha_mroonga.so';
CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';
CREATE FUNCTION mroonga_snippet RETURNS STRING SONAME 'ha_mroonga.so';
CREATE FUNCTION mroonga_command RETURNS STRING SONAME 'ha_mroonga.so';
CREATE FUNCTION mroonga_escape RETURNS STRING SONAME 'ha_mroonga.so';
```