Neo4J:批量导入neo4j-admin import

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/chengyuqiang/article/details/102562224

(1)停止Neo4J

[root@elastic1 neo4j-community-3.5.11]# bin/neo4j status
Neo4j is running at pid 25395
[root@elastic1 neo4j-community-3.5.11]# bin/neo4j stop
Stopping Neo4j.. stopped
[root@elastic1 neo4j-community-3.5.11]#

(2)删除graph.db

[root@elastic1 data]# cd databases/
[root@elastic1 databases]# ls
graph.db  movies_graph.db  store_lock
[root@elastic1 databases]# ll
total 8
drwxr-xr-x 3 root root 4096 Oct 14 14:57 graph.db
-rw-r--r-- 1 root root    0 Oct 14 14:37 store_lock
[root@elastic1 databases]# rm -rf graph.db/

(3)准备CSV文件

[root@elastic1 import]# pwd
/opt/neo4j-community-3.5.11/import
[root@elastic1 import]# ll
total 12
-rw-r--r-- 1 root root 123 Oct 15 09:52 actors.csv
-rw-r--r-- 1 root root 170 Oct 15 09:53 movies.csv
-rw-r--r-- 1 root root 359 Oct 15 09:54 roles.csv
[root@elastic1 import]# 
[root@elastic1 import]# cat movies.csv
movieId:ID,title,year:int,:LABEL
tt0133093,"The Matrix",1999,Movie
tt0234215,"The Matrix Reloaded",2003,Movie;Sequel
tt0242653,"The Matrix Revolutions",2003,Movie;Sequel
[root@elastic1 import]# cat actors.csv
personId:ID,name,:LABEL
keanu,"Keanu Reeves",Actor
laurence,"Laurence Fishburne",Actor
carrieanne,"Carrie-Anne Moss",Actor
[root@elastic1 import]# cat roles.csv
:START_ID,role,:END_ID,:TYPE
keanu,"Neo",tt0133093,ACTED_IN
keanu,"Neo",tt0234215,ACTED_IN
keanu,"Neo",tt0242653,ACTED_IN
laurence,"Morpheus",tt0133093,ACTED_IN
laurence,"Morpheus",tt0234215,ACTED_IN
laurence,"Morpheus",tt0242653,ACTED_IN
carrieanne,"Trinity",tt0133093,ACTED_IN
carrieanne,"Trinity",tt0234215,ACTED_IN
carrieanne,"Trinity",tt0242653,ACTED_IN
[root@elastic1 import]#

(4)导入命令

bin/neo4j-admin import 
--mode csv 
--database=graph.db 
--nodes:Move ./import/movies.csv 
--nodes:Actor ./import/actors.csv 
--relationships:Role ./import/roles.csv
[root@elastic1 neo4j-community-3.5.11]# bin/neo4j-admin import --mode csv --database=graph.db --nodes:Move ./import/movies.csv --nodes:Actor ./import/actors.csv --relationships:Role ./import/roles.csv
Neo4j version: 3.5.11
Importing the contents of these files into /opt/neo4j-community-3.5.11/data/databases/graph.db:
Nodes:
  :Move
  /opt/neo4j-community-3.5.11/./import/movies.csv

  :Actor
  /opt/neo4j-community-3.5.11/./import/actors.csv
Relationships:
  :Role
  /opt/neo4j-community-3.5.11/./import/roles.csv

Available resources:
  Total machine memory: 7.64 GB
  Free machine memory: 1.25 GB
  Max heap memory : 1.78 GB
  Processors: 4
  Configured max memory: 5.28 GB
  High-IO: false

Import starting 2019-10-15 10:20:01.710+0800
  Estimated number of nodes: 6.00 
  Estimated number of node properties: 15.00 
  Estimated number of relationships: 9.00 
  Estimated number of relationship properties: 9.00 
  Estimated disk space usage: 1.20 kB
  Estimated required memory usage: 1020.01 MB

InteractiveReporterInteractions command list (end with ENTER):
  c: Print more detailed information about current stage
  i: Print more detailed information

(1/4) Node import 2019-10-15 10:20:01.754+0800
  Estimated number of nodes: 6.00 
  Estimated disk space usage: 552.00 B
  Estimated required memory usage: 1020.01 MB
-......... .......... .......... .......... ..........   5% ∆228ms
.......... .......... .......... .......... ..........  10% ∆2ms
.......... .......... .......... .......... ..........  15% ∆1ms
.......... .......... .......... .......... ..........  20% ∆0ms
.......... .......... .......... .......... ..........  25% ∆1ms
.......... .......... .......... .......... ..........  30% ∆1ms
.......... .......... .......... .......... ..........  35% ∆1ms
.......... .......... .......... .......... ..........  40% ∆1ms
.......... .......... .......... .......... ..........  45% ∆1ms
.......... .......... .......... .......... ..........  50% ∆0ms
.......... .......... .......... .......... ..........  55% ∆1ms
.......... .......... .......... .......... ..........  60% ∆0ms
.......... .......... .......... .......... ..........  65% ∆1ms
.......... .......... .......... .......... ..........  70% ∆0ms
.......... .......... .......... .......... ..........  75% ∆0ms
.......... .......... .......... .......... ..........  80% ∆1ms
.......... .......... .......... .......... ..........  85% ∆0ms
.......... .......... .......... .......... ..........  90% ∆1ms
.......... .......... .......... .......... ..........  95% ∆0ms
.......... .......... .......... .......... .......... 100% ∆0ms

