这也吓到我了.特别是,我在本地的一个小项目中使用了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 修改数据.所以这里有一个基本的大纲,但要根据你的情况进行修改.
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
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
试着从redis-stack-server
开始.你应该会回来的.
我们可以通过判断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
导出您的数据.
$ 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)以完成该操作,然后断开客户端并停止服务器.
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
Upgrade back to 7.2.0. For me, using Homebrew, that's just
brew upgrade redis-stack-server
.
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
现在,您可以发出SAVE
或BGSAVE
来生成新的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
所以...我想这没问题吧.:)