Neo4j Embedded HighlyAvailableGraphDatabase

时间:2014-01-10 05:27:29

标签: neo4j

我正在尝试创建嵌入式HighlyAvailableGraphDatabase。我的服务器配置,

ha.server_id=1
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.1:6002
ha.cluster_server=192.168.9.1:5001

ha.server_id=2
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.2:6002
ha.cluster_server=192.168.9.2:5002

ha.server_id=3
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.3:6002
ha.cluster_server=192.168.9.3:5003

在我的java类中,我按如下方式创建数据库,

public class HighAvailableDbTest
{
    private static GraphDatabaseService graphDb;
    private static Map<String, String> haConfig = new HashMap<String, String>();

    public static void main(String a[])
    {
        HighlyAvailableGraphDatabaseFactory databaseFactory = new HighlyAvailableGraphDatabaseFactory();

       haConfig.put("org.neo4j.server.database.mode", "HA");
       haConfig.put("org.neo4j.server.webserver.address","0.0.0.0");
       haConfig.put("CONFIG_KEY_HA_MACHINE_ID","1");
       haConfig.put("CONFIG_KEY_HA_SERVER", "192.168.9.1:6002");


        graphDb = new HighlyAvailableGraphDatabaseFactory()
      .newHighlyAvailableDatabaseBuilder("test.db")
      .setConfig(haConfig)
      .newGraphDatabase();

    }
 }

但是当我运行代码时,我遇到以下异常:

Exception in thread "main" java.lang.NoSuchFieldError: indexProviders
at org.neo4j.graphdb.factory.HighlyAvailableGraphDatabaseFactory$1.newDatabase(HighlyAvailableGraphDatabaseFactory.java:47)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:197).

帮帮我!! 提前谢谢。

1 个答案:

答案 0 :(得分:0)

我设置了一个简单的虚拟项目,展示了如何设置两个嵌入式neo4j数据库以在HA模式下工作。

https://github.com/Jotschi/neo4j-ha-example