neo4j 3.4.1中插入若干数据后,未写入graph.db目录中数据文件
发布于 6 年前 作者 dengchang 4684 次浏览 来自 问答

写入了数据,但是neostore.nodestore.db这些文件中数据不对应,怎么能把数据实时持久化到文件呢?比较困惑,哪位大神可以解答下

QQ20180729-4@2x.png QQ20180729-3@2x.png QQ20180729-2@2x.png

8 回复

Neo4j 的数据本身就是持久化到文件的呀。能详细说一下你的步骤以及遇到的问题吗?

用什么程序写入? Spring data neo4j? 如果是使用Spring data neo4j,必须用注解将事务提交才行

@zhizh 张老师好!下面是我的操作步骤

  1. mac上下载安装neo4j desktop 1.1.7版本
  2. 在MyProject里new了一个graph,neo4j版本选择3.4.1
  3. 在上面graph对应的neo4j browser里执行类似以下cyper语句,创建节点、关系和标签
  4. 使用UltraEdit在数据对应目录下查看文件内容/Users/xxx/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-c6cfdcd8-8662-402a-bfb5-77d018a44faf/installation-3.4.1/data/databases/graph.db/
  5. neostore.nodestore.db文件一直为空,且其对应的id文件neostore.nodestore.db.id对应的最大可用ID一直为0;属性、标签、关系等文件有同样问题;查看文件修改时间,发现只有该目录下profile文件夹里的文件会有修改操作

CREATE (a:User {mis:‘zhangsan’, company:‘xxx’}), (b:User {mis:‘lisi’, company:‘xxx’}), (aa:POI {name:‘jinbaiwan’, rate:3}), (bb:POI {name:‘meizhoudongpo’, rate:4}), (cc:POI {name:‘xiaoxiangshengxian’, rate:5, description:‘https://neo4j.com[Neo4j] is the world s leading Graph Database. It is a high performance graph store with all the features expected of a mature and robust database, like a friendly query language and ACID transactions. The programmer works with a flexible network structure of nodes and relationships rather than static tables – yet enjoys all the benefits of enterprise-quality database. For many applications, Neo4j offers orders of magnitude performance benefits compared to relational DBs. https://neo4j.com[Neo4j] is the worlds leading Graph Database. It is a high performance graph store with all the features expected of a mature and robust database, like a friendly query language and ACID transactions. The programmer works with a flexible network structure of nodes and relationships rather than static tables – yet enjoys all the benefits of enterprise-quality database. For many applications, Neo4j offers orders of magnitude performance benefits compared to relational DBs.’}), (a)-[:consume{time:‘2018-01-23’}]->(aa), (a)-[:consume{time:‘2018-02-23’}]->(bb), (b)-[:consume{time:‘2018-03-23’}]->(bb), (b)-[:consume{time:‘2018-04-23’}]->(cc)

@pangguoming 还没在具体工程写数据,我是在neo4j brower里手工输入cyper语句写入的数据,具体步骤在上一条回复里

我估计数据还在缓存里,并没有存到磁盘里去。可以用两个方法试一下: 1、停掉服务,看看数据是不是存到磁盘里去了(我觉得应该会); 2、写入后,用 Cypher 读出,看看是否写进去了(我觉得应该能正确读出来)。 这两个如果没有问题,那就可以安心睡觉了。如果有问题,就有点可怕了,需要到 https://github.com/neo4j/neo4j/issues 发 bug 了。

@pangguoming 在他的文章里详细解析了你的问题。参见:http://neo4j.com.cn/topic/5b5d6417d40e09d75e4d2389

@zhizh 张老师,按照您的方法试了下

  1. 停掉服务,数据没有写到对应文件(比如node相关数据并没有写到neostore.nodestore.db文件中);但是发现3.4.1版本比2.x版本在graph.db目录下多了一个profiles文件夹,并且实时有数据更新,怀疑是新版本写到了这里
  2. 写入数据用cyper读,是可以读出正确数据的
  3. 我本地下载了neo4j-community-2.3.12,测试了下,数据是可以实时写到对应文件的(比如node相关数据实时写到neostore.nodestore.db)

所以猜测是3.4.1更改了本地文件的写入策略,可能是需要数据到达一定量才会持久化到对应文件

Neo4j是立即持久化数据到硬盘的。你确定看的是正确的数据库目录?另外,建议试试以下步骤:

  • 把UltraEdit关掉,避免多个应用打开同一文件;
  • 查看debug.log和neo4j.log 不管什么版本,大致的数据库文件格式和名称是不变的。3.4版本的Profiles是页缓存的硬盘拷贝,类似Windows下的page文件。
回到顶部