当我try 从使用以前版本的RS创建的RDB文件加载带有Redis Stack 7.2的Redis数据库时,它没有加载,并打印以下错误:

* Loading RDB produced by version 6.2.13
* RDB age 848231 seconds
* RDB memory usage when created 1.50 Mb
# The RDB file contains AUX module data I can't load: no matching module 'graphdata'

这很可能是因为Redis逐步淘汰了RedisGraph,article about that次提到RG"从7.2版开始不再是Redis Stack的一部分".

我认为一切都很好,因为我从来没有使用过任何与图形相关的功能.然而,RDB文件似乎引用了没有任何与其相关的条目的RedisGraph模块despite,我认为这是没有逻辑原因的.

如果用户需要RDB持久化,那么让他们的Redis Stack版本保持最新的预期方式是什么?似乎7.2版不会接受任何以前版本的任何RDB文件.

有没有一种简单的方法可以移植它并继续使用这个文件?

推荐答案

这也吓到我了.特别是,我在本地的一个小项目中使用了redis-STACK,一周前(commit),Homebrew CASK从redis-STACK-SERVER 6.2.6-v9更新到了7.2.0.

我们不能加载我们的RDB的原因,即使我们从来没有使用RedisGraph,是因为加载模块将元数据保存到RDB的AUX字段(自定义数据类型?)中,而新版本的Redis在没有模块的情况下无法读取这些元数据.这也不允许您在运行时使用MODULE UNLOAD卸载模块.

这是怪人,他们正在讨论修复拉取请求#11056和现在的#11374.

无论如何,挽救数据的一个基本策略是在以前的工作配置中加载它,以不包括对旧模块的有问题的引用的方式将其导出为纯文本AOF日志(log),再次升级到7.2.0-删除了有问题的RDB文件-并加载到我们生成的AOF中.SAVE,您就有了一个新的RDB.

我在本地处理大约5MB的数据,没有生产实例可用.此方法假定除了您之外没有任何客户端连接并try 修改数据.所以这里有一个基本的大纲,但要根据你的情况进行修改.

  1. Make a backup of your RDB file before you do anything else, so you have a safety net if these steps don't work precisely on the first try. For me, with Homebrew, I just did e.g.
    cp /opt/homebrew/var/db/redis-stack/dump.rdb ~/Desktop/dump.orig.rdb

  2. Downgrade back to 6.2.x. Again, this will depend on your OS and configuration. For Homebrew, you can attempt to downgrade a cask by downloading the version of the formula you want and installing it from disk. I downloaded the previous version of the cask formula for redis-stack-server.rb, then
    brew install --cask ~/Downloads/redis-stack-server.rb

  3. 试着从redis-stack-server开始.你应该会回来的.

  4. 我们可以通过判断rdb文件btw来查看这些对模块的有问题的引用:

    $ redis-check-rdb /opt/homebrew/var/db/redis-stack/dump.rdb
    [offset 0] Checking RDB file dump.rdb
    [offset 27] AUX FIELD redis-ver = '6.2.13'
    [offset 41] AUX FIELD redis-bits = '64'
    [offset 53] AUX FIELD ctime = '1692437664'
    [offset 68] AUX FIELD used-mem = '5479248'
    [offset 84] AUX FIELD aof-preamble = '0'
    [offset 96] MODULE AUX for: graphdata
    [offset 111] MODULE AUX for: scdtype00
    [offset 124] MODULE AUX for: ft_index0
    [offset 129] Selecting DB ID 2
    [offset 2666081] MODULE AUX for: graphdata
    [offset 2666096] MODULE AUX for: scdtype00
    [offset 2666108] Checksum OK
    [offset 2666108] \o/ RDB looks OK! \o/
    [info] 4713 keys read
    [info] 0 expires
    [info] 0 already expired
    
  5. 导出您的数据.

    $ redis-cli
    127.0.0.1:6379> CONFIG SET aof-use-rdb-preamble no
    OK
    127.0.0.1:6379> CONFIG SET appendonly yes
    OK
    127.0.0.1:6379> BGREWRITEAOF
    Background append only file rewriting started
    

    判断服务器日志(log)以完成该操作,然后断开客户端并停止服务器.

  6. Delete the active RDB file.
    rm /opt/homebrew/var/db/redis-stack/dump.rdb
    There should be a larger appendonly.aof alongside it now. You can move that somewhere safe.
    mv /opt/homebrew/var/db/redis-stack/appendonly.aof ~/Desktop/appendonly.6.2.aof

  7. Upgrade back to 7.2.0. For me, using Homebrew, that's just
    brew upgrade redis-stack-server.

  8. Finally, start 7.2.0 without any data (since we deleted/moved it all away)
    redis-stack-server
    And replay the log:
    redis-cli --pipe < ~/Desktop/appendonly.6.2.aof

现在,您可以发出SAVEBGSAVE来生成新的RDB文件.


我希望这能帮到你!我已经有大约十年没有负责生产Redis实例了,我只是 Select Redis Stack作为JSON支持,因为我正在缓存来自JSON API的所有响应,并且认为它可能会很方便.但模块互操作性的这个问题让我想知道,我现在是否应该只使用普通的Redis.

顺便说一句,Redis 7.2.0在启动时对我这样说:

71950:M 21 Aug 2023 04:07:05.933 * <redisgears_2> Created new data type 'GearsType'
71950:M 21 Aug 2023 04:07:05.934 * <redisgears_2> Detected redis oss
71950:M 21 Aug 2023 04:07:05.934 # <redisgears_2> could not initialize RedisAI_InitError

71950:M 21 Aug 2023 04:07:05.934 * <redisgears_2> Failed loading RedisAI API.
71950:M 21 Aug 2023 04:07:05.934 * <redisgears_2> RedisGears v2.0.11, sha='0aa55951836750ceabd9733decb200f8a5e7bac3', build_type='release', built_for='Macos-mac os12.6.3.arm64v8'.
71950:M 21 Aug 2023 04:07:05.935 * <redisgears_2> Registered backend: js.
71950:M 21 Aug 2023 04:07:05.935 * Module 'redisgears_2' loaded from /opt/homebrew/Caskroom/redis-stack-server/7.2.0-v0/lib/redisgears.so

所以...我想这没问题吧.:)

Database相关问答推荐

Sequel Pro / MAMP 在哪里存储本地数据库?

有没有办法使用 JPA 注释和 Hibernate 动态 Select @GeneratedValue 策略?

函数到关系映射比对象到关系更容易吗?

MySQL 语法 LIMIT x, y 的 T-SQL 类似的功能是什么?

多列索引的顺序

如何更改 Heroku 中的列类型?

如何将新架构添加到现有的 Visual Studio 数据库项目?

try 重新打开一个已经关闭的对象:SQLiteDatabase

如何禁用 Django 查询缓存?

ER图中的一对多关系

将 XML 存储在数据库中是否不好?

我可以在没有数据源的情况下配置 Grails 吗?

mysql,dump,数据库restore恢复

Django中的Atomic原子操作?

应用程序用户应该是数据库用户吗?

PostgreSQL 字符变长限制

如何用 SQL 思考?

如何在 SSIS 中插入新记录之前清空我的目标表?

QSqlDatabase & QSqlQuery 的正确方法是什么?

如何处理数据库中用户的身份验证/授权?