简体   繁体   中英

How to Dump/Load Neo4j Database in Azure?

Searched the marketplace in Azure and installed Neo4j High Availability Cluster

and currently running cluster of 3 vm's

Trying to test dump/load and I got the error:

~$ neo4j-admin dump --database=graph.db --to=graph.dump
org.neo4j.commandline.admin.CommandFailed: you do not have permission to dump the 
database -- is Neo4j running as a different user?
        at org.neo4j.commandline.dbms.DumpCommand.execute(DumpCommand.java:100)
        at org.neo4j.commandline.admin.AdminTool.execute(AdminTool.java:127)
        at org.neo4j.commandline.admin.AdminTool.main(AdminTool.java:51)
Caused by: org.neo4j.commandline.dbms.CannotWriteException: Could not write to: 
/var/lib/neo4j/data/databases/graph.db/store_lock
        at org.neo4j.commandline.dbms.StoreLockChecker.check(StoreLockChecker.java:84)
        at org.neo4j.commandline.dbms.DumpCommand.execute(DumpCommand.java:86)
        ... 2 more
command failed: you do not have permission to dump the database -- is Neo4j running 
as a different user?

Should I shutdown all three VM's? If so, how do I do that?

Dump/Load Manual doesn't seem to explain how to shutdown the DB or which VM in the cluster (all three or just the primary) should be shut down. https://neo4j.com/docs/operations-manual/current/tools/dump-load/

The error-logs clearly suggest that you're possibly doing database dump/load with a wrong user (a different user than the user with 'admin' role):

"You do not have permission to dump the database -- is Neo4j running as a different user?"

Which user you're running these commands as? Probably you can do a sanity check as follows:

CALL dbms.showCurrentUser()
+---------------------+
| username    | flags |
+---------------------+
| "johnsmith" | []    |
+---------------------+

To list all Neo4j users, you can try:

CALL dbms.security.listUsers()
+---------------------------------------------------------------------+
| username | roles                     | flags                        |
+---------------------------------------------------------------------+
| "neo4j"  | ["admin"]                 | []                           |
| "anne"   | []                        | ["password_change_required"] |
| "bill"   | ["reader"]                | ["is_suspended"]             |
| "john"   | ["architect","publisher"] | []                           |
+---------------------------------------------------------------------+

If your current user is not neo4j (or any other user with admin role - as you have used Market Place services, then there can be a different user) then switch to appropriate user using:

$neo4j-home> bin/cypher-shell -u neo4j -p secret

Also, to perform an "online" backup & restore from a running Neo4j server, you may refer to the following section of the official documentation: https://neo4j.com/docs/operations-manual/current/backup

For offline backup (which you've been attempting), first you need to take the DB dump as follows:

$neo4j-home> bin/neo4j-admin dump --database=MyNewDB.db --to=/backups/JeffreyGoinesDB.dump
$neo4j-home> ls /backups/
$neo4j-home> JeffreyGoinesDB.dump

While Loading the dump back again to Neo4j, first you need to shutdown the database ( Not VM ) as follows:

$neo4j-home> bin/neo4j stop
Stopping Neo4j.. stopped
$neo4j-home> bin/neo4j-admin load --from=/backups/JeffreyGoinesDB.dump --database=MyNewDB.db --force

Hope it helps!!

If this is a Windows build, try to launch the terminal as Administrator and use the same command. If this is a Linux build, try to start your command with sudo. As the request is from a few months ago, please share the details if you were able to resolve your issue with other means.

On Linux

~$ sudo neo4j-admin dump --database=graph.db --to=graph.dump

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