迁移数据库Aura 不支持
您可以使用 neo4j-admin database migrate 命令将 Neo4j 数据库从一种存储格式迁移到另一种格式,或者迁移到相同格式的更高 MAJOR 版本。
存储格式定义了数据库数据在文件系统上的存储方式。
数据库的存储格式使用 MAJOR.MINOR 方案进行版本控制,独立于 Neo4j 日历版本控制。升级到最新的 MINOR 格式版本是在数据库启动时执行的自动操作。迁移到更高的 MAJOR 格式版本或另一种格式是使用 migrate 命令执行的手动操作。
可以使用 db.format 配置设置来设置新数据库的存储格式。
下表显示了不同 Neo4j 存储格式之间支持的迁移路径。但是,standard 和 high_limit 存储格式从 Neo4j 5.23 开始被弃用,这意味着从该版本开始不建议迁移到这些格式。
存储格式 |
迁移路径 |
|||
至 |
至 |
至 |
至 |
|
|
不建议 |
不建议 |
||
|
不建议 |
|||
|
||||
|
不建议 |
|||
1. 自 Neo4j 5.22 起, block 格式是企业版的默认格式。
2. aligned 格式是社区版的默认格式。在 Neo4j 5.22 之前,它是企业版的默认格式。 | ||||
在从 block 格式迁移到 aligned 格式之前,您必须确保您的图数据适合 aligned 格式,因为 block 格式具有更高的限制。有关详细信息,请参阅 数据库内部原理与事务行为 → 存储格式。
语法
neo4j-admin database migrate 的语法如下
neo4j-admin database migrate [-h] [--expand-commands]
[--force-btree-indexes-to-range]
[--verbose] [--additional-config=<file>]
[--max-off-heap-memory=<size>] [--pagecache=<size>]
[--to-format=standard|high_limit|aligned|block] <database>
|
|
参数
| 参数 | 描述 |
|---|---|
|
要迁移的数据库名称。可以使用 * 和 ? 进行通配。请注意,* 和 ? 在某些 shell 中有特殊含义,可能需要进行转义或使用引号括起来。 |
选项
neo4j-admin database migrate 命令具有以下选项
| 选项 | 描述 | 默认 | ||
|---|---|---|---|---|
|
包含额外配置的配置文件。 |
|||
|
允许在配置值评估中进行命令扩展。 |
|||
|
这是一个特殊选项,用于自动将所有 BTREE 索引/约束转换为 RANGE 类型。请注意,RANGE 索引并不总是 BTREE 的最佳替代方案,并且在新索引填充期间性能可能会受到影响。有关更多信息,请参阅在线的 Neo4j v5 迁移指南。新创建的索引将在迁移后的首次数据库启动时在后台填充,用户应监控该过程是否成功完成。
|
|||
|
显示此帮助消息并退出。 |
|||
|
该命令可用于页面缓存和各种缓存数据结构以提高性能的最大内存。值可以是普通数字(例如 10000000)、单位大小(例如 20G 表示 20GB),或百分比(例如 70%,表示当前机器空闲内存的 70%)。 |
|
||
|
用于迁移过程的页面缓存大小。通常的规则是,值最高达到数据库大小时,性能会成比例提升。 |
|||
|
要将存储迁移到的格式名称。如果指定了格式,目标数据库将迁移到该指定格式的最新已知 |
|||
|
启用详细输出。 |
|||
5. 有关详细信息,请参阅 Neo4j Admin 和 Neo4j CLI → 配置。 | ||||
示例
以下示例将 movies 数据库迁移到 block 格式的最新已知 MAJOR 和 MINOR 版本组合
bin/neo4j-admin database migrate --to-format=block movies
2025-01-22 18:03:21.842+0000 INFO [c.n.c.d.EnterpriseMigrateStoreCommand] Starting migration for database 'movies'
2025-01-22 18:03:22.504+0000 INFO [o.n.k.i.s.StoreMigrator] 'record-aligned-1.1' has been identified as the current version of the store
2025-01-22 18:03:22.504+0000 INFO [o.n.k.i.s.StoreMigrator] 'block-block-1.1' has been identified as the target version of the store migration
2025-01-22 18:03:22.506+0000 INFO [o.n.k.i.s.StoreMigrator] Starting migration of database
2025-01-22 18:03:22.586+0000 INFO [o.n.k.i.s.StoreMigrator] Migrating Store files (1/1):
2025-01-22 18:03:22.588+0000 INFO [o.n.k.i.s.StoreMigrator] Store files
2025-01-22 18:03:23.270+0000 INFO [c.n.i.b.i.BlockBatchImporter] Import completed successfully, took 654ms.
2025-01-22 18:03:23.708+0000 INFO [o.n.k.i.s.StoreMigrator] 10% completed
2025-01-22 18:03:23.708+0000 INFO [o.n.k.i.s.StoreMigrator] 20% completed
2025-01-22 18:03:23.708+0000 INFO [o.n.k.i.s.StoreMigrator] 30% completed
2025-01-22 18:03:23.708+0000 INFO [o.n.k.i.s.StoreMigrator] 40% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 50% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 60% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 70% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 80% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 90% completed
2025-01-22 18:03:23.709+0000 INFO [o.n.k.i.s.StoreMigrator] 100% completed
2025-01-22 18:03:23.761+0000 INFO [o.n.k.i.s.StoreMigrator] Starting transaction logs migration.
2025-01-22 18:03:23.800+0000 INFO [o.n.k.i.s.StoreMigrator] Transaction logs migration completed.
2025-01-22 18:03:23.802+0000 INFO [o.n.k.i.s.StoreMigrator] Successfully finished migration of database, took 1s 296ms
2025-01-22 18:03:23.804+0000 INFO [c.n.c.d.EnterpriseMigrateStoreCommand] Database migration completed successfully