迁移数据库
您可以使用 neo4j-admin database migrate
命令将 Neo4j 数据库从一种存储格式迁移到另一种存储格式,或迁移到相同格式的更高 MAJOR
版本。
存储格式定义了数据库数据在文件系统上的存储方式。
数据库的存储格式采用 MAJOR.MINOR
方案进行版本控制,独立于Neo4j 日历版本控制。升级到最新的 MINOR
格式版本是数据库启动时执行的自动操作。迁移到更高的 MAJOR
格式版本或另一种格式是使用 migrate
命令执行的手动操作。
新数据库的存储格式可以使用db.format
配置设置。
语法
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 在线迁移指南。新创建的索引将在迁移后首次数据库启动时在后台填充,用户应监控该过程的成功完成。
|
|||
|
显示此帮助消息并退出。 |
|||
|
neo4j-admin 可以用于各种数据结构和缓存以提高性能的最大内存。值可以是纯数字,例如 10000000,或 20G 表示 20 GB。它也可以指定为可用内存的百分比,例如 70%。 |
|
||
|
用于迁移过程的页面缓存大小。通常的规则是,值达到数据库大小的比例会提高性能。 |
|||
|
要将存储迁移到的格式名称。如果指定了格式,则目标数据库将迁移到指定格式的最新已知 |
|||
|
启用详细输出。 |
|||
示例
以下示例将 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