Example : rdb --command json -k "user.*" /var/redis/6379/dump.rdb
positional arguments: -- 要处理的dump文件 dump_file RDB Dump file to process
optional arguments: -- 帮助 -h, --help show this help message and exit -- 要处理的命令,-c后的有效参数为:json, diff,justkeys, justkeyvals, memory,protocol -c CMD, --command CMD Command to execute. Valid commands are json, diff, justkeys, justkeyvals, memory and protocol -- 输出文件 -f FILE, --file FILE Output file -- 数据库号,可以提供多个数据库。如果未指定,则包括所有数据库。 -n DBS, --db DBS Database Number. Multiple databases can be provided. If not specified, all databases will be included. -- 要导出的key。这可以是一个正则表达式 -k KEYS, --key KEYS Keys to export. This can be a regular expression -- key不导出。这可以是一个正则表达式 -o NOT_KEYS, --not-key NOT_KEYS Keys Not to export. This can be a regular expression -- 解析的数据类型。可能的值为string,hash,set,sortedset,list。可以输入多种类型提供。如果未指定,则为所有数据类型 -t TYPES, --type TYPES Data types to include. Possible values are string, hash, set, sortedset, list. Multiple typees can be provided. If not specified, all data types will be returned -- 将key的内存输出限制为大于或等此值(以字节为单位) -b BYTES, --bytes BYTES Limit memory output to keys greater to or equal to this value (in bytes) -- 将内存按大小输出前N个key -l LARGEST, --largest LARGEST Limit memory output to only the top N keys (by size) -- 将字符串转义为编码:raw(默认),print,utf8或base64。 -e {raw,print,utf8,base64}, --escape {raw,print,utf8,base64} Escape strings to encoding: raw (default), print, utf8, or base64. -- 使用command protocol参数,从所有键中删除到期的key -x, --no-expire With protocol command, remove expiry from all keys -- 使用command protocol参数,将N秒添加到key的到期时间 -a N, --amend-expire N With protocol command, add N seconds to key expiry time
Options: -- 帮助 -h, --help show this help message and exit -- 服务地址,默认127.0.0.1 -s HOST, --server=HOST Redis Server hostname. Defaults to 127.0.0.1 -- 服务端口,默认6379 -p PORT, --port=PORT Redis Server port. Defaults to 6379 --服务密码 -a PASSWORD, --password=PASSWORD Password to use when connecting to the server -- 数据库号,默认0 -d DB, --db=DB Database number, defaults to 0
**3,redis-profiler –help: **
1 2 3 4 5 6 7 8 9 10 11 12 13
Usage: redis-profiler [options] /path/to/dump.rdb
Example 1 : redis-profiler -k "user.*" -k "friends.*" -f memoryreport.html /var/redis/6379/dump.rdb Example 2 : redis-profiler /var/redis/6379/dump.rdb
Options: -- 帮助 -h, --help show this help message and exit -- 输出 -f FILE, --file=FILE Output file -- 组合在一起的键。 多个正则表达式 -k KEYS, --key=KEYS Keys that should be grouped together. Multiple regexes can be provided
[{ "Citat":["B\u00e4ttre sent \u00e4n aldrig","Bra karl reder sig sj\u00e4lv","Man ska inte k\u00f6pa grisen i s\u00e4cken"], "bin_data":"\\xFE\u0000\u00e2\\xF2"}]
将dump文件解析为原始字节,并在标准输出上打印JSON:
1 2 3 4 5
> rdb -c json /var/redis/6379/dump.rdb --escape raw
[{ "Citat":["B\u00c3\u00a4ttre sent \u00c3\u00a4n aldrig","Bra karl reder sig sj\u00c3\u00a4lv","Man ska inte k\u00c3\u00b6pa grisen i s\u00c3\u00a4cken"], "bin_data":"\u00fe\u0000\u00c3\u00a2\u00f2"}]
生成内存报告:
使用-c memory 运行会生成CSV报告,其中包含该键使用的近似内存。 –bytes C 和 –largest N 可用于将输出限制为大于C字节的键或N个最大键。