Redis 版本差异

2021/6/5 2:26:06

本文主要是介绍Redis 版本差异,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Redis 2.8 vs 5.0

release notes

  • 3.0
  • 3.2
  • 4.0
  • 5.0

non-backward compatible list

2.8 vs 3.0:

  • The log format was modified. The prefix of each line included the pid in the following format [1234]. Now instead it is 1234:? Where '?' is actually the role of the instance. M for master, S for slave, C if this process is a saving child (for RDB/AOF), and X for Sentinel.

    日志格式修改。每一行的前缀和 [1234] 格式的 pid,被修改为 1234:??为实例的角色:

    • M : 主节点
    • S : 从节点
    • C : 用于保存的子进程(用于RDB/AOF)
    • X : 哨兵进程
  • The default maxmemory policy in Redis 3.0 is no longer "volatile-lru" as it used to be in 2.8, but "noeviction". The policies behavior is the same (but LRU eviction is much more precise in 3.0), so only the default value changed. Just make sure to specify in your redis.conf what you mean.

    在 3.0 版本中默认的 maxmemory 策略不再是 volatile-lru,而是 noeviction。策略行为是相同的(但 LRU 逐出在 3.0 中更精确),所以只有默认值改变。只要确保在 redis.conf 中指定想要的策略。

3.0 vs 3.2

  • The default configuration file now binds to 127.0.0.1.

    默认配置文件现在绑定在 127.0.0.1.

  • Slaves try to no longer expose stale data about already expired keys.

    从节点尝试不再公开关于已过期密匙的过时数据。

  • The RDB format changed. Redis 3.2 is still able to read 3.0 (and all the past versions) files, but not the other way around.

    RDB 存储格式改变,3.2 版本可以正常读取 3.0 版本的文件,但是老版本不能读取新的文件。

  • Behavior on crash may be different. The crash log format changed and the memory test executed is now different.

    崩溃时的行为发生变化,崩溃日志格式改变,执行的内存测试也发生了变化。

3.2 vs 4.0

  • The Redis Cluster bus protocol of 4.0 is no longer compatible with Redis 3.2. This was needed in order to provide Docker / NAT compatibility to Redis Cluster. SO in order to upgrade a Redis Cluster to 4.0, a mass restart of all the instances is needed.

    4.0 版本为了兼容 Docker / NAT 修改了 Redis 的集群总线协议,并且不在兼容 3.2 版本。因此为了将 Redis Cluster 升到到 4.0 版本,需要大量的重启 Redis 实例。

  • Redis Cluster CLUSTER NODES output is now slightly different. Nodes addresses are now in the form host:port@bus-port instead of host:port.Clients should use CLUSTER SLOTS in order to fetch the cluster configuration however if they are still using CLUSTER NODES, they should be modified in order to ignore the @bus-port part.

    Redis ClusterCLUSTER NODES 输出格式改变。节点地址格式从 host:port 改为 host:port@bus-port。客户端应使用 CLUSTER SLOTS 来获取集群的配置。但如果仍使用 CLUSTER NODES 的话,应该手动修改来忽略 @bus-port

  • Writable slaves do not propagate writes to their sub-slaves, so writes to writable slaves remain just local.

    可写 slaves 不会将他们的写操作传播到 sub-slaves,因此对可写的 slaves 的写入仍然是本地的。

  • The RDB format changed. Redis 4.0 is still able to read 3.2 (and all the past versions) files, but not the other way around.

    RDB 存储格式改变,4.0 版本可以正常读取 3.2 以及更老版本的文件,但是旧版本不能读取新的文件。

  • Certain log formats and sentences are different in Redis 4.0.

    某些日志的格式和语句在 4.0 中是不同的。

  • Certain INFO fields, especially related to replication, are now different.

    某些 INFO 字段,特别是与复制相关的字段,现在是不同的。

  • GEODIST, GEOPOS and GEOHASH return values changed for non existing keys: Previously the return value was inconsistent between non existing key and non existing elements. Now the return is always like if the key contains no elements if the key does not exist. So, for instance, "GEOHASH non_existing_key A B C" now returns an array of 3 NULL values as it should. In general this change should not break compatibility with the past since in the past two different forms were provided by the server and the new behavior is one of the two.

    对于 GEODISTGEOPOSGEOHASH 对于不存在的键的返回值被修改:在之前,不存在键与不存在元素的返回值是不一致的。现在返回值总是像 key contains no elementskey does not exist 这样。所以像 GEOHASH non_existing_key A B C 现在会返回一个包含 3 个 NULL 的数组。

  • The SLOWLOG command entires contain additional two fields: the client address and name. This is documented in the SLOWLOG command online documentation.

    SLOWLOG 命令包含另外俩个字段:addressname,在 SLOWLOG 在线文档有说明。

