AWSのEC2インスタンスにmroongaをインストールするまでの話


# 目次

RDSは便利なのですが、mroongaで全文検索やりたい場合は、EC2インスタンスにスレーブサーバをつくって、それでやるしかないなと思って、すぐにできるだろうと思ったら、そうは行かなかったというログの記録です。

1. AmazonLinuxでインストールしようとしたが失敗
2. ならば、マシンイメージをLinux7.1にしてみてインストール
3. 使えるようになりました

## 0.インストール手順
インストール手順は公式ページを参考にして実行します。
http://mroonga.org/ja/docs/install/centos.html#centos-6-with-the-official-mysql-package


## 1. AmazonLinuxでインストールしようとしたが失敗

groongaパッケージのインストールは成功

```
#  sudo yum install -y http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
```
その次が失敗

```
#  sudo yum install -y http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

Loaded plugins: priorities, update-motd, upgrade-helper
Existing lock /var/run/yum.pid: another copy is running as pid 2467.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  32 M RSS (242 MB VSZ)
    Started: Thu Nov 19 01:06:07 2015 - 00:01 ago
    State  : Running, pid: 2467
mysql-community-release-el6-5.noarch.rpm                                                         | 5.7 kB     00:00
Examining /var/tmp/yum-root-gHgQbE/mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking /var/tmp/yum-root-gHgQbE/mysql-community-release-el6-5.noarch.rpm to be installed
Resolving Dependencies
http://packages.groonga.org/centos/latest/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.


 One of the configured repositories failed (Groonga for CentOS latest - x86_64),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable groonga

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=groonga.skip_if_unavailable=true

failure: repodata/repomd.xml from groonga: [Errno 256] No more mirrors to try.
```

## 2. ならば、マシンイメージをLinux7.1にしてみてインストール

らちがあかなさそうなので、マシンイメージを変更してみた。
順調にインストールできていたかと思ったら、

mysql-community-mroonga
のインストールでエラー発生。

インストールしようとしているmysql-community-mroongaに対して
mysql-community-serverのバージョンが少し古いようです。

```
#  yum install -y mysql-community-mroonga
Loaded plugins: amazon-id, rhui-lb
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-mroonga.x86_64 0:5.09-1.el7.centos will be installed
--> Processing Dependency: mysql-community-client = 5.6.27-2.el7 for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Processing Dependency: mysql-community-server = 5.6.27-2.el7 for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Processing Dependency: groonga-libs >= 5.0.2 for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Processing Dependency: groonga-normalizer-mysql for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Processing Dependency: libgroonga.so.0()(64bit) for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Running transaction check
---> Package groonga-libs.x86_64 0:5.0.9-1.el7.centos will be installed
---> Package groonga-normalizer-mysql.x86_64 0:1.1.0-1.el7.centos will be installed
---> Package mysql-community-mroonga.x86_64 0:5.09-1.el7.centos will be installed
--> Processing Dependency: mysql-community-client = 5.6.27-2.el7 for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Processing Dependency: mysql-community-server = 5.6.27-2.el7 for package: mysql-community-mroonga-5.09-1.el7.centos.x86_64
--> Finished Dependency Resolution
Error: Package: mysql-community-mroonga-5.09-1.el7.centos.x86_64 (groonga)
           Requires: mysql-community-server = 5.6.27-2.el7
           Installed: mysql-community-server-5.6.27-2.el6.x86_64 (@mysql56-community)
               mysql-community-server = 5.6.27-2.el6
           Available: mysql-community-server-5.6.15-1.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.15-1.el6
           Available: mysql-community-server-5.6.16-1.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.16-1.el6
           Available: mysql-community-server-5.6.17-4.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.17-4.el6
           Available: mysql-community-server-5.6.19-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.19-2.el6
           Available: mysql-community-server-5.6.20-4.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.20-4.el6
           Available: mysql-community-server-5.6.21-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.21-2.el6
           Available: mysql-community-server-5.6.22-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.22-2.el6
           Available: mysql-community-server-5.6.23-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.23-2.el6
           Available: mysql-community-server-5.6.24-3.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.24-3.el6
           Available: mysql-community-server-5.6.25-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.25-2.el6
           Available: mysql-community-server-5.6.26-2.el6.x86_64 (mysql56-community)
               mysql-community-server = 5.6.26-2.el6

```

状況確認

```
#  yum list installed | grep mysql
mysql-community-client.x86_64
                           5.6.27-2.el6        @mysql56-community
mysql-community-common.x86_64
                           5.6.27-2.el6        @mysql56-community
mysql-community-libs.x86_64
                           5.6.27-2.el6        @mysql56-community
mysql-community-release.noarch
                           el6-7               @/mysql-community-release-el6-7.noarch
mysql-community-server.x86_64
                           5.6.27-2.el6        @mysql56-community
```

そのため、mysql-communityパッケージをアップデートしなおしてからインストールをかけなおしました。


```                         
#  sudo /sbin/service mysqld stop

Stopping mysqld (via systemctl):                           [  OK  ]

#  yum install -y http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
```   

## 3. 使えるようになりました

インストール手順としてはこうですね（2015/11/19現在）
EC2インスタンスは、Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type - ami-12663b7a

```bash: 
sudo yum install -y http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
  
yum install -y http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
 
sudo yum makecache
sudo yum install -y mysql-community-server
sudo /sbin/service mysqld start
sudo yum install -y mysql-community-mroonga
(% sudo mysqladmin -u root password 'new-password')
```