LoginSignup
1
1

More than 5 years have passed since last update.

RethinkDBをCentOS7にインストールする

Last updated at Posted at 2016-12-23

前提

STF (Smartphone Test Farm)を構築したので、RethinkDBのセットアップを改めてやり直して、整理してみました。

インストール

以下に公式のインストール方法があります。

CentOSの場合はyumでインストール可能です。

wget https://download.rethinkdb.com/centos/7/`uname -m`/rethinkdb.repo -O /etc/yum.repos.d/rethinkdb.repo
yum install rethinkdb

起動

基本的にrethinkdbというコマンドを発行するとカレントディレクトリに、rethinkdb_dataというディレクトリが作成されて、プロセスが立ち上がります。

自動起動設定

それだと、OS再起動のたびに手動でコマンド打たないといけないので、運用しづらくなります。
RethinkDBにはデーモンで起動するモードもあるので、それで起動します。

基本的には以下の公式ドキュメントに書いている内容です。

公式ドキュメントでは「Startup with systemd」となっているところの手順です。
/usr/lib/systemd/system/rethinkdb@.serviceを作成して以下を記述します。

/usr/lib/systemd/system/rethinkdb@.service
[Unit]
Description=RethinkDB database server for instance '%i'

[Service]
User=rethinkdb
Group=rethinkdb
ExecStart=/usr/bin/rethinkdb serve --config-file /etc/rethinkdb/instances.d/%i.conf
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

次にインスタンスの設定ファイルを作成します。
/etc/rethinkdb/default.conf.sampleにサンプルの設定ファイルがあるので、これを/etc/rethinkdb/instances.d以下にコピーして設定をカスタマイズしていきますが、設定項目もそんなに多くないので、基本的に以下で十分です。
/etc/rethinkdb/instances.d/default.confを作成して以下のようにします。

/etc/rethinkdb/instances.d/default.conf
runuser=rethinkdb
rungroup=rethinkdb
pid-file=/var/run/rethinkdb/rethinkdb.pid
directory=/var/lib/rethinkdb/default
bind=all
driver-port=28015
cluster-port=29015
http-port=8080
server-name=server1

systemdに登録して起動

systemctl enable rethinkdb@default
systemctl start rethinkdb@default

操作

RethinkDBにはWeb UIが用意されています。
上記の設定でWeb UIが使えるようになっています。
ブラウザでhttp://{IPアドレス}:8080でアクセスできます。

ポイント

ポイントは設定ファイルにbind=allと記述することです。こうしておかないとlocalhostからしかWeb UIにアクセス出来なかったりします。

1
1
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
1
1