简体   繁体   中英

How to migrate/shift/copy/move data in Neo4j

Does any one know how to migrate data from one instance of Neo4j to another. 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. Does any one have any idea about it.

I'm working on my windows machine with Eclipse and Embedded Neo4j . I need to transfer this data to remote Neo4j instance on a Centos machine. Please help me with this.

Not sure how to do it for "embedded neo4j db". But for standalone and in case you have something like the command line tool "Putty" on your windows machine, this should work. Instead of $NEO4j_HOME you can also use the normal path without the env variable.

$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).

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:

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

This will download the file with cypher queries in the import folder

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:

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:

  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

  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).

  4. Start all nodes. In the background neo4j will copy data from other cluster servers to the new node.

For embedded mode , you would just need to locate the graph neo4j-db folder location then zip and send it to the remote system.

In your code where you would have called graphdatabaseservice , you would have given the target location

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. 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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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