Couchbase Server 4.0をCentOS7にインストールする

Couchbase

Couchbaseは分散ドキュメントを扱うNoSQLである。
主な特徴としては、

  • RAMベースでの高速な動作に加え非同期でのストレージ保存 (分離レベルを設定可能)
  • キーバリュー型のシンプルなドキュメントストア構造
  • ノードのクラスタ追加によるリニアなスケールがオンラインで可能
  • コマンドラインREST APIによる操作
  • memcachedモードではスケール可能なmemcachedとしてクライアント側の変更なしに使用が可能

などが挙げられる。

Couchbaseのインストール

まず、Couchbaseの公式ページより、必要なパッケージのリンクを取得する。
f:id:nao_bamboo:20160118155912p:plain
今回はCentOS7にインストールするので、Red Hat 7 のダウンロードリンクをコピーする。
このパッケージをサーバでダウンロードしてインストールする。

[admin@centos7 ~]$ cd /var/src
[admin@centos7 src]$ wget http://packages.couchbase.com/releases/4.0.0/couchbase-server-community-4.0.0-centos7.x86_64.rpm

packages.couchbase.com (packages.couchbase.com) をDNSに問いあわせています... 54.231.49.99
packages.couchbase.com (packages.couchbase.com)|54.231.49.99|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 73719752 (70M) [application/x-redhat-package-manager]
`couchbase-server-community-4.0.0-centos7.x86_64.rpm' に保存中

100%[==========================================================>] 73,719,752 5.89MB/s 時間 39s

2016-01-18 14:52:17 (1.80 MB/s) - `couchbase-server-community-4.0.0-centos7.x86_64.rpm' へ保存完了 [73719752/73719752]

[admin@centos7 src]$ sudo rpm -ivh couchbase-server-community-4.0.0-centos7.x86_64.rpm
準備しています... ################################# [100%]
Warning: Transparent hugepages looks to be active and should not be.
Please look at http://bit.ly/1hTySfg as for how to PERMANENTLY alter this setting.
Warning: Swappiness is not set to 0.
Please look at http://bit.ly/1hTySfg as for how to PERMANENTLY alter this setting.
Minimum RAM required : 4 GB
System RAM configured : 1.80 GB

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

更新中 / インストール中...
1:couchbase-server-community-4.0.0-################################# [100%]
Reloading systemd: [ OK ]
Starting couchbase-server (via systemctl): Failed to start couchbase-server.service: Unit couchbase-server.service failed to load: No such file or directory.
[失敗]

You have successfully installed Couchbase Server.
Please browse to http://centos7.osxserver.net: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, 8093, 9100 to 9105, 9998, 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.

RAMやプロセッサ数が最低動作要件を満たしていないものの、インストールは可能だ。
だが、インストールは成功したものの、systemctlによるサービスの起動で失敗していることがわかる。
これはCentOS7における既知の問題のようで、フォーラムにも記載があった。
forums.couchbase.com
これによれば、systemctlを使うのではなく、Couchbaseの起動コマンドを使うのが良いようだ。
コマンドを使って起動すると無事起動できた。

[admin@centos7 src]$ sudo /opt/couchbase/etc/couchbase_init.d start
Starting couchbase-server-community

セットアップ

アクセス方法

管理画面へは
http://サーバのIPアドレス:8091/
でアクセスできる。
f:id:nao_bamboo:20160118161719p:plain

ストレージとクラスタの設定

ストレージについてはデータファイルパスとインデックスファイルパスを設定する。
クラスタについては新規クラスタなのか既存のクラスタへの追加なのかを選択できる。
f:id:nao_bamboo:20160118162028p:plain

  • Services: このノードで使用するサービスを選択する
  • Data RAM Quota: データに対するノード単位のメモリ使用量を設定する
  • Index RAM Quota: インデックスに対するノード単位のメモリ使用量を設定する

サンプルバケットの設定

サンプルバケット及びサンプルデータを作成することができる。
バケットはRDBMSでいうところのデータベースに該当する。
f:id:nao_bamboo:20160118162532p:plain

デフォルトバケットの作成

デフォルトのバケットを作成する。
Couchbaseとしての機能を使う場合はCouchbaseを、memcached互換として使う場合はMemcachedを選択する。
f:id:nao_bamboo:20160118162844p:plain

  • Cache Metadata:
    • Value Ejection: RAM上からキャッシュデータを削除する際に、値データのみを削除し、キーやメタデータを削除しない。メモリ使用量が増える代わりにパフォーマンスが向上する。
    • Full Ejection: RAM上からキャッシュデータを削除する際に、キーやメタデータ、値データを含む全てのデータを削除する。パフォーマンスが落ちる代わりに、メモリ使用のオーバーヘッドを減らすことができる。
  • Set the bucket disk I/O priority: 優先度によるディスクI/O最適化を行う場合の詳細設定項目である。
  • Flush: データフラッシュを有効にする。フラッシュ実行時、memcachedバケットのデータは削除可能フラグが立ち、後でデータ削除される。Couchbaseバケットのデータは直ちに削除される。この設定はすぐにフラッシュを実行するという意味ではない。

通知の設定

ソフトウェアアップデートの通知設定とコミュニティへの登録を行う。
f:id:nao_bamboo:20160118164206p:plain

  • Enable software update notifications: 新しいバージョンのCouchbase Serverが利用可能になった時、Webコンソール上で通知が行われる。この設定は匿名で送られ、いかなるキーバーリューで他を含むものでもない。

サーバ管理者の設定

サーバ管理者のアカウントを作成する。
f:id:nao_bamboo:20160118164522p:plain

セットアップ完了

セットアップが完了すると、管理画面のオーバービューが表示される。
f:id:nao_bamboo:20160118164609p:plain

REST APIでの接続

REST APIで接続してみる。

[admin@centos7 src]$ curl 'http://192.168.0.3:8091/pools'
{"pools":[{"name":"default","uri":"/pools/default?uuid=xxxxxxxxxxxxxxxxxxxxxx","streamingUri":"/poolsStreaming/default?uuid=xxxxxxxxxxxxxxxxxxxxxx"}],"isAdminCreds":false,"isROAdminCreds":false,"isEnterprise":false,"settings":{"maxParallelIndexers":"/settings/maxParallelIndexers?uuid=xxxxxxxxxxxxxxxxxxxxxx","viewUpdateDaemon":"/settings/viewUpdateDaemon?uuid=xxxxxxxxxxxxxxxxxxxxxx"},"uuid":"xxxxxxxxxxxxxxxxxxxxxx","implementationVersion":"4.0.0-4051-community","componentsVersion":{"lhttpc":"1.3.0","os_mon":"2.2.14","public_key":"0.21","asn1":"2.0.4","kernel":"2.16.4","ale":"4.0.0-4051-community","inets":"5.9.8","ns_server":"4.0.0-4051-community","crypto":"3.2","ssl":"5.3.3","sasl":"2.3.4","stdlib":"1.19.4"}}

REST APIについては、下記ドキュメントが用意されている。

developer.couchbase.com

developer.couchbase.com

参考書籍

バージョンが古くなっているが、オライリーからCouchbaseに関する入門書 (Ebookのみ) が出ている。
O'Reilly Japan - Couchbase Serverをはじめよう