(https://github.com/sripathikrishnan/redis-rdb-tools)
Rdbtools是Redis的dump.rdb文件的解析器,主要功能有三个:
1)生成所有数据库和键中数据的内存报告;
2)将dump文件转换为JSON;
3)使用标准差异工具比较两个dump文件。
使用示例:(有效的命令有: json, diff, justkeys, justkeyvals and protocol.)
rdb --command json dump.rdb
rdb --command justkeyvals --key "user.*" dump.rdb
rdb -c json --type hash --key "a.*" dump.rdb
使用 -c memory 可以生成一个csv报告,描述了key的大致内存使用情况。 –byte C 和 –largest N 可以用于输出超过C字节的key,或前N个最大的key:
rdb -c memory dump.rdb --bytes 128 -f memory.csv
redis-memory-for-key -s 192.168.0.142 -p 6381 short_url
rdb --command diff zxw.rdb |sort > dump1.txt
rdb --command diff zxw.rdb |sort > dump2.txt
(https://github.com/happybits/redisimp)
RedisImp用来快速安全地从其他Redis主机导入数据,导入到运行中的Redis或cluster实例中
远程备份rdb文件命令:
/usr/local/redis4/bin/redis-cli -h 192.168.0.142 -p 6381 --rdb ./zxw.rdb
redisimp使用示例:
redisimp -s 127.0.0.1:6379 -d 127.0.0.1:6380
redisimp -s ./dump.rdb -d 127.0.0.1:6380
redisimp -s 192.168.0.142:6382 -d 192.168.0.142:6381 --pattern '/^short_url_/'
-b 不覆盖之前存在的key
redisimp -s 192.168.0.142:6382 -d 192.168.0.142:6381 --pattern '/^short_url_/'-b
Redis工具redis-rdb-tools和redisimp
原文:https://www.cnblogs.com/any-way/p/12358190.html