OrientDB - 如何在群集服务器上创建数据库?

时间:2013-02-01 11:52:55

标签: distributed orientdb

我使用默认配置群集状态设置了两个节点:

"members": [{
    "id": "192.168.1.101:2434",
    "listeners": [{"protocol": "ONetworkProtocolBinary", "listen": "192.168.1.101:2424"}, {"protocol": "ONetworkProtocolHttpDb", "li
80"}],
    "alias": "192.168.1.101:2434",
    "status": "aligning"
    }, {
    "id": "192.168.1.102:2435",
    "listeners": [{"protocol": "ONetworkProtocolBinary", "listen": "192.168.1.101:2425"}, {"protocol": "ONetworkProtocolHttpDb", "li
80"}],
    "alias": "192.168.1.101:2435",
    "status": "aligning"
    }],
"name": "_hzInstance_1_orientdb",
"local": "192.168.1.101:2435"
}

但是当我使用Java API连接到一台服务器并尝试创建数据库时,会发生异常,

admin = new OServerAdmin(PATH);
            admin.connect("root", "password");

            if (!admin.existsDatabase()) {
                admin.createDatabase("document", "local");
            }

堆栈:

Cannot create the remote storage: demo1
com.orientechnologies.orient.core.exception.ODatabaseException: Cannot create database
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:515)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:470)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:59)
    at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1832)
    at com.orientechnologies.orient.client.remote.OStorageRemote.getResponse(OStorageRemote.java:1863)
    at com.orientechnologies.orient.client.remote.OServerAdmin.createDatabase(OServerAdmin.java:184)
    at com.test.db.Client.main(Client.java:19)
Caused by: java.lang.NullPointerException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:517)
    ... 7 more
com.orientechnologies.orient.core.exception.OStorageException: Cannot create the remote storage: demo1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.common.log.OLogManager.error(OLogManager.java:119)
    at com.orientechnologies.orient.client.remote.OServerAdmin.createDatabase(OServerAdmin.java:189)
    at com.test.db.Client.main(Client.java:19)
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: Cannot create database
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:515)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:470)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:59)
    at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1832)
    at com.orientechnologies.orient.client.remote.OStorageRemote.getResponse(OStorageRemote.java:1863)
    at com.orientechnologies.orient.client.remote.OServerAdmin.createDatabase(OServerAdmin.java:184)
    ... 1 more
Caused by: java.lang.NullPointerException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:517)
    ... 7 more

为什么会这样?如何在群集服务器上创建数据库?

THX。

1 个答案:

答案 0 :(得分:0)

必须在群集外部完成数据库的初始创建。然后将数据库复制到所有服务器并启动集群。