简体   繁体   English

如何迁移/移位/复制/移动在Neo4j的数据

[英]How to migrate/shift/copy/move data in Neo4j

Does any one know how to migrate data from one instance of Neo4j to another.是否任何一个知道如何将数据从Neo4j的一个实例迁移到另一个。 To be more precise, I want to know, how to move the data from one instance of Neo4j on my local machine to another on remote machine.更精确地说,我想知道,如何将数据从Neo4j的一个实例移动我的本地机器到另一台远程机器上。 Does any one have any idea about it.没有任何一个有任何想法。

I'm working on my windows machine with Eclipse and Embedded Neo4j .我的工作我的Windows机器与Eclipse和嵌入式的Neo4j上。 I need to transfer this data to remote Neo4j instance on a Centos machine.我需要这个数据传送到远程的Neo4j例如一个CentOS的机器上。 Please help me with this.请帮我解决一下这个。

Not sure how to do it for "embedded neo4j db".不确定如何为“嵌入式 neo4j db”执行此操作。 But for standalone and in case you have something like the command line tool "Putty" on your windows machine, this should work.但是对于独立的,如果你的 Windows 机器上有类似命令行工具“Putty”的东西,这应该可以工作。 Instead of $NEO4j_HOME you can also use the normal path without the env variable.除了 $NEO4j_HOME,您还可以使用没有 env 变量的普通路径。

$NEO4J_HOME/bin/neo4j stop

cd $NEO4J_HOME/data
tar -cvf graph.db.tar graph.db
gzip graph.db.tar

scp -i ~/some_path/key_for_remote_server.pem ./graph.db.tar.gz username@your_remote_domeain.com:~/

ssh -i ~/some_path/key_for_remote_server.pem/ username@your_remote_domeain.com

On your remote server (at least this works for ubuntu): Maybe you need to use "sudo" (prefix the commands with sudo).在您的远程服务器上(至少这适用于 ubuntu):也许您需要使用“sudo”(在命令前加上 sudo)。

mv ./graph.db.tar.gz /some_path/
cd /some_path/
gunzip graph.db.tar.gz
tar -xvf graph.db.tar

$NEO4J_HOME/bin/neo4j start
$NEO4J_HOME/bin/neo4j status

You can migrate the data by using the apoc procedure by running the below query in the cypher shell from where the data needs to be exported:您可以通过使用APOC程序通过从那里要导出的数据需求的暗号shell中运行下面的查询迁移数据:

CALL apoc.export.cypher.all('myfilename.cypher');

This will download the file with cypher queries in the import folder这将下载与CYPHER查询文件中导入文件夹

Go the database instance where the data needs to be imported and copy the file in the import folder.去哪里需要数据要导入的数据库实例和复制文件中导入文件夹。 Run the below command using the cypher shell:使用 cypher shell 运行以下命令:

apoc.cypher.runFile("myfilename.cypher",{}) yield row, result;

For more advanced options follow the below links:对于更高级的选项,按照下面的链接:

I found out the following workaround for copying the data from a server in the cluster to all others, after using the neo4j-import tool:我发现了以下解决方法对于集群中的从服务器将数据复制到所有其他使用Neo4j的导入工具后:

  1. Stop all nodes.停止所有节点。

  2. On the new node/server, where you need your data to be copied, you have to create the database folder for that graph (in my case loadTest): /neo4j-enterprise-3.1.0/data/databases/loadTest.db在新的节点/服务器,你需要你的数据被复制,你必须创建该图的数据库文件夹(在我的情况下,负载测试):/neo4j-enterprise-3.1.0/data/databases/loadTest.db

  3. Then, the source node/server that is holding the data, you have to copy here the neostore.id file to the destination server db folder (loadTest.db from the previous step).然后,源节点/服务器持有该数据,你必须在这里neostore.id文件复制到目标服务器数据库文件夹(loadTest.db从之前的步骤)。

  4. Start all nodes.启动所有节点。 In the background neo4j will copy data from other cluster servers to the new node.在后台,neo4j 会将数据从其他集群服务器复制到新节点。

For embedded mode , you would just need to locate the graph neo4j-db folder location then zip and send it to the remote system.对于嵌入模式,你只需要找到该图的Neo4j-DB文件夹的位置,然后压缩并传送到远程系统。

In your code where you would have called graphdatabaseservice , you would have given the target location在你的代码,你会叫graphdatabaseservice,你会给出的目标位置

Check if its relative path then the database might be in your project folder .检查其相对路径,那么数据库可能是在项目文件夹。

Now for running the db instance on browser , you will need to use the neo4j communty server and point it to the folder containing the index folder.现在运行浏览器的数据库实例,您将需要使用的Neo4j communty服务器并将其指向包含索引文件夹中的文件夹。 So if your neo4j-db is located at $project/tmp/neo4j-db then you will give the file path till this folder(the index folder will be inside this folder)所以,如果你的Neo4j-DB位于$项目的/ tmp /的Neo4j-DB,那么你会给直到该文件夹​​中的文件路径(索引文件夹将在此文件夹中)

Edit编辑

The folder that will contain the schema and index folders needs to be zipped.将包含模式和索引文件夹中的文件夹必须压缩。 You can upload and unzip the folder at a certain location using Putty on your standalone server.你可以上传你的独立服务器上使用腻子在某个位置解压的文件夹。 Then just change the org.neo4j.server.database.location in conf/neo4j-server.properties file.然后,只需改变org.neo4j.server.database.locationconf/neo4j-server.properties文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM