Neo4j嵌入了高可用性

时间:2013-05-14 12:11:21

标签: neo4j spring-data-neo4j

我最近使用Spring Data Neo4j Embedded作为其中一个POC。它在单机上运行速度极快。在开始生产之前,我想将数据库与应用程序服务器分开。我配置了三个Neo4j Server实例和HA代理,并使用Spring Data Neo4j Rest进行连接。但速度最差。每个查询执行时间超过30秒。

我在考虑使用Neo4j Embedded和HA?有人可以为我提供链接/教程,以便在具有HA代理的嵌入式模式下配置Spring Data Neo4j。

我希望拥有3台neo4j服务器和多台应用服务器。 感谢。

附加日志

17:43:10.695 [main] DEBUG o.s.b.f.annotation.InjectionMetadata - Processing injected method of bean 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': AutowiredMethodElement for public void org.springframework.data.neo4j.config.Neo4jConfiguration.setConversionService(org.springframework.core.convert.ConversionService)
17:43:10.703 [main] DEBUG o.s.b.f.annotation.InjectionMetadata - Processing injected method of bean 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': AutowiredMethodElement for public void org.springframework.data.neo4j.config.Neo4jConfiguration.setGraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService)
17:43:10.703 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'graphDatabaseService'
17:43:10.703 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'graphDatabaseService'
17:43:10.832 [main] DEBUG neo4j - WARNING! Deprecated configuration options used. See manual for details
17:43:10.832 [main] DEBUG neo4j - neo4j.ext.udc.disable has been replaced with neo4j.ext.udc.enabled
17:43:10.832 [main] DEBUG neo4j - cannot configure writers and searchers individually since they go together
17:43:14.467 [main] DEBUG neo4j - Writing at flush-requested: -1
17:43:16.163 [main] DEBUG neo4j - Read HA server:54.234.75.138:6002 (for machineID 2) from zoo keeper
17:43:16.821 [main] DEBUG neo4j - Read HA server:54.234.75.138:6003 (for machineID 3) from zoo keeper
17:43:17.445 [main] DEBUG neo4j - Writing at flush-requested: -6
17:43:19.013 [main] DEBUG neo4j - getMaster 2 based on [MachineInfo[ID:2, sequence:46, last tx:672, server:(54.234.75.138, 6002), master for last tx:1], MachineInfo[ID:3, sequence:47, last tx:672, server:(54.234.75.138, 6003), master for last tx:1]]

我尝试过如下设置:

<bean id="graphDatabaseService" class="org.neo4j.kernel.HighlyAvailableGraphDatabase" destroy-method="shutdown" scope="singleton">
        <constructor-arg name="storeDir" index="0" value="data/graph.db" />
         <constructor-arg index="1"> 
                        <map>
                                <entry key="ha.server_id" value="${server.id}"></entry>
                                <entry key="ha.server" value="${ha.server.address}:${ha.server.port}"></entry>
                                <entry key="ha.coordinators" value="${coordinators}"></entry>
                                <entry key="enable_remote_shell" value="port=1331"></entry>
                                <entry key="ha.pull_interval" value="1"></entry>
                        </map>
                </constructor-arg>

    </bean> 

我的neo4j-ha.properties文件

server.id=1
ha.server.address=192.168.1.9
ha.server.port=7474
coordinators=192.168.1.9:5001,192.168.1.9:5002,192.168.1.9:5003

server.id=2
ha.server.address=192.168.1.9
ha.server.port=7475
coordinators=192.168.1.9:5001,192.168.1.9:5002,192.168.1.9:5003

server.id=3
ha.server.address=192.168.1.9
ha.server.port=7476
coordinators=192.168.1.9:5001,192.168.1.9:5002,192.168.1.9:5003

仍然没有运气,它停止了以下日志

16:49:13.386 [main] DEBUG o.s.b.f.annotation.InjectionMetadata - Processing injected method of bean 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': AutowiredMethodElement for public void org.springframework.data.neo4j.config.Neo4jConfiguration.setGraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService)
16:49:13.387 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'graphDatabaseService'
16:49:13.387 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'graphDatabaseService'
16:49:13.522 [main] DEBUG neo4j - WARNING! Deprecated configuration options used. See manual for details
16:49:13.522 [main] DEBUG neo4j - neo4j.ext.udc.disable has been replaced with neo4j.ext.udc.enabled
16:49:13.522 [main] DEBUG neo4j - cannot configure writers and searchers individually since they go together

2 个答案:

答案 0 :(得分:1)

瑞克,

这是一个关于如何将嵌入式HA的参数传递给HighlyAvailableGraphDatabase的示例。

<neo4j:config graphDatabaseService="graphDatabaseService" />

<context:property-placeholder 
        location="file:/etc/neo4j-ha.properties" />

<bean id="graphDatabaseService" class="org.neo4j.kernel.HighlyAvailableGraphDatabase"
                destroy-method="shutdown" scope="singleton">
                <constructor-arg index="0" value="${database.path}" />
                <constructor-arg index="1"> 
                        <map>
                                <entry key="ha.server_id" value="${server.id}"></entry>
                                <entry key="ha.server" value="${ha.server.address}:${ha.server.port}"></entry>
                                <entry key="ha.coordinators" value="${coordinators}"></entry>
                                <entry key="enable_remote_shell" value="port=1331"></entry>
                                <entry key="ha.pull_interval" value="1"></entry>
                        </map>
                </constructor-arg>
</bean>

另见:Neo4j HA (embedded) via Spring?

答案 1 :(得分:0)

前一段时间我写了一篇博文。应该准确地给你你想要的东西。 (虽然我决定使用Java配置)。

http://michaelandrews.typepad.com/the_technical_times/2013/04/spring-data-neo4j-configuration-for-highly-available-cluster-and-sub-reference-type-representation-s.html

中号