Rdb file analysis tool
installation
git clone https://github.com/sripathikrishnan/redis-rdb-tools.git
sudo pip install --upgrade pip
sudo pip install python-lzf
Analysis of key beginning with n
rdb --command justkeyvals --key "n*" /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb
[kou@python ~]$ od -c /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb
0000000 R E D I S 0 0 0 6 376 \0 \0 004 n a m
0000020 e 005 h o d g e 377 004 | 313 025 = G % 310
0000040
json format and outputs the parsed
[kou@python ~]$ rdb --command json /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb
[{
"name":"hodge"}]
Specify the database, type, format, key
rdb -c json --db 2 --type hash --key "a.*"
Report generation memory
[kou@python ~]$ rdb -c memory /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb
database,type,key,size_in_bytes,encoding,num_elements,len_largest_element,expiry
0,string,name,56,string,5,5,
Find the memory used by a single bond
redis-memory-for-key -s localhost -p 6379 -a mypassword person:1
RDB file into Redis protocol stream protocol
rdb --c protocol
You can export pipe to the netcat and reintroduced into a subset of data. For example, if the data is to be fragmented into two Redis instance, can be used to select a subset -key flag data, and then passes the output to the running instance Redis to load the data. Read Redis Mass Insert for more information.
When the output printing protocol, the option may be used -escape with printable or non-printable utf8 avoid the use / control character.
Compare RDB file
> rdb --command diff /var/redis/6379/dump1.rdb | sort > dump1.txt
> rdb --command diff /var/redis/6379/dump2.rdb | sort > dump2.txt
然后,运行您喜欢的差异程序
> kdiff3 dump1.txt dump2.txt
Results
[kou@python ~]$ rdb --command justkeyvals --key "n*" /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb
name hodge