(2/4) Relationship import 2019-10-15 10:20:02.030+0800
  Estimated number of relationships: 9.00 
  Estimated disk space usage: 675.00 B
  Estimated required memory usage: 1.00 GB
.......... .......... .......... .......... ..........   5% ∆37ms
.......... .......... .......... .......... ..........  10% ∆1ms
.......... .......... .......... .......... ..........  15% ∆0ms
.......... .......... .......... .......... ..........  20% ∆0ms
.......... .......... .......... .......... ..........  25% ∆0ms
.......... .......... .......... .......... ..........  30% ∆1ms
.......... .......... .......... .......... ..........  35% ∆0ms
.......... .......... .......... .......... ..........  40% ∆0ms
.......... .......... .......... .......... ..........  45% ∆1ms
.......... .......... .......... .......... ..........  50% ∆0ms
.......... .......... .......... .......... ..........  55% ∆0ms
.......... .......... .......... .......... ..........  60% ∆0ms
.......... .......... .......... .......... ..........  65% ∆1ms
.......... .......... .......... .......... ..........  70% ∆0ms
.......... .......... .......... .......... ..........  75% ∆0ms
.......... .......... .......... .......... ..........  80% ∆0ms
.......... .......... .......... .......... ..........  85% ∆1ms
.......... .......... .......... .......... ..........  90% ∆0ms
.......... .......... .......... .......... ..........  95% ∆0ms
.......... .......... .......... .......... .......... 100% ∆0ms

(3/4) Relationship linking 2019-10-15 10:20:02.073+0800
  Estimated required memory usage: 1020.01 MB
-......... .......... .......... .......... ..........   5% ∆29ms
.......... .......... .......... .......... ..........  10% ∆1ms
.......... .......... .......... .......... ..........  15% ∆0ms
.......... .......... .......... .......... ..........  20% ∆0ms
.......... .......... .......... .......... ..........  25% ∆0ms
.......... .......... .......... .......... ..........  30% ∆1ms
.......... .......... .......... .......... ..........  35% ∆0ms
.......... .......... .......... .......... ..........  40% ∆0ms
.......... .......... .......... .......... ..........  45% ∆0ms
.......... .......... .......... .......... ..........  50% ∆1ms
.......... .......... .......... .......... ..........  55% ∆0ms
.......... .......... .......... .......... ..........  60% ∆0ms
.......... .......... .......... .......... ..........  65% ∆0ms
.......... .......... .......... .......... ..........  70% ∆0ms
.......... .......... .......... .......... ..........  75% ∆1ms
.......... .......... .......... .......... ..........  80% ∆0ms
.......... .......... .......... .......... ..........  85% ∆0ms
.......... .......... .......... .......... ..........  90% ∆0ms
.......... .......... .......... .......... ..........  95% ∆1ms
.......... .......... .......... .......... .........(4/4) Post processing 2019-10-15 10:20:02.216+0800
  Estimated required memory usage: 1020.01 MB
-......... .......... .......... .......... ..........   5% ∆25ms
.......... .......... .......... .......... ..........  10% ∆0ms
.......... .......... .......... .......... ..........  15% ∆1ms
.......... .......... .......... .......... ..........  20% ∆0ms
.......... .......... .......... .......... ..........  25% ∆0ms
.......... .......... .......... .......... ..........  30% ∆0ms
.......... .......... .......... .......... ..........  35% ∆0ms
.......... .......... .......... .......... ..........  40% ∆1ms
.......... .......... .......... .......... ..........  45% ∆0ms
.......... .......... .......... .......... ..........  50% ∆0ms
.......... .......... .......... .......... ..........  55% ∆0ms
.......... .......... .......... .......... ..........  60% ∆1ms
.......... .......... .......... .......... ..........  65% ∆0ms
.......... .......... .......... .......... ..........  70% ∆0ms
.......... .......... .......... .......... ..........  75% ∆0ms
.......... .......... .......... .......... ..........  80% ∆1ms
.......... .......... .......... .......... ..........  85% ∆0ms
.......... .......... .......... .......... ..........  90% ∆0ms
.......... .......... .......... .......... ..........  95% ∆0ms
.......... .......... .......... .......... .......... 100% ∆1ms


IMPORT DONE in 942ms. 
Imported:
  6 nodes
  9 relationships
  15 properties
Peak memory usage: 1.00 GB
[root@elastic1 neo4j-community-3.5.11]#

(5)启动

[root@elastic1 neo4j-community-3.5.11]# bin/neo4j start
Active database: graph.db
Directories in use:
  home:         /opt/neo4j-community-3.5.11
  config:       /opt/neo4j-community-3.5.11/conf
  logs:         /opt/neo4j-community-3.5.11/logs
  plugins:      /opt/neo4j-community-3.5.11/plugins
  import:       NOT SET
  data:         /opt/neo4j-community-3.5.11/data
  certificates: /opt/neo4j-community-3.5.11/certificates
  run:          /opt/neo4j-community-3.5.11/run
Starting Neo4j.
Started neo4j (pid 9605). It is available at http://0.0.0.0:7474/
There may be a short delay until the server is ready.
See /opt/neo4j-community-3.5.11/logs/neo4j.log for current status.
[root@elastic1 neo4j-community-3.5.11]#

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券