4.0 vs 5.0

  • redis-cli now implements the cluster management tool. We still ship the old redis-trib, but new fixes will be implemented only in redis-cli. See redis-cli --cluster help for more info.

    redis-cli 现在实现了集群管理工具,仍然发布旧的 redis-trib,但是新的修复只会再 redis-cli 中实现。详情请看 redis-cli --cluster help

  • The RDB format changed. Redis 5.0 is still able to read 4.0 (and all the past versions) files, but not the other way around.

    RDB 存储格式改变,5.0 版本可以正常读取 4.0 以及更老版本的文件,但是旧版本不能读取新的文件。

  • Certain log formats and sentences are different in Redis 5.0.

    某些日志的格式和语句在 5.0 中是不同的。

  • Now by default maxmemory is ignored by slaves, and used only once a slave is promoted to master. It means that in setups where you want slaves to enforce maxmemory in an independent way from the master (that will anyway stream the key eviction DEL commands), you should active this feature manually and make sure you understand that it breaks consistency if writes are not always idempotent. TLDR: the new behavior is much better for 99.999% of use cases, revert it if you really know what you are doing.

    现在默认情况下 maxmemoryslaves 忽略,并且只在 slaves 被升级为 master 时使用。者意味着如果希望 slaves 以独立于 master 的方式强制执行 maxmemory 的设置中(无论如何都会流式传输关键的驱逐 DEL 命令),并且应该手动激活这个特性,且确保已经了解,如果写操作不是幂等的话,这会破坏一致性。TLDR:对于 99.999 %的情况,新的行为将要好的多,请在还原它之前,确认是否十分必要。

  • Scripts are only replicated by their effects and not by sending EVAL/EVALSHA to slaves or the AOF log itself. This is much better in the general case and in the future we want to totally remove the other possiblity of propagating scripts the old way (as EVAL). However you can still turn this back to the default via the non-documented (if not here) Redis configuration directive "lua-replicate-commands yes" or "DEBUG lua-always-replicate-commands 0". However note that Redis 6 may completely remove such feature.

    脚本仅通过它们的效果复制,而不是通过将 EVAL/EVALSHA 发送到从属或 AOF 日志本身来复制。 这在一般情况下要好得多,将来我们希望完全消除以旧方式传播脚本的其他可能性(如 EVAL)。 但是,您仍然可以通过未记录的(如果不在此处)Redis 配置指令 lua-replicate-commands yesDEBUG lua-always-replicate-commands 0 将其恢复为默认值。 但是请注意,Redis 6 可能会完全删除此类功能

  • Because of the above change related to scripts replication, certain Redis commands that in Redis 4 had their result ordered lexicographically before being passed to Lua via the return value of redis.call(), now have a behavior more similar to calling the commands directly from a normal client. For instance the ordering of elements returned by SMEMBERS or SDIFF is now undetermined in Lua, exactly as it is by default when calling the commands from a non-scripting context.

    由于上一条更改与脚本复制有关,在 Redis 4 中的某些命令在通过 redis.call() 将返回值传递给 Lua 之前,会按字典顺序对其结果进行了排序,而现在的行为更类似于直接从一个普通的客户端调用命令。例如,由 SMEMBERSSDIFF 返回的元素的顺序现在在 Lua 中是不确定的,这与从非脚本上下文调用命令时的默认设置完全相同。



这篇关于Redis 版本差异的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程