您现在的位置是:热点 >>正文
一日一技:可视化分析 Redis Key 资源占用情况
热点198233人已围观
简介...
Redis 在日常的开发中,会积累大量的 Key,占用不少内存空间。有时候,我们想知道当前 Redis 里面有多少个 Key,是哪个 Key 占用了最大的内存。
但是,我们知道,由于 Redis 是一日单线程数据库,所以在线上环境是绝对禁止使用keys *这种命令的,因为它会花费很长时间扫描所有的 Key,在这个过程中,Redis 会卡死,无法处理其他的读写操作。
那么,我们应该怎么知道当前有多少个一技 Key 呢?有同学说可以使用scan命令。但这个命令一方面是需要写程序来迭代,另一方面是它给出的结果可能是不准确的。
也有同学会说,可以使用info keyspace命令,运行效果如下图所示:
确实可以看到:可有多少个 Key。不过另一个问题是,怎么知道哪个 Key 占用的内存空间最大?
还有时候,Redis 里面可能有几万十几万个 Key,里面有些 Key 是可以删掉的。但是由于我们不能使用keys命令查看当前有哪视化些 Key,所以不知道这些可以删掉的 Key 竟然还在。
实际上,这些问题,我们使用一个叫做RDR[1]的工具,都可以解决。在 RDR 的 Github 上,可以找到对应系统的可执行文件。我们以 Linux 版本为例来分析进行说明。Linux 版本的可执行文件地址为:https://github.com/xueqiu/rdr/releases/download/v0.0.1/rdr-linux,下载以后,赋予可 R执行权限:
cd ~ wget https://github.com/xueqiu/rdr/releases/download/v0.0.1/rdr-linux&nbedsp;chmod +x rdr-linux
接下来,我们需要找到dump.rdb文件。
Redis 默认开启了RDB方式的持久化储存。满足一定条件时,Redis 会把内存中is的数据存放到硬盘中,防止由于突然断电导致数据丢失。默认情况下,RDB 文件在/var/lib/redis/dump.rdb,这个文件只有 root 用户可以读取。
如果你现在不是 root 用户,那么你可以把它 K复制出来,修改成当前用户,我的 Linux 系统当前用户名叫做 kingname,所在的用户组也叫 kingname,所以可以执行如下 shell 命令:
cd ~ sudo eycp /var/lib/redis/dump.rdb ./ sudo chown kingname:kinganme dump.r 资db
修改了用户以后,现在我们让 RDR 来读取这个RDB 文件:
./rdr-linux show -p 8766 dump.rdb
运行效果如源占下图所示:
现在,打开浏览器,打开http://IP:8766,就可以看到当前 Redis 的各个 Key 的统计信息:
不仅可以看到Redis 有哪些 Key,还能看到每个 Key 里面有多少元素,大小是多少。
而用情且由于是分析的 RDB 文件,所以也完全不需要担心对线上数据造成任何影响。
有了这个工具以后,要找出占用空间最大的 Key,就非常简单了。
参考资料[1]RDR: https://github.com/xu一日eqiu/rdr
Tags:
相关文章
阿里通义万相预告Wan 2.2-S2V模型:解锁AI视频音频同步生成
热点近日,阿里通义万相团队在社交媒体平台X上发布预告,即将推出其最新的AI模型—— Wan2.2-S2V 。这款新模型的核心亮点在于,它不仅具备强大的视频生成能力,还能同步生成音频,实现了 视频与音频的深...
【热点】
阅读更多玉米直男什么梗
热点玉米为什么被叫直男?玉米被叫直男,说话比较直接,给不经过大脑玉米被叫直男,说话比较直接,给不经过大脑天王老子来了什么梗?一个女友测试男友是不是直男的梗。今天就是天王老子来了他也是个玉米,不然是个啥?谁...
【热点】
阅读更多炒北瓜怎么做好吃
热点炒北瓜的做法,炒北瓜做法是什么好吃,炒北瓜的家常做法是什...3.将洗净的北瓜切成小片以后待用。4.油烧热后加入辣椒、葱、蒜爆香。5.将葱、蒜的香味炒出来以后加入洗干净的北瓜片,大火炒制。。6.北瓜片...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.zutari.com/search/谷歌站群软件【tg:seogoogle987】,dhE
- https://www.stormberg.com/no/search?q=谷歌站群软件【tg:seogoogle987】,RBb
- https://www.shacknews.com/editorial-search?q=谷歌站群软件【tg:seogoogle987】,QyX
- https://www.metalmensales.com/?action=QUERY&s=谷歌站群软件【tg:seogoogle987】,rxZ
- https://www.lezhin.com/ko/tags/谷歌站群软件【tg:seogoogle987】,sPO
- https://www.wattpad.com/search/谷歌站群软件【tg:seogoogle987】GFg
- https://www.olx.ba/pretraga?trazilica=谷歌站群软件【tg:seogoogle987】,2D7
- https://www.pierreherme.com/catalogsearch/result/?q=谷歌站群软件【tg:seogoogle987】,CHz
- https://www.teamlab.art/pt/?submit=谷歌站群软件【tg:seogoogle987】,ucf
- https://www.voices.com/talents/search?keywords=谷歌站群软件【tg:seogoogle987】,gJM
- https://www.yli.ro/catalogsearch/result/?q=谷歌站群软件【tg:seogoogle987】,WR0
- https://www.msrenewal.com/search/谷歌站群软件【tg:seogoogle987】,Onj
- https://www.terramania.nl/catalogsearch/result/index/?q=谷歌站群软件【tg:seogoogle987】,CA1
- https://www.ncetm.org.uk/search?action=CHECK&q=谷歌站群软件【tg:seogoogle987】,oHM
- https://www.kaskus.co.id/search?q=谷歌站群软件【tg:seogoogle987】,HJL
- https://www.teamlab.art/ko/?submit=谷歌站群软件【tg:seogoogle987】,kvK
- https://www.duksung.ac.kr/search/front/Search.jsp?qt=谷歌站群软件【tg:seogoogle987】tHw
- https://www.laoairlines.com/?action=QUERY&s=谷歌站群软件【tg:seogoogle987】,2SX
- https://www.kuaikanmanhua.com/sou/谷歌站群软件【tg:seogoogle987】,JzS
- https://www.pearlstonecenter.org/search/谷歌站群软件【tg:seogoogle987】,qSt
- https://hsmoa.com/search?query=谷歌站群软件【tg:seogoogle987】2Ck
- https://www.totolink.vn/search/谷歌站群软件【tg:seogoogle987】,9dt
- https://www.livehindustan.com/tags/谷歌站群软件【tg:seogoogle987】,mrY
- https://www.krisinformation.se/en/search?q=谷歌站群软件【tg:seogoogle987】,XE5
- https://www.selfsufficientish.com/main/?s=谷歌站群软件【tg:seogoogle987】,PVJ
- https://www.merchbar.com/search?q=谷歌站群软件【tg:seogoogle987】,pZA
- https://www.localfootdoc.com/?s=谷歌站群软件【tg:seogoogle987】,vIn
- https://www.nctsn.org/search?cat=191&query=谷歌站群软件【tg:seogoogle987】,7fR
- https://www.rostaing.com/catalogsearch/result/?cat=22&q=谷歌站群软件【tg:seogoogle987】,OzQ
- https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=谷歌站群软件【tg:seogoogle987】,T5p
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌站群软件【tg:seogoogle987】k8z
- https://www.roblox.com/discover/?cat=107&Keyword=谷歌站群软件【tg:seogoogle987】,vhQ
- https://www.resilienz-akademie.com/?cat=71&s=谷歌站群软件【tg:seogoogle987】,To9
- https://www.woorden.org/spreekwoord.php?woord=谷歌站群软件【tg:seogoogle987】,wzH
- https://www.remit.co.jp/id/?s=谷歌站群软件【tg:seogoogle987】,L2r
- https://www.lneg.pt/?cat=140&s=谷歌站群软件【tg:seogoogle987】,Xpd
- https://www.pmindia.gov.in/en/?s=谷歌站群软件【tg:seogoogle987】,vJK
- https://www.sdcard.org/ja/?s=谷歌站群软件【tg:seogoogle987】,g8n
- https://www.wellbees.com/catalogsearch/result/?action=CHECK&q=谷歌站群软件【tg:seogoogle987】,esT
- https://www.partilerdunyasi.com/index.php?route=product/search&tag=谷歌站群软件【tg:seogoogle987】,qyi
- https://www.tullygroup.us/?ID=hbkq8jFjrQlVRrwzEmvoUJJAY4e1Lfo5&s=谷歌站群软件【tg:seogoogle987】,6w9
- https://www.spoiledsweetboutique.com/search/谷歌站群软件【tg:seogoogle987】,ylx
- https://xehay.vn/tim-kiem/=谷歌站群软件【tg:seogoogle987】,loS
- https://xn--lgernevedlystskoven-lxb.dk/search/谷歌站群软件【tg:seogoogle987】,Nmz
- https://www.remit.co.jp/vi/?s=谷歌站群软件【tg:seogoogle987】,aqn
- https://www.roberthalf.com/us/en/jobs/all/谷歌站群软件【tg:seogoogle987】tSb
- https://www.mi.com/search?keyword=谷歌站群软件【tg:seogoogle987】,oQF
- https://www.writingforward.com/?action=SEARCH&s=谷歌站群软件【tg:seogoogle987】,DKx
- https://www.sensorshop24.de/catalogsearch/result/index/?type=132&q=谷歌站群软件【tg:seogoogle987】,ZQs
- https://www.yidian51.com/taobao/谷歌站群软件【tg:seogoogle987】,evb