OrientDB:使用hotalignment = true创建分布式集群时出现问题

时间:2015-12-18 09:41:53

标签: orientdb

我在嵌入式和分布式模式下使用OrientDB 2.1.7,并且应用程序在两个节点(两个Java进程)上运行。

使用默认的JSON数据库配置时,一切正常:

{
  "autoDeploy": true,
  "hotAlignment": false,
  "executionMode": "undefined",
  "readQuorum": 1,
  "writeQuorum": 2,
  "failureAvailableNodesLessQuorum": false,
  "readYourWrites": true,
  "servers": {
    "*": "master"
  },
  "clusters": {
    "internal": {
      "replication": false
    },
    "index": {
      "replication": false
    },
    "*": {
      "servers": ["<NEW_NODE>"]
    }
  }
}

但是,我想将hotAlignment更改为&#34; true&#34;,但是当我这样做时,我在启动节点2时出现以下错误(注意:此时数据库未部署到节点2,但它已在节点1上创建:

  

2015-12-17 16:28:32:010 INFO [order2]保存数据库的分布式配置文件&#39; test&#39; to:./ database / test / distributed-config.json [OHazelcastPlugin]
  2015-12-17 16:28:32:012 INFO [order2]收到新状态order2.test = ONLINE [OHazelcastPlugin]
  2015-12-17 16:28:32:019 INFO [order2]在队列中找不到以前的消息orientdb.node.order2.test.request [OHazelcastDistributedMessageService]
  2015-12-17 16:28:32:043 INFO [order2]发布数据库order2.test的在线状态... [OHazelcastDistributedDatabase]
  2015-12-17 16:28:32:046 INFO [order2]收到更新状态order2.test = ONLINE [OHazelcastPlugin]
  2015-12-17 16:28:32:052 INFO [order2] class&#39; ORole&#39;,创建新的本地集群&#39; orole_order2&#39; (id = -1)[OHazelcastPlugin]
  2015-12-17 16:28:32:134 WARNI在分布式节点上创建集群时出错:ID不同(local = 9,remote = 15)。重试0/10 ... [ODistributedStorage]
  2015-12-17 16:28:32:522 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试1/10 ... [ODistributedStorage]
  2015-12-17 16:28:32:903 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试2/10 ... [ODistributedStorage]
  2015-12-17 16:28:33:283 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试3/10 ... [ODistributedStorage]
  2015-12-17 16:28:33:663 WARNI在分布式节点上创建集群时出错:ID不同(local = 9,remote = 15)。重试4/10 ... [ODistributedStorage]
  2015-12-17 16:28:34:043 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试5/10 ... [ODistributedStorage]
  2015-12-17 16:28:34:419 WARNI在分布式节点上创建集群时出错:ID不同(local = 9,remote = 15)。重试6/10 ... [ODistributedStorage]
  2015-12-17 16:28:34:799 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试7/10 ... [ODistributedStorage]
  2015-12-17 16:28:35:176 WARNI在分布式节点上创建集群时出错:ID不同(local = 9,remote = 15)。重试8/10 ... [ODistributedStorage]
  2015-12-17 16:28:35:556 WARNI在分布式节点上创建集群时出错:ID不同(local = 9和remote = 15)。重试9/10 ... [ODistributedStorage]
  2015-12-17 16:28:35:910 SEVER [order2]错误创建群集&#39; orole_order2&#39;在课堂上&#39; ORole&#39;:[OHazelcastPlugin] [order2]启动分布式插件时出错   com.orientechnologies.orient.server.distributed.ODistributedException:创建集群&#39; orole_order2&#39;时出错。在课堂上&#39; ORole&#39;
      at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.installLocalClusterPerClass(OHazelcastPlugin.java:1624)
      在com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.installDbClustersForLocalNode(OHazelcastPlugin.java:1293)
      at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.loadDistributedDatabases(OHazelcastPlugin.java:1434)
      在com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.startup(OHazelcastPlugin.java:187)
      在com.orientechnologies.orient.server.OServer.registerPlugins(OServer.java:979)
      在com.orientechnologies.orient.server.OServer.activate(OServer.java:346)
      at no.kommune.bergen.graftest.GraphDBServerWrapper.startDatabaseServer(GraphDBServerWrapper.java:74)
      at no.kommune.bergen.graftest.GraftestApplication.main(GraftestApplication.java:47)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      在java.lang.reflect.Method.invoke(Method.java:483)
      在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
      在java.lang.Thread.run(Thread.java:745)
  引起:com.orientechnologies.orient.server.distributed.ODistributedException:在分布式节点上创建集群时出错:分配的本地和远程ID不同
      at com.orientechnologies.orient.server.distributed.ODistributedStorage.addCluster(ODistributedStorage.java:1364)
      在com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.addCluster(ODatabaseDocumentTx.java:1291)
      at com.orientechnologies.orient.core.metadata.schema.OClassImpl.createClusterIfNeeded(OClassImpl.java:2102)
      在com.orientechnologies.orient.core.metadata.schema.OClassImpl.addCluster(OClassImpl.java:1068)
      在com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.installLocalClusterPerClass(OHazelcastPlugin.java:1617)
      ......还有13个

