-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial: setup a distributed database
Previous (Using schema with Graphs ) - Next (Working with distributed Graph Database)
OrientDBは分散アーキテクチャーで、複数のサーバーインスタンスでデータベースを動作させることができます。
このチュートリアルでは2台のノードで分散させてみます。一つのデータベースを複数ノードで共有するには二つの方法があります。
- 事前に二つのノードに同じデータベースディレクトリィを物理的にコピーしておきます。"databases"ディレクトリィの配下をコピーしておけば良いのです。
- 最初のノードを動作させておいて、新しく別のノードを参加させます。デフォルトの設定では、データベースを自動的に2ノードで共有されます。
OrientDBを分散ノードとして起動するためには、bin/server.sh
(windowsでは.bat
)ではなく、、bin/dserver.sh
(windowsではbin/dserver.bat
)を使います。
> cd bin
> ./dserver.sh
INFO OrientDB Server v1.6 (build 897) is starting up... [OServer]
INFO Databases directory: ./databases [OServer]
INFO Listening binary connections on 0.0.0.0:2424 (protocol v.18) [OServerNetworkListener]
INFO Listening http connections on 0.0.0.0:2480 (protocol v.10) [OServerNetworkListener]
INFO Installing dynamic plugin 'studio-1.6.zip'... [OServerPluginManager]
INFO Installing GREMLIN language v.2.5.0-SNAPSHOT - graph.pool.max=20 [OGraphServerHandler]
設定ファイルは、orientdb-server-config.xml
ではなく、orientdb-dserver-config.xml
です。詳しくはこちらを参照して下さい。
ノード起動時のログの残りは以下の通りです。
INFO Starting distributed server 'node1383734730415'... [OHazelcastPlugin]
INFO Configuring Hazelcast from ./config/hazelcast.xml'. [FileSystemXmlConfig]
INFO [10.1.28.101]:2434 [orientdb]
Members [1] {
Member [10.1.28.101]:2434 this
}
[MulticastJoiner]
WARN [node1383734730415] opening database 'GratefulDeadConcerts'... [OHazelcastPlugin]
INFO [node1383734730415] loaded database configuration from disk: ./config/default-distributed-db-config.json [OHazelcastPlugin]
---------- [OHazelcastPlugin]
INFO [node1383734730415] adding node 'node1383734730415' in partition: GratefulDeadConcerts.*.0 [OHazelcastDistributedDatabase]
INFO updated distributed configuration for database: GratefulDeadConcerts:
----------
{
"replication":true, "autoDeploy":true, "hotAlignment":true, "resyncEvery":15,
"clusters":{
"internal":{ "replication":false },
"index":{ "replication":false },
"*":{ "replication":true,
"readQuorum":1,
"writeQuorum":2,
"failureAvailableNodesLessQuorum":false,
"readYourWrites":true,
"partitioning":{
"strategy":"round-robin",
"default":0,
"partitions":[["<NEW_NODE>","node1383734730415"]]
}
}
}
}
ログの最後のあたりを見てみると、デフォルトの分散DBの設定用コピー元ファイルであるconfig/orientdb-dserver-config.xml
のnodeId
が空なので、
自動的にランダムな値("node1383734730415")がセットされているのがわかります。事前に"europe0"とか"production1"といった使いやすい名前をセットしておいたほうが用でしょう。
事前に
起動時に、OrientDBは、"databases" ディレクトリィにすべてのデータベースをロードします。そして、それらを分散モードで利用できるようにするために、
config/default-distributed-db-config.json
の内容をデフォルト設定として使用し、各データベースディレクトリィ配下にコピーします。
次からは、各データベースのディレクトリィのファイル(例えばdatabases/GratefulDeadConcerts/default-distributed-db-config.json
)が設定値として利用されます。
これはサーバーのノード構造がいつでも変化できる(ノードとして参加したり、離脱したり)できるようにするために、各サーバーノード毎にOrientDBが設定ファイルを更新し続けられるようにするためにです。
分散DB設定ファイル(config/default-distributed-db-config.json
)をもっと詳細に知るにはこちらを参照して下さい。
では、最初のと同じように2台目のサーバーノードを起動しましょう。分散DBに参加するためにはconfig/hazelcast.xml
ファイルに同じHazelcast証明書がある必要があります。
一番簡単なのは、1ノード目から2ノード目にコピーすることです。
いったん、2ノード目がオンラインになると、以下のように両ノードが相互にメッセージをダンプし始めます。
WARN [node1384014656983] added new node id=Member [192.168.1.179]:2435 name=null [OHazelcastPlugin]
INFO [192.168.1.179]:2434 [orientdb] Re-partitioning cluster data... Migration queue size: 135 [PartitionService]
INFO [192.168.1.179]:2434 [orientdb] All migration tasks has been completed, queues are empty. [PartitionService]
INFO [node1384014656983] added node configuration id=Member [192.168.1.179]:2435 name=node1384015873680, now 2 nodes are configured [OHazelcastPlugin]
INFO [node1384014656983] update configuration db=GratefulDeadConcerts from=node1384015873680 [OHazelcastPlugin]
INFO updated distributed configuration for database: GratefulDeadConcerts:
----------
{
"replication":true,
"autoDeploy":true,
"hotAlignment":true,
"resyncEvery":15,"clusters":{
"internal":{
"replication":false
},
"index":{
"replication":false
},
"*":{
"replication":true,
"readQuorum":1,
"writeQuorum":2,
"failureAvailableNodesLessQuorum":false,
"readYourWrites":true,"partitioning":{
"strategy":"round-robin",
"default":0,
"partitions":[["<NEW_NODE>","node1383734730415","node1384015873680"]]
}
}
},
"version":1
}
---------- [OHazelcastPlugin]
WARN [node1383734730415]->[node1384015873680] deploying database GratefulDeadConcerts... [ODeployDatabaseTask]
WARN [node1383734730415]->[node1384015873680] sending the compressed database GratefulDeadConcerts over the network, total 339,66Kb [ODeployDatabaseTask]
ここでは、同一のサーバー(ip=192.168.1.179)上の2ノードをポートを変えて(2434と2435)動作させています。 ログの残りは、2ノード目へのデータベースの分散に関係しています。
WARN [node1384015873680]<-[node1383734730415] installing database GratefulDeadConcerts in databases/GratefulDeadConcerts... [OHazelcastPlugin]
WARN [node1384015873680] installed database GratefulDeadConcerts in databases/GratefulDeadConcerts, setting it online... [OHazelcastPlugin]
WARN [node1384015873680] database GratefulDeadConcerts is online [OHazelcastPlugin]
WARN [node1384015873680] updated node status to 'ONLINE' [OHazelcastPlugin]
INFO OrientDB Server v1.6.1-SNAPSHOT is active. [OServer]
これは、"GratefulDeadConcerts" データベースが、1ノード目からネットワーク経由でインストールされたことを示しています。
Previous (Using schema with Graphs ) - Next (Working with distributed Graph Database)
Home - Download - Install - Upgrade - Professional Support - Courses - Team
- Copyright (C) Orient Technologies - All rights reserved.