0

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

我正在考虑使用带有 HA 的 Neo4j Embedded?有人可以为我提供链接/教程以使用 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
4

2 回答 2

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?

于 2013-05-15T06:25:44.840 回答
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

于 2013-11-07T14:15:52.460 回答