如何与多个Spring应用程序共享Neo4j HA集群?

时间:2013-12-14 14:25:52

标签: java spring neo4j spring-data-neo4j database-cluster

我有一个包含4个Neo4j实例的集群(v.1.9.3),其中包含以下initial_host:

ha.initial_hosts=192.168.1.10:5001,192.168.1.10:5002,192.168.1.10:5003,192.168.1.10:5004  

我正在使用这个集群作为我的一个spring应用程序(使用Spring-data-neo4j),我已经在我的applicationContext文件中继续进行配置:

<bean id="graphDatabaseService" class="org.neo4j.kernel.HighlyAvailableGraphDatabase"
    destroy-method="shutdown" scope="singleton"> 
    <constructor-arg name="storeDir" index="0" value="E:/Neo4J Enterprise Edition/db1/data/graph.db" />
    <constructor-arg index="1">
        <map>
            <entry key="ha.server_id" value="5" />
            <entry key="ha.pull_interval" value="10" />
            <entry key="ha.server" value="192.168.1.10:6005" />
            <entry key="ha.initial_hosts" value="192.168.1.10:5001,192.168.1.10:5002,192.168.1.10:5003,192.168.1.10:5004" />
        </map>
    </constructor-arg>
</bean><neo4j:config graphDatabaseService="graphDatabaseService" />  

群集正常运行,实例之间正确同步/复制数据。

现在是否可以在同一群集上共享群集或运行其他应用程序? 为实现这一目标,我为第二个应用程序编写了另一个配置如下:

<bean id="graphDatabaseService" class="org.neo4j.kernel.HighlyAvailableGraphDatabase"
        destroy-method="shutdown" scope="singleton"> 
        <constructor-arg name="storeDir" index="1" value="E:/db_5/graph.db" />
        <constructor-arg index="2">
            <map>
                <entry key="ha.server_id" value="6" />
                <entry key="ha.pull_interval" value="10" />
                <entry key="ha.server" value="192.168.1.10:6006" />
                <entry key="ha.initial_hosts" value="192.168.1.10:5001,192.168.1.10:5002,192.168.1.10:5003,192.168.1.10:5004" />
            </map>
        </constructor-arg>
    </bean>
    <neo4j:config graphDatabaseService="graphDatabaseService" />  

但它总是以异常结束。以下是它的几行:

    Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.cluster.client.ClusterClient@9bad4f' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
    ... 78 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.cluster.client.ClusterJoin@c47498' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
    at org.neo4j.cluster.client.ClusterClient.start(ClusterClient.java:421)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
    ... 80 more
Caused by: java.lang.IllegalStateException: i was denied entry
    at org.neo4j.cluster.protocol.cluster.ClusterState$2.handle(ClusterState.java:199)
    at org.neo4j.cluster.protocol.cluster.ClusterState$2.handle(ClusterState.java:121)
    at org.neo4j.cluster.statemachine.StateMachine.handle(StateMachine.java:88)
    at org.neo4j.cluster.StateMachines$1.run(StateMachines.java:135)
    ... 3 more  

第二次配置有什么问题吗?我访问了这个link。并尝试更改ha.server_idha.server条目密钥并在同一域的两台不同计算机上运行项目,但没有帮助。

任何人都可以指出我在这里做错了什么吗?感谢

0 个答案:

没有答案