2015-11-09 54 views
2

我必須在兩個Neo4j數據庫之間移動數據。其中一個是較舊的(2.1.8),而另一個是2.3.0。 我試過的是這個,但你也可以在輸出中看到有什麼不對。在Neo4j數據庫之間移動數據

/home/adam/neo4j-community-2.1.8/bin/neo4j-shell -path /home/adam/neo4j_bak9/ -c "dump" | /home/adam/neo4j-community-2.3.0/bin/neo4j-shell -file - 
Transaction started 
3 ms 

WARNING: Invalid input 'c': expected whitespace, comment, ';' or end of input (line 2, column 1 (offset: 39)) 
"create index on :`Location`(`latitude`)" 
^ 
ERROR (-v for expanded information): 
    Transaction was marked as successful, but unable to commit transaction so rolled back. 

-host  Domain name or IP of host to connect to (default: localhost) 
-port  Port of host to connect to (default: 1337) 
-name  RMI name, i.e. rmi://<host>:<port>/<name> (default: shell) 
-pid  Process ID to connect to 
-c   Command line to execute. After executing it the shell exits 
-file  File containing commands to execute, or '-' to read from stdin. After executing it the shell exits 
-readonly Connect in readonly mode (only for connecting with -path) 
-path  Points to a neo4j db path so that a local server can be started there 
-config Points to a config file when starting a local server 

Example arguments for remote: 
    -port 1337 
    -host 192.168.1.234 -port 1337 -name shell 
    -host localhost -readonly 
    ...or no arguments for default values 
Example arguments for local: 
    -path /path/to/db 
    -path /path/to/db -config /path/to/neo4j.config 
    -path /path/to/db -readonly 

它看起來是Neo4j的是生產的語法,不能被新版本讀取。我做錯了什麼或者這是一個錯誤?

回答

3

這是我的問題。我認爲它對dump頂部的create index語句期待分號(反之亦然)。很遺憾,它不是更順利的進口/出口。

升級的Neo4j的最簡單,最乾淨的方式另一種選擇(假設你能夠有一點停機時間):

  • 關閉這兩個服務器
  • 複製從舊datagraph.db目錄DIR到新
  • 確保新的數據庫已在conf/neo4j.properties文件allow_store_upgrade=true
  • 啓動新的數據庫

啓動時,它應該看到數據庫文件來自舊版本,並自動將其升級到2.3.0格式。

+1

前段時間我創建了一個腳本,關心下載本身並執行升級:http://blog.armbruster-it.de/2012/06/upgrading-an-old-neo4j-database-using- groovy/ –

+0

我寫了一個可以正確導出的shell擴展:https://github.com/jexp/neo4j-shell-tools#cypher-export –

+0

將舊數據庫複製到新位置並設置allow_store_upgrade的想法是我的第一個。但是,這有問題。我通過2.1.8 - > 2.2.6 - > 2.3.0解決了它。不過,這是一件好事,一種簡單的方法來轉儲數據庫,然後加載它,而無需其他工具。原創想法看起來很有希很遺憾,由於這個小問題,這是不可能的。我希望它至少兼容2.3.0 <-> 2.3.0。 – Cob