启用hotAlignment时,似乎无法为node2创建本地群集。关闭autodeploy时我也遇到了同样的问题。 我的配置中是否缺少某些内容?

编辑:这是我们启动服务器的方式:

    OServerConfiguration cfg = new OServerConfiguration();
    //DB server config
    cfg.handlers = new ArrayList<OServerHandlerConfiguration>();
    //Cluster plugin config
    OServerHandlerConfiguration hazelcastHandlerConfig = new OServerHandlerConfiguration();
    hazelcastHandlerConfig.clazz = "com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin";
    hazelcastHandlerConfig.parameters = new OServerParameterConfiguration[6];
    hazelcastHandlerConfig.parameters[0] = new OServerParameterConfiguration("nodeName", nodeName);
    hazelcastHandlerConfig.parameters[1] = new OServerParameterConfiguration("enabled", "true");
    hazelcastHandlerConfig.parameters[2] = new OServerParameterConfiguration("configuration.db.default", "/config/distributed-db-config.json");
    hazelcastHandlerConfig.parameters[3] = new OServerParameterConfiguration("configuration.hazelcast", "/config/hazelcast.xml");
    hazelcastHandlerConfig.parameters[4] = new OServerParameterConfiguration("conflict.resolver.impl", "com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver");
    hazelcastHandlerConfig.parameters[5] = new OServerParameterConfiguration("sharding.strategy.round-robin", "com.orientechnologies.orient.server.hazelcast.sharding.strategy.ORoundRobinPartitioninStrategy");
    cfg.handlers.add(hazelcastHandlerConfig);
    //Network config
    cfg.network = new OServerNetworkConfiguration();
    cfg.network.protocols = new ArrayList<OServerNetworkProtocolConfiguration>();
    cfg.network.protocols.add(new OServerNetworkProtocolConfiguration("binary", "com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"));
    OServerNetworkListenerConfiguration binaryListenerCfg = new OServerNetworkListenerConfiguration();
    binaryListenerCfg.ipAddress = "0.0.0.0";
    binaryListenerCfg.portRange = "2424-2430";
    binaryListenerCfg.protocol = "binary";
    cfg.network.listeners = new ArrayList<>();
    cfg.network.listeners.add(binaryListenerCfg);

    //Storage config
    OServerStorageConfiguration storageCfg = new OServerStorageConfiguration();
    storageCfg.path = "plocal:./databases/test";
    storageCfg.name = "test";
    storageCfg.loadOnStartup = true;
    cfg.storages = new OServerStorageConfiguration[]{storageCfg};
    //User config
    OServerUserConfiguration userCfg = new OServerUserConfiguration(username, password, "*");
    cfg.users = new OServerUserConfiguration[]{userCfg};

    databaseServer = OServerMain.create(true);
    databaseServer.startup(cfg);

    databaseServer.activate();

1 个答案:

答案 0 :(得分:1)

好的,所以我找到了解决这个问题的方法(found here

我在创建服务器服务器之前添加了这两行:

    String orientdbHome = new File("").getAbsolutePath();
    System.setProperty("ORIENTDB_HOME", orientdbHome);

所以服务器就像这样启动:

    String orientdbHome = new File("").getAbsolutePath();
    System.setProperty("ORIENTDB_HOME", orientdbHome);

    databaseServer = OServerMain.create(true);
    databaseServer.startup(cfg);

    databaseServer.activate();

现在启动节点2时没有问题。

我认为文档中的this page缺少此信息。