You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker部署Neo4j 3.5.x跨服务器迁移及4.0版本适配问题咨询

Great question—let’s break down why your direct copy approach failed first, then walk through two reliable migration methods for moving from Neo4j 3.5.x (Docker) to 4.0 on a new server, including the Cypher export/import method you asked about.

Why Your Direct Copy Failed
  • Neo4j 4.0 changed the default database name from graph.db to neo4j—so your copied data wasn’t being loaded as the active database.
  • The storage engine format changed between 3.5 and 4.0; raw data directory copies aren’t compatible across these major versions.
  • The auth prompt issue happens because 4.0 handles authentication differently, and your misaligned data directory caused the NEO4J_AUTH=none env var to be ignored.
  • The WebSocket error? You mapped port 3003 to 3003 in your Docker run command, but Neo4j’s Bolt protocol (used for WebSocket connections) runs on port 7687 by default. That mismatch broke the connection.

1. Neo4j Admin Dump & Load (Official, Best for Large Datasets)

This is the most reliable method for cross-server and cross-version migrations—it preserves all data, indexes, and constraints efficiently.

Step 1: Export from Your 3.5.x Server

  1. Stop your running Neo4j 3.5 container:
    sudo docker stop vis
    
  2. Create a dump of your graph.db database using the Neo4j 3.5 image:
    sudo docker run --rm -v /path/to/your/3.5/data:/data neo4j:3.5 neo4j-admin dump --database=graph.db --to=/data/neo4j_migration_dump.dump
    
    Replace /path/to/your/3.5/data with the actual path to your 3.5 data directory on the source server.

Step 2: Transfer the Dump to the Target Server

Use scp or your preferred file transfer tool to send the dump file:

scp /path/to/your/3.5/data/neo4j_migration_dump.dump your-user@target-server-ip:/path/to/target/dump/

Step 3: Load the Dump into Neo4j 4.0

  1. On the target server, make sure no Neo4j 4.0 container is running.
  2. Load the dump into the default 4.0 database (neo4j):
    sudo docker run --rm -v /path/to/your/4.0/data:/data neo4j:4.0 neo4j-admin load --database=neo4j --from=/data/neo4j_migration_dump.dump --force
    
    The --force flag overwrites the default empty neo4j database.

Step 4: Start the Neo4j 4.0 Container Correctly

Fix the port mapping for Bolt and ensure auth is disabled:

sudo docker run --name vis-neo4j4 --restart unless-stopped --log-opt max-size=50m --log-opt max-file=10 \
-p 3001:7474 -p 3002:7473 -p 3003:7687 \
-d -v /path/to/your/4.0/data:/data -v /path/to/your/4.0/conf:/conf -v /path/to/your/4.0/logs:/logs \
--env NEO4J_AUTH=none neo4j:4.0

Note: We mapped port 3003 to 7687 (Bolt’s default port) to fix your WebSocket error.

2. Cypher Export & Import (Good for Small/Medium Datasets)

The method you referenced works well if you need to modify data during migration, or have a smaller dataset. Here’s how to implement it:

Step 1: Prepare the Source 3.5.x Server

  1. Start your 3.5 container and install the APOC plugin (required for bulk export). Download the compatible APOC version for Neo4j 3.5, place it in your plugins directory, and update neo4j.conf to allow unrestricted APOC procedures:
    dbms.security.procedures.unrestricted=apoc.*
    
  2. Restart the container, then open the Neo4j browser (or use cypher-shell) and run this command to export all data to a Cypher file:
    CALL apoc.export.cypher.all("all_neo4j_data.cypher", {format: "cypher", useOptimizations: {type: "UNWIND_BATCH", unwindBatchSize: 1000}})
    
  3. Copy the all_neo4j_data.cypher file from your data directory to the target server.

Step 2: Import into Neo4j 4.0

  1. Start your 4.0 container with NEO4J_AUTH=none (as in the dump/load method).
  2. Install the compatible APOC version for Neo4j 4.0 if needed, or use cypher-shell to run the import script:
    sudo docker exec -it vis-neo4j4 cypher-shell -u neo4j -p "" -f /path/to/all_neo4j_data.cypher
    
Final Notes
  • Always back up your data before starting any migration.
  • For large datasets, stick with the neo4j-admin dump/load method—it’s faster and avoids potential Cypher import errors.
  • If you still run into auth issues after migration, check your neo4j.conf file to ensure dbms.security.auth_enabled=false is set (since you’re using NEO4J_AUTH=none).

内容的提问来源于stack exchange,提问作者canbax

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:10:46