ぺーぺーSEのブログ

備忘録・メモ用サイト。

CouchbaseをDockerにインストール

CouchbaseはDocument型NoSQL。
Couchbase 2.5をDockerで構築してみる。
Docker環境については下記を参照。

blog.pepese.com


■Dockerfile

FROM centos

WORKDIR /tmp

RUN echo 'exclude=kernel*' >> /etc/yum.conf
RUN echo 'proxy=http://[proxy_FQDN]:[port]' >> /etc/yum.conf
RUN echo 'proxy_username=[username]' >> /etc/yum.conf
RUN echo 'proxy_password=[password]' >> /etc/yum.conf

RUN yum install -y pkgconfig
ENV http_proxy http://[username]:[password]@[proxy_FQDN]:[port]
ENV https_proxy https://[username]:[password]@[proxy_FQDN]:[port]
RUN wget http://packages.couchbase.com/releases/2.5.1/couchbase-server-enterprise_2.5.1_x86_64.rpm
RUN rpm --install couchbase-server-enterprise_2.5.1_x86_64.rpm
EXPOSE 4369 8091 8092 11209 11211 21100 21299

EXPOSEで指定したポート設定は適当。(ポートの範囲指定ってどうするんだ。。。?)

■Couchbase Serverが使用するポート

Port Description Node to Node Node to Client Cluster Administration XDCR
8091 Web Administration Port Yes Yes Yes Yes
8092 Couchbase API Port Yes Yes No Yes
11209 Internal Cluster Port Yes No No No
11210 Internal Cluster Port Yes Yes No No
11211 Client interface (proxy) Yes Yes No No
4369 Erlang Port Mapper ( epmd ) Yes No No No
21100 to 21199 (inclusive) Node data exchange Yes No No No

参考:http://docs.couchbase.com/couchbase-manual-2.0/

docker buildしてimageを作成。

[root@vagrant-centos65 couchbase]# docker build --no-cache --rm -t couchbase/centos .
Uploading context 3.072 kB
Uploading context
Step 0 : FROM centos
 ---> 539c0211cd76
Step 1 : WORKDIR /tmp
 ---> Running in 157b4bf1723e
 ---> d857d692838d
Step 2 : RUN echo 'exclude=kernel*' >> /etc/yum.conf
 ---> Running in 8aa671153f08
 ---> 058e4a648711
Step 3 : RUN echo 'proxy=http://[proxy_FQDN]:[port]' >> /etc/yum.conf
 ---> Running in e0a87e7ec88c
 ---> 0c428c00d10b
Step 4 : RUN echo 'proxy_username=[username]' >> /etc/yum.conf
 ---> Running in 1761af5838cc
 ---> 1c7cd568ebb5
Step 5 : RUN echo 'proxy_password=[password]' >> /etc/yum.conf
 ---> Running in e813025c2f7d
 ---> 7b088e80ab76
Step 6 : RUN yum install -y pkgconfig
 ---> Running in c1a93e041b5f
Loaded plugins: fastestmirror
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pkgconfig.x86_64 1:0.23-9.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch            Version                 Repository     Size
================================================================================
Installing:
 pkgconfig          x86_64          1:0.23-9.1.el6          base           70 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 70 k
Installed size: 137 k
Downloading Packages:
rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-4.el6.centos.10.x86_64 (@febootstrap/$releasever)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction

Installed:
  pkgconfig.x86_64 1:0.23-9.1.el6

Complete!
 ---> e08deebfd7cb
Step 7 : ENV http_proxy http://[username]:[password]@[proxy_FQDN]:[port]
 ---> Running in a6bba1827a8f
 ---> b1fb2d6c41be
Step 8 : ENV https_proxy https://[username]:[password]@[proxy_FQDN]:[port]
 ---> Running in aec0c0aafdde
 ---> 6001a359d719
Step 9 : RUN wget http://packages.couchbase.com/releases/2.5.1/couchbase-server-enterprise_2.5.1_x86_64.rpm
 ---> Running in d0eb2a22eb31
--2014-04-09 21:28:37--  http://packages.couchbase.com/releases/2.5.1/couchbase-server-enterprise_2.5.1_x86_64.rpm
163.135.17.8
connected.
200 OK
Length: 87817112 (84M) [application/x-redhat-package-manager]
Saving to: `couchbase-server-enterprise_2.5.1_x86_64.rpm'

.....  0%  238K 6m0s
....                                              100%  154K=3m58s

2014-04-09 21:32:41 (361 KB/s) - `couchbase-server-enterprise_2.5.1_x86_64.rpm' saved [87817112/87817112]

 ---> d96ab4d5def1
Step 10 : RUN rpm --install couchbase-server-enterprise_2.5.1_x86_64.rpm
 ---> Running in 971d4ee2b0e1
Minimum RAM required  : 4 GB
System RAM configured : 603580 kB

Minimum number of processors required : 4 cores
Number of processors on the system    : 1 cores

/etc/init.d/couchbase-server: line 47: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/couchbase-server: line 49: ulimit: max locked memory: cannot modify limit: Operation not permitted


You have successfully installed Couchbase Server.
Please browse to http://157b4bf1723e:8091/ to configure your server.
Please refer to http://couchbase.com for additional resources.

Please note that you have to update your firewall configuration to
allow connections to the following ports: 11211, 11210, 11209, 4369,
8091, 8092, 18091, 18092, 11214, 11215 and from 21100 to 21299.

By using this software you agree to the End User License Agreement.
See /opt/couchbase/LICENSE.txt.

 ---> 1aa1db704244
Step 11 : EXPOSE 4369 8091 8092 11209 11211 21100 21299
 ---> Running in 32e1451b58f8
 ---> baaa7e484e42
Successfully built baaa7e484e42
Removing intermediate container 157b4bf1723e
Removing intermediate container 8aa671153f08
Removing intermediate container e0a87e7ec88c
Error removing intermediate container 1761af5838cc: Driver devicemapper failed to remove root filesystem 1761af5838cca14b7efd8bcf514b33904a73eff997780c974a4890e05e4cb26f: Error running removeDevice
Removing intermediate container e813025c2f7d
Removing intermediate container aec0c0aafdde
Removing intermediate container c1a93e041b5f
Removing intermediate container a6bba1827a8f
Removing intermediate container d0eb2a22eb31
Removing intermediate container 971d4ee2b0e1
Removing intermediate container 32e1451b58f8

成功。
確認

[root@vagrant-centos65 couchbase]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
couchbase/centos    latest              baaa7e484e42        9 minutes ago       884.9 MB
httpd/centos        latest              2dfb101187c6        5 days ago          369.2 MB
centos              6.4                 539c0211cd76        12 months ago       300.6 MB
centos              latest              539c0211cd76        12 months ago       300.6 MB

起動。

[root@vagrant-centos65 couchbase]# docker run -d -i -p 8091:8091 -t couchbase/centos /bin/bash -c './etc/init.d/couchbase-server start && read -p "waiting"'
[root@vagrant-centos65 couchbase]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS               NAMES
10924f1ce787        couchbase/centos:latest   /bin/bash -c ./etc/i   12 seconds ago      Exit 127                                furious_nobel

なんかExit 127だし、メモリ不足で起動失敗してるっぽい。
インタラクティブに起動してcouchbase-server startして、ブラウザから8091ポートアクセスしたら見えた。
Dockerfileとしてはたぶん大丈夫かな。