OrientDBことはじめ

1.0の安定版が19日にリリース予定っぽいんですが、学習コストちょっと高そうな予感がしたので1.0rc9でためしてみる。

Downloads - orient
zip落としてきてunzip。
/usr/local/に移動してorientdbでシンボリックリンク貼っておく。

# ll orientdb/
合計 68
drwxr-xr-x 2 root root  4096  3月 26 18:39 benchmarks
drwxr-xr-x 2 root root  4096  3月 26 18:41 bin
drwxr-xr-x 2 root root  4096  3月 26 18:39 config
drwxr-xr-x 3 root root  4096  3月 26 18:40 databases
-rw-r--r-- 1 root root 23349  3月 26 18:41 history.txt
drwxr-xr-x 2 root root  4096  3月 26 18:39 lib
-rw-r--r-- 1 root root 11622  3月 26 18:41 license.txt
drwxr-xr-x 2 root root  4096  3月 26 18:39 log
-rw-r--r-- 1 root root  3003  3月 26 18:41 readme.txt
drwxr-xr-x 4 root root  4096  3月 26 18:39 www

起動とかコンソールとかはbin配下に格納されてるみたい。
殆どのシェルがjavaを叩いてるんですけど、jvmのバージョンを実行するものによって切り替えたりしたいのでシェルのjavaをフルパスに書き換えたりしたのち、実行権限を付与。

# chmod +x console.sh server.sh orientdb.sh shutdown.sh gremlin.sh

stop/start/statusはorientdb.shがserver.shとshutdown.shを呼び出す形で行ってるっぽいので、ちょっとorientdb.shの中身を見てみる。
ORIENTDB_DIRとORIENTDB_USERの中身を書き換えろと書いてあるので環境に合わせて書き換えます。

# diff orientdb.sh orientdb.sh.org 
6,7c6,7
< ORIENTDB_DIR="/usr/local/orientdb"
< ORIENTDB_USER="root"
---
> ORIENTDB_DIR="YOUR_ORIENTDB_INSTALLATION_PATH"
> ORIENTDB_USER="USER_YOU_WANT_ORIENTDB_RUN_WITH"

ユーザー作るつもりだったけど一旦rootで…。
早速startしてみます。

# ./orientdb.sh start
Starting OrientDB server daemon...
# ps aux |grep orient
root     23206  141  3.3 1413772 135940 pts/0  Sl   14:20   0:12 /usr/local/java/bin/java -server -XX:+UseParallelGC -XX:+AggressiveOpts -XX:CompileThreshold=200 -Djava.util.logging.config.file=/usr/local/orientdb/config/orientdb-server-log.properties -Dorientdb.config.file=/usr/local/orientdb/config/orientdb-server-config.xml -Dorientdb.www.path=/usr/local/orientdb/www -Dlog.console.level=info -Dlog.file.level=fine -Dorientdb.build.number=@BUILD@ -cp /usr/local/orientdb/lib/*: com.orientechnologies.orient.server.OServerMain

うむ。
次はstop。

# ./orientdb.sh stop
ending shutdown command to remote OrientDB Server instance...
# ps aux |grep orient
root     23206  141  3.3 1413772 135940 pts/0  Sl   14:20   0:12 /usr/local/java/bin/java -server -XX:+UseParallelGC -XX:+AggressiveOpts -XX:CompileThreshold=200 -Djava.util.logging.config.file=/usr/local/orientdb/config/orientdb-server-log.properties -Dorientdb.config.file=/usr/local/orientdb/config/orientdb-server-config.xml -Dorientdb.www.path=/usr/local/orientdb/www -Dlog.console.level=info -Dlog.file.level=fine -Dorientdb.build.number=@BUILD@ -cp /usr/local/orientdb/lib/*: com.orientechnologies.orient.server.OServerMain

アルェー。
落ちない。ログを見てみると

Error: Cannot connect to server host '0.0.0.0', ports: [2424, 2425, 2426, 2427, 2428, 2429, 2430]

と表示されてました。
リッスンするポート指定するところがあるのか。設定ファイルがありそうなconfを見てみると「orientdb-server-config.xml」というファイルがありました。

# diff orientdb-server-config.xml orientdb-server-config.xml.org 
40,42c40,42
<             <listener ip-address="xxx.xxx.xxx.xxx" port-range="2424-2430" protocol="binary"/>
<             <listener ip-address="xxx.xxx.xxx.xxx" port-range="2434-2440" protocol="cluster"/>
<             <listener ip-address="xxx.xxx.xxx.xxx" port-range="2480-2490" protocol="http">
---
>             <listener ip-address="0.0.0.0" port-range="2424-2430" protocol="binary"/>
>             <listener ip-address="0.0.0.0" port-range="2434-2440" protocol="cluster"/>
>             <listener ip-address="0.0.0.0" port-range="2480-2490" protocol="http">

とりあえずそれっぽいところを書き換えて、今立ち上がってるプロセスをkillして再度startしたのちstop。

# ./orientdb.sh start
ending shutdown command to remote OrientDB Server instance...
Shutdown executed correctly

おわった!
OrientDB自身はprotocol="binary"を指定してるポートを使ってるみたい。
clusterはまだ調べてない。httpはOrientDBStudioなるブラウザからOrientDBを操作出来るアプリが乗っかるみたい。
http://$サーバのIPアドレス$:2480/で閲覧できる。
グラフを分かりやすく表示してくれるあたりがまさにGraphDBって感じで素敵。
とりあえずここまで…!

スポンサーリンク