Redis的常见命令

/data/anaconda2/bin/rdb --command json -f 1.csv /tmp/dump.rdb
  • 分析key大小
Cd /data/bak/scripts/redis/redis-rdb-tools
redis-memory-for-key -p 6379 -a xxx key
  • redis 5.0 集群批量操作命令
# redis 5.0以上可以通过如下命令向整个集群执行命令:
redis-cli --cluster call <ip>:<port> command -a xxx
# 查看dbsize,已经全部清零。
redis-cli --cluster call <ip>:<port> command -a xxx
  • 哨兵剔除一个slave
1、先 把slave kill
2、在哨兵节点上执行
redis-cli -h 10.2.52.162 -p 26388 sentinel reset redis19
redis-cli -h 10.2.53.160 -p 26388 sentinel reset redis19
redis-cli -h 10.2.59.16 -p 26388 sentinel reset redis19
  • 批量删除
./redis-cli -h 127.0.0.1 -p 6379 -a password --scan --pattern 'key-*' | xargs ./redis-cli -h 127.0.0.1 -p 6379 -a password del {}
  • 集群删除handshake节点
#!/bin/bash

nodes_addrs=$(redis-cli -a $3 -h $1 -p $2 cluster nodes|grep -v handshake| awk '{print $2}')
echo $nodes_addrs
for addr in ${nodes_addrs[@]}; do
host=${addr%:*}
port=${addr#*:}
del_nodeids=$(redis-cli -a $3 -h $host -p $port cluster nodes|grep -E 'handshake|fail'| awk '{print $1}')
for nodeid in ${del_nodeids[@]}; do
echo $host $port $nodeid
redis-cli -a $3 -h $host -p $port cluster forget $nodeid
done
done
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容