写入了数据,但是neostore.nodestore.db这些文件中数据不对应,怎么能把数据实时持久化到文件呢?比较困惑,哪位大神可以解答下
@zhizh 张老师好!下面是我的操作步骤
- mac上下载安装neo4j desktop 1.1.7版本
- 在MyProject里new了一个graph,neo4j版本选择3.4.1
- 在上面graph对应的neo4j browser里执行类似以下cyper语句,创建节点、关系和标签
- 使用UltraEdit在数据对应目录下查看文件内容/Users/xxx/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-c6cfdcd8-8662-402a-bfb5-77d018a44faf/installation-3.4.1/data/databases/graph.db/
- 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)
我估计数据还在缓存里,并没有存到磁盘里去。可以用两个方法试一下: 1、停掉服务,看看数据是不是存到磁盘里去了(我觉得应该会); 2、写入后,用 Cypher 读出,看看是否写进去了(我觉得应该能正确读出来)。 这两个如果没有问题,那就可以安心睡觉了。如果有问题,就有点可怕了,需要到 https://github.com/neo4j/neo4j/issues 发 bug 了。
@zhizh 张老师,按照您的方法试了下
- 停掉服务,数据没有写到对应文件(比如node相关数据并没有写到neostore.nodestore.db文件中);但是发现3.4.1版本比2.x版本在graph.db目录下多了一个profiles文件夹,并且实时有数据更新,怀疑是新版本写到了这里
- 写入数据用cyper读,是可以读出正确数据的
- 我本地下载了neo4j-community-2.3.12,测试了下,数据是可以实时写到对应文件的(比如node相关数据实时写到neostore.nodestore.db)
所以猜测是3.4.1更改了本地文件的写入策略,可能是需要数据到达一定量才会持久化到对应文件