redis-rdb-tools安裝部署及使用

來源:互聯網
上載者:User

標籤:number   local   mos   ash   記憶體分析   last   ipa   模式   too   

redis記憶體分析工具redis-rdb-tools安裝部署
項目地址:https://github.com/sripathikrishnan/redis-rdb-tools

安裝部署
安裝Python2.7下載redis-rdb-toolsgit clone https://github.com/sripathikrishnan/redis-rdb-tools.git安裝redis-rdb-toolspip2.7 install  python-lzfcd redis-rdb-toolspython2.7 setup.py install
常見用法:
# 以json格式輸出> rdb --command json /var/redis/6379/dump.rdb# 以json格式輸出,模糊尋找> rdb --command justkeyvals --key "user.*" /var/redis/6379/dump.rdbuser003 fname Ron,sname Bumquist,user001 fname Raoul,sname Duke,user002 fname Gonzo,sname Dr,user_list user003,user002,user001# 尋找確定鍵資訊> redis-memory-for-key -s localhost -p 6379 -a mypassword person:1Key             person:1Bytes               111Type                hashEncoding            ziplistNumber of Elements      2Length of Largest Element   8# rdb檔案解析並輸出為csv> rdb -c memory /var/redis/6379/dump.rdb --bytes 128 -f memory.csv> cat memory.csvdatabase,type,key,size_in_bytes,encoding,num_elements,len_largest_element0,list,lizards,241,quicklist,5,190,list,user_list,190,quicklist,3,72,hash,baloon,138,ziplist,3,112,list,armadillo,231,quicklist,5,202,hash,aroma,129,ziplist,3,11#  輸出top10的鍵資訊rdb -c memory  --largest=10  /app/redis/data/7000/dump.rdb
報錯及解決方案:

在redis-cluster模式下使使用者出現如下報錯,將地址改為該鍵對應的地址即可

[[email protected] python2.7]# redis-memory-for-key -s 172.16.2.53 -p 7000 KEYNAMETESTTraceback (most recent call last):  File "/usr/local/python2.7/bin/redis-memory-for-key", line 11, in <module>    load_entry_point(‘rdbtools==0.1.12‘, ‘console_scripts‘, ‘redis-memory-for-key‘)()  File "/usr/local/python2.7/lib/python2.7/site-packages/rdbtools-0.1.12-py2.7.egg/rdbtools/cli/redis_memory_for_key.py", line 43, in main    db=options.db, password=options.password)  File "/usr/local/python2.7/lib/python2.7/site-packages/rdbtools-0.1.12-py2.7.egg/rdbtools/cli/redis_memory_for_key.py", line 53, in print_memory_for_key    raw_dump = redis.execute_command(‘dump‘, key)  File "/usr/local/python2.7/lib/python2.7/site-packages/redis/client.py", line 668, in execute_command    return self.parse_response(connection, command_name, **options)  File "/usr/local/python2.7/lib/python2.7/site-packages/redis/client.py", line 680, in parse_response    response = connection.read_response()  File "/usr/local/python2.7/lib/python2.7/site-packages/redis/connection.py", line 629, in read_response    raise responseredis.exceptions.ResponseError: MOVED 16278 172.16.0.99:7000[[email protected] python2.7]# redis-memory-for-key -s 172.16.0.99 -p 7000 KEYNAMETESTKey             KEYNAMETESTBytes               933972.0Type                sortedsetEncoding            skiplistNumber of Elements      7658Length of Largest Element   8

注意事項:

1、整個rdb檔案的解析會導致CPU佔用嚴重,所以慎用!!!2、最好選擇單鍵查詢的方式,不太消耗資源3、如果需要解析某個rdb檔案,最好使用它的備份檔案,或者將檔案匯出到本地或者測試機進行解析

redis-rdb-tools安裝部署及使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.