3

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

"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

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

谢谢。

4

1 回答 1

0

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

于 2013-02-01T13:25:54.130 回答