禁用Neo4j图形数据库的锁定? [英] Disable locking of Neo4j graph database?

查看:457
本文介绍了禁用Neo4j图形数据库的锁定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序正在/tmp/import.db处填充Neo4j图形数据库.除了单元测试之外,我还喜欢使用Neo4j浏览器(AKA Neo4j社区)在同一数据库中进行一些挖掘.当浏览器运行时,我的应用程序运行时崩溃,因为它的数据库已锁定:

My application is populating a Neo4j graph database at /tmp/import.db. In addition to my unit tests I like to use the Neo4j browser (AKA Neo4j Community) to do some digging in that same database. When the browser is running, my application crashes when it gets run because the database it is locked:

Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /tmp/import.db
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:330)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:92)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:198)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:69)
    at no.marcello.cmdb.Import.<init>(Import.java:34)
    at no.marcello.cmdb.Main.main(Main.java:10)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@5d20e46' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:509)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:307)
    ... 6 more
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: /tmp/import.db/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
    at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:82)
    at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:44)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:503)
    ... 8 more
Caused by: java.io.IOException: Unable to lock sun.nio.ch.FileChannelImpl@70b0b186
    at org.neo4j.kernel.impl.nioneo.store.FileLock.wrapFileChannelLock(FileLock.java:38)
    at org.neo4j.kernel.impl.nioneo.store.FileLock.getOsSpecificFileLock(FileLock.java:93)
    at org.neo4j.kernel.DefaultFileSystemAbstraction.tryLock(DefaultFileSystemAbstraction.java:89)
    at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
    ... 10 more

现在,我必须在应用程序的每次运行之间分别单击neo4j stopneo4j start,以查看更改.我的手对此感到厌倦.

Now I have to neo4j stop and neo4j start between every run of my application to see the changes. My hands got tired of that.

使用Neo4j浏览器时可以禁用数据库锁定吗?我想这样做是出于测试目的,因为它有助于在我填充数据库模型时了解我的数据库模型是如何演变的.

Can I disable locking of the database when using the Neo4j browser? I'd like to do that for testing purposes, as it helps alot to see how my database model evolves while I'm populating it.

推荐答案

无论如何,小型数据库系统通常可以两种方式运行:嵌入式或服务器.在嵌入式模式下,其思想是一次只能有一个程序可以读写数据库.这对于许多应用程序非常有用,并且允许数据库省去必要的代码以允许在多个程序之间进行访问,这会浪费时间,代码和处理能力.

Database systems -- small ones, anyway -- can often run in either of two modes: embedded or server. In embedded mode, the idea is that one program and only one program can read and write to the database at a time. This is quite useful for many applications, and allows the database to dispense with the code necessary to allow access among multiple programs, which eats up time, code, and processing power.

在服务器模式下,数据库管理系统本身作为单独的程序运行,并且构建为具有多个程序可以访问它.

In server mode, the database management system itself runs as a separate program, and it is built to have multiple programs access it.

根据上面错误消息中的类,您有一个嵌入式数据库,因此问题的答案是不,您不能在此模式下执行此操作".我希望可以切换到使用neo4j的服务器模式,但是连接到该服务器将涉及一些代码更改,然后在确保程序运行时确保数据库系统正在运行等次要问题.

Based on the class in the error message above, you have an embedded database, so the answer to your question is "no, you can't do that in this mode". You can switch to using a server mode of neo4j, I expect, but connecting to it will involve some code changes, and you then have the minor problems of making sure your database system is running when your program runs, etc.

因此您可以使用此数据库数据来执行此操作,但是必须更改运行数据库管理系统的方式.

So you can do it with this database data, but you have to change the mode in which you are running the database management system.

这篇关于禁用Neo4j图形数据库的锁定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