【问题标题】:OrientDB: Trouble creating distributed clusters with hotalignment=trueOrientDB:使用 hotalignment=true 创建分布式集群时遇到问题
【发布时间】:2016-03-24 23:33:38
【问题描述】:

我在嵌入式和分布式模式下使用 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更改为“true”,但是当我这样做时,在启动节点2时出现以下错误(注意:此时数据库未部署到节点2,但已创建在节点 1)上:

2015-12-17 16:28:32:010 INFO [order2] 将数据库“test”的分布式配置文件保存到:./databases/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] 类 'ORole',创建新的本地集群 'orole_order2' (id=-1) [OHazelcastPlugin]
2015-12-17 16:28:32:134 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 0/10... [ODistributedStorage]
2015-12-17 16:28:32:522 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 1/10... [ODistributedStorage]
2015-12-17 16:28:32:903 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 2/10...[ODistributedStorage]
2015-12-17 16:28:33:283 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 3/10...[ODistributedStorage]
2015-12-17 16:28:33:663 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 4/10... [ODistributedStorage]
2015-12-17 16:28:34:043 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 5/10...[ODistributedStorage]
2015-12-17 16:28:34:419 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 6/10... [ODistributedStorage]
2015-12-17 16:28:34:799 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 7/10...[ODistributedStorage]
2015-12-17 16:28:35:176 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 8/10... [ODistributedStorage]
2015-12-17 16:28:35:556 WARNI 在分布式节点上创建集群时出错:ID 不同(本地 = 9 和远程 = 15)。正在重试 9/10... [ODistributedStorage]
2015-12-17 16:28:35:910 SEVER [order2] 在类“ORole”中创建集群“orole_order2”时出错:[OHazelcastPlugin][order2] 启动分布式插件时出错
com.orientechnologies.orient.server.distributed.ODistributedException:在类“ORole”中创建集群“orole_order2”时出错
在 com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.installLocalClusterPerClass(OHazelcastPlugin.java:1624)
在 com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.installDbClustersForLocalNode(OHazelcastPlugin.java:1293)
在 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)
在 no.kommune.bergen.graftest.GraphDBServerWrapper.startDatabaseServer(GraphDBServerWrapper.java:74)
在 no.kommune.bergen.graftest.GraftestApplication.main(GraftestApplication.java:47)
在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在 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 不同
在 com.orienttechnologies.orient.server.distributed.ODistributedStorage.addCluster(ODistributedStorage.java:1364)
在 com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.addCluster(ODatabaseDocumentTx.java:1291)
在 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 创建本地集群。关闭自动部署时,我也看到了同样的问题。 我的配置中是否缺少某些内容?

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

    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();

【问题讨论】:

标签: orientdb


【解决方案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 缺少此信息。

【讨论】:

  • 有趣的发现,顺便说一句,如果你去维基上的那个页面向上滚动,有一个“编辑这个页面”链接,你可以在其中将它添加到文档中,它会自动创建一个拉请求更改。您需要一个 github 帐户才能执行此操作。
  • 我将建议添加一个部分来解释应该设置此属性,以及如何以编程方式进行设置。
【解决方案2】:

您不应该使用 hotAligment,它已严重损坏。它将在 2.2 中修复

例如看 https://github.com/orientechnologies/orientdb/issues/2270 https://github.com/orientechnologies/orientdb/issues/5455

目前,向分布式设置添加和重新添加节点需要完全同步数据库。

【讨论】:

  • 好的,我明白了。但是当我尝试使用 OrientDB 2.2.0-beta 时,我仍然得到同样的错误。知道如何配置数据库,以便我可以使用 2.2 的热对齐和自动部署吗?
  • OK,但是问题和使用2.1的时候一样,所以我觉得不是2.2的原因
  • 好的,你能展示一下你启动数据库的方式吗?分享您的嵌入式代码?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-28
  • 1970-01-01
  • 2016-01-20
  • 2014-03-21
  • 2012-10-28
  • 1970-01-01
  • 2022-06-16
相关资源
最近更新 更多