需求:之前写的脚本(https://www.cnblogs.com/imdba/p/10197192.html),每个node上都只有一个slot段范围的情况,本次通过测试,实现了,任意段范围的获取方法。

key_slot=`redis-cli -h 5.5.5.101 -p  -a abc123 -c cluster keyslot $`

node_slot=`sh get_slot_range2.sh 5.5.5.101 `

find_tag=
for i in $node_slot
do
node_ip=`echo $i | awk -F '[|]' '{print $1}'`
range_count=`echo $i | awk -F '[|]' '{print NF}'`
for (( rc=;rc<=$range_count;rc++ ))
do
start_slot=`echo $i | awk -F '[|]' '{print $'$rc'}' | awk -F '[-]' '{print $1}'`
end_slot=`echo $i | awk -F '[|]' '{print $'$rc'}' | awk -F '[-]' '{print $2}'`
for(( j=$start_slot;j<=$end_slot;j++ ))
do
if [[ $j == $key_slot ]];then
echo $node_ip
find_tag=1
fi
done
if [[ $find_tag == 1 ]];then
break
fi
done
done 说明:get_slot_range2.sh,具体可以参考https://www.cnblogs.com/imdba/p/10115358.html
redis-cli -h $ -p $ -c cluster nodes |grep master > ./all
cat all | awk '{print $2}' | awk '$1 ~/@.*/{gsub("@.*","",$1);print $0}' >
cat all | awk -F " " '{for (i=9;i<=NF;i++)printf("%s", "|"$i);print ""}' >
paste -d "|" > 2_9.txt
cat 2_9.txt
key_slot=`redis-cli -h 5.5.5.101 -p  -a abc123 -c cluster keyslot $`

node_slot=`sh get_slot_range2.sh 5.5.5.101 `

find_tag=
for i in $node_slot
do
node_ip=`echo $i | awk -F '[|]' '{print $1}'`
range_count=`echo $i | awk -F '[|]' '{print NF}'`
for (( rc=;rc<=$range_count;rc++ ))
do
start_slot=`echo $i | awk -F '[|]' '{print $'$rc'}' | awk -F '[-]' '{print $1}'`
end_slot=`echo $i | awk -F '[|]' '{print $'$rc'}' | awk -F '[-]' '{print $2}'`
[ $key_slot -gt $start_slot -a $key_slot -le $end_slot ] && echo $node_ip
done
done #感谢浩神,上面标红的可以直接用一个判断获取,不需要循环。

最新文章

  1. XPatchLib 对象增量数据序列化及反序列化器 For .Net
  2. JavaScript基础整理(2)
  3. Union-Find Algorithm
  4. Java - Collection 高效的找出两个List中的不同元素
  5. atitit.hbnt orm db 新新增更新最佳实践o99
  6. 简单的freemarker解析测试
  7. poj1182(食物链)续
  8. STM32中的位带(bit-band)操作
  9. codevs1099字串变换(Bfs)
  10. linux经常使用解压缩命令
  11. 自然饱和度(Vibrance)算法的模拟实现及其SSE优化(附源码,可作为SSE图像入门,Vibrance算法也可用于简单的肤色调整)。
  12. deviceMotion.userAcceleration加速度方向
  13. Tars 负载均衡
  14. SpringSecurity如何在代码中获取认证用户信息
  15. :app:compileDebugJavaWithJavac
  16. shell 文件描述符
  17. 20155207 EXP7 网络欺诈技术防范
  18. js中parentNode,parentElement,childNodes,children
  19. Python MySQLdb模块连接操作mysql数据库实例_python
  20. c#实现图片二值化例子(黑白效果)

热门文章

  1. HDU_2579_bfs
  2. 小白学 Python 数据分析(4):Pandas (三)数据结构 DataFrame
  3. SpringCloud五大神兽之Eureka
  4. D语言-随机数游戏
  5. 一个工程中cpp文件的编译顺序
  6. linux 删除文件 磁盘空间未释放
  7. vue-cli搭建vue项目(单页面应用)
  8. sublime text3 安装详解+前端插件
  9. a链接四种伪类状态切换实现人机交互
  10. window 下如何恢复被删除的mysql root账户及密码(mysql 8.0.17)