2015-11-09 59 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