一、判断阿里云 redis cluster,的key属于那个分片。
阿里云特有的命令info key 可以查看key属于那个slot,那个分片
 命令行查看:
xxxx:6379> info key  xxxx_compressed_xxx
slot:4941 node_index:9
xxxx:6379> cluster keyslot xxxx_compressed_xxx
(integer) 4941
xxxx:6379:6379> 
 
也可以在dms查看。
 
 如果实例是安全协同模式,dms安全规则需要增加:
 

// 文档:https://help.aliyun.com/document_detail/131131.html
if
  @fac.cmd_type in ['INFO']
then
  @act.allow_execute
elseif @fac.is_read
then
  @act.reject_execute '该命令被 "允许执行Hash读命令(白名单集合)"安全规则 禁用,需要使用请联系管理员修改模板或走工单流程'
end
 
二、原生 redis cluster查看方法
cluster nodes 或者 cluster slots 都可以查看所有分片对应slot的范围。
cluster keyslot keyname 命令可以查看某个key 属于那个slot。
 以上两种命令结合可以判断key属于那个分片
命令说明
 cluster nodes
 https://cloud.tencent.com/developer/section/1374002
 cluster slots
 https://cloud.tencent.com/developer/section/1374009
 cluster keyslot
 https://cloud.tencent.com/developer/section/1374000









![[2023]Java后台开发工程师笔试题](https://img-blog.csdnimg.cn/img_convert/23c7b0fd05f139e0f6dee08a1790418f.png)









