当前位置: 首页 > news >正文

【neo4j】跨版本升级数据库

由于使用neo4j版本较低,需要从neo4j-community-3.5.8升级到neo4j-community-5.26.0,但是直接通过dump保存文件,load加载到新版中,报错

所以使用逐步升级的方式。

3.5 -> 4.4 -> 5.26

一、 旧版本操作

  1. 导出文件
cd /opt/neo4j-community-3.5.8
bin/neo4j stop
./bin/neo4j-admin dump --database=graph.db --to=graph.db.dump
  1. 传输文件到中间版本所在的机器。

二、中间版本操作

  1. 解压4.4版本
tar zxvf neo4j-community-4.4.44-unix.tar.gz 
  1. 解压并配置环境变量
tar zxvf jdk-11.0.27_linux-x64_bin.tar.gz -C /root/neo4j-community-4.4.44/
# 编辑并保存
vi /etc/profile
export JAVA_HOME=/root/neo4j-community-4.4.44/jdk-11.0.27
export JRE_HOME=/root/neo4j-community-4.4.44/jdk-11.0.27
# source生效
source /etc/profile
  1. 启动并关闭neo4j
cd /root/neo4j-community-4.4.44
bin/neo4j start
bin/neo4j stop
  1. 导入load
    4.4版本的导入已经和3.x的不同,需要注意命令。
bin/neo4j-admin load --from=/root/graph.db.dump --database=graph.db --force

执行结束以后,会有一个WARN的提示,需要把dbms.allow_upgrade配置改为true,执行升级操作。

  1. 修改配置并启动
# 配置后保存
vi conf/neo4j.conf
# 修改库名为自己的数据库
initial.dbms.default_database=graph.db
dbms.allow_upgrade=true
# 启动
bin/neo4j start

等待库表自动升级后,服务启动。
在这里插入图片描述
在这里插入图片描述
6. 观察
在这里插入图片描述
7. 导出
4.4版本的导出命令已经和3.x的不同,需要注意命令。

# 停止neo4j服务
bin/neo4j stop
bin/neo4j-admin dump --database=graph.db --to=/root/out/
  1. 传输文件到中间版本所在的机器。

三、新版本操作

新版本已安装,安装步骤和操作库一样,不过jdk要求21.

  1. 停止服务
    cd /opt/neo4j-community-5.26.0/
    bin/neo4j stop
  2. 导入
# 执行导入命令
bin/neo4j-admin database load --from-path=/root/out/ --overwrite-destination=true graph.db  
# 根据提示执行migrate 操作
bin/neo4j-admin database migrate graph.db

报错:
2025-07-31 09:47:24.119+0000 ERROR [o.n.c.d. MigrateStoreCommand] Failed to migrate database ‘graph.db’: Migration will remove all BTREE indexes and constraints backed by BTREE indexes. To guard against unintentionally removing indexes or constraints, it is recommended for all BTREE indexes or constraints backed by BTREE indexes to have a valid replacement. Indexes can be replaced by RANGE, TEXT or POINT index and constraints can be replaced by constraints backed by RANGE index. Please drop your indexes and constraints or create replacements and retry the migration. The indexes and constraints without replacement are: [Index( id=1, name=‘index_7530a0f9’, type=‘BTREE’, schema=(:CI实例 {oneLevelId}), indexProvider=‘native-btree-1.0’ ), Index( id=3, name=‘index_5565c06f’, type=‘BTREE’, schema=(:CI目录 {type}), indexProvider=‘native-btree-1.0’ )] and []. Alternatively, you can use the option --force-btree-indexes-to-range to force all BTREE indexes or constraints backed by BTREE indexes to be replaced by RANGE equivalents. Be aware that RANGE indexes are not always the optimal replacement of BTREEs and performance may be affected while the new indexes are populated. See the Neo4j v5 migration guide online for more information.

根据提示新增–force-btree-indexes-to-range参数

bin/neo4j-admin database migrate graph.db --force-btree-indexes-to-range
  1. 修改配置并启动
# 配置后保存
vi conf/neo4j.conf
# 修改库名为自己的数据库
initial.dbms.default_database=graph.db
# 启动
bin/neo4j start
  1. 观察
    旧版本:
    在这里插入图片描述
    新版本:
    在这里插入图片描述
    参考:
    https://neo4j.ac.cn/docs/upgrade-migration-guide/current/version-4/migration/migrate-to-4.0/standalone/
http://www.lryc.cn/news/606524.html

相关文章:

  • 《Java 程序设计》第 14 章 - JavaFX 基础
  • MySQL 8.0 OCP 1Z0-908 题目解析(42)
  • 企业级部署 (基于tomcat与nginx)
  • Linux和shell
  • 【运维基础】Linux 文件系统基本管理
  • Side band ECC、Inline ECC、On-die ECC、Link ECC
  • chrome.storage 和 localStorage
  • Android 基础入门学习目录(持续更新)
  • kettle插件-kettle http client plus插件,轻松解决https接口无法调用文件流下载问题
  • 面试笔记【16:9区域问题】
  • SQL注入SQLi-LABS 靶场less25a-28a详细通关攻略
  • ESP32 外设驱动开发指南 (ESP-IDF框架)——GPIO篇:基础配置、外部中断与PWM(LEDC模块)应用
  • 机械学习--逻辑回归
  • 第1章:基础篇——第1节:基础操作与认识界面
  • Vercel 全面介绍与网站部署指南
  • 老旧远程控制管理模块(物联网设备)渗透实战:SNMP泄露+内核提权攻击链深度解析
  • Gold 序列
  • 7月31号打卡
  • nvm安装nodejs后提示No installations recognized
  • 爱普生002墨水与004墨水基本参数及支持机型
  • pyspark使用
  • 火焰图(Flame Graph)深度指南:CPU性能分析与瓶颈定位
  • STM32——HAL 库MDK工程创建
  • 计算机网络知识【推荐!!!】按照OSI七层模型梳理
  • 动手学习深度学习-深度学习知识大纲
  • Spring Boot + MinIO + KKFile:三步搭建企业级文件预览系统
  • SpringBoot3.x入门到精通系列:1.2 开发环境搭建
  • 前端核心技术Node.js(二)——path模块、HTTP与模块化
  • 2025年物联网新趋势:格行随身WiFi的模块化架构与低延迟优化
  • 代码随想录算法训练营第三十七天