需求:获取redis指定的实例中所有的key的名字。
千万不要使⽤keys *,可以使⽤scan命令的递归⽅式获取。
以下给出⾃⼰写的脚本,经过测试效果还可以。
db_ip=5.5.5.101db_port=6379
password=abc123cursor=0cnt=100
new_cursor=0
redis-cli -h $db_ip -p $db_port -a $password scan $cursor count $cnt > scan_tmp_resultnew_cursor=`sed -n '1p' scan_tmp_result`sed -n '2,$p' scan_tmp_result >> scan_result
while [ $cursor -ne $new_cursor ]do
redis-cli -h $db_ip -p $db_port -a $password scan $new_cursor count $cnt > scan_tmp_result new_cursor=`sed -n '1p' scan_tmp_result` sed -n '2,$p' scan_tmp_result >> scan_resultdone
rm -rf scan_tmp_result
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- yrrf.cn 版权所有 赣ICP备2024042794号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务