redis从节点加入集群后key数量与主节点不一致


背景
最近新部署一台redis从节点服务器时,检查发现key数量远比主节点要少得多,而其他从节点的key和主节点差不多。

原因
If you use keys with limited time to live (Redis expires) this is normal behavior. This is what happens:

  • The master generates an RDB file on the first synchronization with the slave.
  • The RDB file will not include keys already expired in the master, but that are still in memory.
  • However these keys are still in the memory of the Redis master, even if logically expired. They’ll not be considered as existing, but the memory will be reclaimed later, both incrementally and explicitly on access. However while these keys are not logical part of the dataset, they are advertised in INFO output and by the DBSIZE command.
  • When the slave reads the RDB file generated by the master, this set of keys will not be loaded.

As a result of this, it is common for users with many keys with an expire set to see less keys in the slaves, because of this artifact, but there is no actual logical difference in the instances content.

原创文章,作者:wdmbts,如若转载,请注明出处:https://blog.ytso.com/274471.html

(0)
上一篇 2022年7月15日
下一篇 2022年7月15日

相关推荐

发表回复

登录后才能评论