redis源码剖析(十四)—— dump.rdb文件分析工具
生活随笔
收集整理的這篇文章主要介紹了
redis源码剖析(十四)—— dump.rdb文件分析工具
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
分析rdb文件的工具
安裝
git clone https://github.com/sripathikrishnan/redis-rdb-tools.git sudo pip install --upgrade pip sudo pip install python-lzf分析以n開頭的key
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 0000040json格式解析并輸出
[kou@python ~]$ rdb --command json /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdb [{ "name":"hodge"}]指定數據庫,類型,格式,key
rdb -c json --db 2 --type hash --key "a.*"生成內存報告
[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,查找單鍵使用的內存
redis-memory-for-key -s localhost -p 6379 -a mypassword person:1RDB文件轉換為Redis協議流protocol
rdb --c protocol您可以將輸出通過管道傳輸到netcat并重新導入數據的子集。例如,如果要將數據分片到兩個Redis實例中,則可以使用–key標志選擇數據的子集,然后將輸出傳遞給正在運行的Redis實例以加載該數據。閱讀Redis Mass Insert以獲得更多信息。
當輸出打印協議時,該–escape選項可與一起使用printable或utf8避免使用不可打印/控制字符。
比較RDB文件
> 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分析結果
[kou@python ~]$ rdb --command justkeyvals --key "n*" /home/kou/redis_tar/redis-3.0-annotated/src/dump.rdbname hodge總結
以上是生活随笔為你收集整理的redis源码剖析(十四)—— dump.rdb文件分析工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL为什么要用数字做自增主键?
- 下一篇: 创世神话镶嵌宝石去哪里镶嵌?