2019-06-28 知识图谱:Neo4j数据导入与多库切换

一. 数据导入

(1)import导入csv

格式:

neo4j-admin import [--mode=csv] [--database=]

                          [--additional-config=]

                          [--report-file=]

                          [--nodes[:Label1:Label2]=<"file1,file2,...">]

                          [--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">]

                          [--id-type=]

                          [--input-encoding=]

                          [--ignore-extra-columns[=]]

                          [--ignore-duplicate-nodes[=]]

                          [--ignore-missing-nodes[=]]

                          [--multiline-fields[=]]

                          [--delimiter=]

                          [--array-delimiter=]

                          [--quote=]

                          [--max-memory=]

                          [--f=]

                          [--high-io=]

命令:

./bin/neo4j-import --into data/databases/graph_kg_merge_id.db --nodes:Persons data/csv_kg_merge_id/persons.csv --nodes:Industry data/csv_kg_merge_id/industry.csv --relationships:Director data/csv_kg_merge_id/director.csv --multiline-fields=true

作者:ai_1046067944 来源:CSDN 原文:https://blog.csdn.net/ai_1046067944/article/details/85342494 版权声明:本文为博主原创文章,转载请附上博文链接!

2. mount 多个数据库database.db文件

(1)官网推荐方式:地址

If you have multiple graphs set up and want to quickly switch between each without modifying dbms.active_database in conf/neo4j.conf, you can accomplish this with a neo4j restartand with the environment variable NEO4J_CONF defined pointing to the appropriate/corresponding neo4j.conf file.

For example, one could define:

$NEO4J_HOME/conf

$NEO4J_HOME/conf_test

and where each directory has the same files, namely:

jmx.access  jmx.password  neo4j.conf  neo4j-wrapper.conf

and in the $NEO4J_HOME/conf_tests/neo4j.conf one might configure the databse name to a different graph:

# The name of the database to mount

dbms.active_database=graph.db.test

Then, prior to a restart of neo4j if one modifies the environment variable NEO4J_CONF to point to the $NEO4J_HOME/conf_test, for example:

export NEO4J_CONF="/home/neo/neo4j-enterprise-3.0.7/conf_test"

then upon restart of neo4j, it will then use the graph in the graph.db.test location.

Note: Be aware that the dbms.active_database setting in neo4j.conf is one of many settings that you may want/need to change. If for example you do not change #dbms.directories.logs=logs then both conf files will result in each Neo instance writing to $NEO4J_HOME/logs.

(2)设置soft links 到 graph.db

因为Neo4j的import导入时,只能导入一个不存的db,这就在想创建多个库时,需要去切换,Neo4j默认的库是graph.db,在./conf/neo4j.conf可以修改


切换多个库的方法,将新库重新连接到默认库graph.db,然后重启Neo4j

//软连接

>>>cd ./data/databases/

>>>ln -s graph_kg.db graph.db

//重启neo4j

>>>cd $NEO4j_HOME/bin

>>>./neo4j restart

// 删除软连接

>>>ln-s test_chk  test_chk_ln

>>>rm -rf  ./test_chk_ln

参考文章:地址

你可能感兴趣的:(2019-06-28 知识图谱:Neo4j数据导入与多库切换)