{"id":2074,"date":"2023-04-01T21:45:01","date_gmt":"2023-04-01T13:45:01","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2074"},"modified":"2023-04-06T16:00:58","modified_gmt":"2023-04-06T08:00:58","slug":"redis-view-the-memory-size-occupied-by-the-value-values-of-all-keys","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/redis-view-the-memory-size-occupied-by-the-value-values-of-all-keys\/","title":{"rendered":"Redis \u67e5\u770b\u6240\u6709 key \u7684 value \u503c\u6240\u5360\u5185\u5b58\u5927\u5c0f"},"content":{"rendered":"<p>Redis \u867d\u597d\uff0c\u5374\u662f\u4e2a\u5403\u5185\u5b58\u517d\uff0c\u56e0\u6b64\u5728\u5199\u5165 Redis \u6570\u636e\u65f6\uff0c\u5e94\u8be5\u907f\u514d\u5199\u5165\u65e0\u7528\u7684\u6570\u636e\uff0c\u6d6a\u8d39\u5185\u5b58<\/p>\n<p>\u5982\u679c\u6211\u4eec\u8981\u5206\u6790\u54ea\u4e9b key \u5360\u7528\u4e86\u5927\u91cf\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5c31\u9700\u8981\u6709\u5de5\u5177\u8f85\u52a9\u5bf9\u6240\u6709\u7684 value \u6240\u70b9\u7a7a\u95f4\u8fdb\u884c\u6392\u5e8f\uff0c\u5982\u6b64\u624d\u80fd\u6709\u7684\u653e\u77e2\u8fdb\u884c\u4f18\u5316<\/p>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/sripathikrishnan\/redis-rdb-tools#generate-memory-report\" title=\"redis-rdb-tools\">redis-rdb-tools<\/a> \u53ef\u4ee5\u5c06\u6240\u6709 key \u5bf9\u5e94\u7684 value \u5927\u5c0f\u7528 csv \u683c\u5f0f\u5bfc\u51fa<\/p>\n<p><!-- more --><\/p>\n<p>\u5b89\u88c5\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash\">$ pip install rdbtools python-lzf\n$ git clone https:\/\/github.com\/sripathikrishnan\/redis-rdb-tools\n$ cd redis-rdb-tools\n$ sudo python setup.py install<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u627e\u5230 Redis \u7684<code>dump.rdb<\/code>\u4f4d\u7f6e<\/p>\n<p>\u9996\u5148\u5b9a\u4f4d\u5230<code>redis.conf<\/code>\u4f4d\u7f6e<\/p>\n<pre><code class=\"language-bash\">$ whereis redis.conf\nredis: \/etc\/redis.conf<\/code><\/pre>\n<pre><code class=\"language-bash\">$ cat \/etc\/redis.conf | grep dir | grep redis\ndir \/var\/lib\/redis\n$ cat \/etc\/redis.conf | grep dump.rdb\ndbfilename dump.rdb<\/code><\/pre>\n<p>\u7efc\u4e0a\uff0c\u5f97\u77e5\u5176\u8def\u5f84\u4e3a\uff1a<code>\/var\/lib\/redis\/dump.rdb<\/code><\/p>\n<p>\u6309\u5185\u5b58\u503c\u5bfc\u51fa csv<\/p>\n<pre><code class=\"language-bash\">$ rdb -c memory \/var\/lib\/redis\/dump.rdb &gt; \/tmp\/redis.csv<\/code><\/pre>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u6570\u636e\u5e93\/redis-rdb-tools\u6570\u636e\u5bfc\u51facsv.png\" alt=\"redis-rdb-tools\u6570\u636e\u5bfc\u51facsv\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis \u867d\u597d\uff0c\u5374\u662f\u4e2a\u5403\u5185\u5b58\u517d\uff0c\u56e0\u6b64\u5728\u5199\u5165 Redis \u6570\u636e\u65f6\uff0c\u5e94\u8be5\u907f\u514d\u5199\u5165\u65e0\u7528\u7684\u6570\u636e\uff0c\u6d6a\u8d39\u5185\u5b58 \u5982\u679c\u6211\u4eec\u8981 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-2074","post","type-post","status-publish","format-standard","hentry","category-redis"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2074"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2074\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}