本文介绍: 随着时间流逝,redis内存逐步增大,需要对redis内存进行清理,发现问题,解决问题。

场景

        随着时间流逝,redis内存逐步增大,需要对redis内存进行清理,发现问题,解决问题。

方案

bigkeys 命令用于识别在 Redis 数据库中占用最多内存的键。

对服务有一定开销,在使用系统低峰期操作。

redis-cli -c -h 127.0.0.1 -p 7021 --bigkeys
输出结果
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).

[00.00%] Biggest string found so far '"xxx22"' with 172 bytes
[00.45%] Biggest hash   found so far '"xx111"' with 1 fields
....
[06.72%] Biggest list   found so far '"lizzList"' with 1 items
...
[39.70%] Biggest set    found so far '"setlizz:20"' with 8 members
[50.22%] Biggest hash   found so far '"hashlizz:123123"' with 2480 fields
[85.93%] Biggest string found so far '"string111:12321312"' with 445240 bytes
[95.07%] Biggest zset   found so far '"lizzZset"' with 30 members

-------- summary -------

Sampled 32329 keys in the keyspace!
Total key length in bytes is 1496560 (avg len 46.29)

Biggest   list found '"lizzList"' has 1 items
Biggest   hash found '"hashlizz:123123"' has 2480 fields
Biggest string found '"string111:12321312"' has 445240 bytes
Biggest    set found '"setlizz:20"' has 8 members
Biggest   zset found '"lizzZset"' has 30 members

4 lists with 4 items (00.01% of keys, avg size 1.00)
329 hashs with 3956 fields (01.02% of keys, avg size 12.02)
31922 strings with 6028942 bytes (98.74% of keys, avg size 188.86)
0 streams with 0 entries (00.00% of keys, avg size 0.00)
16 sets with 27 members (00.05% of keys, avg size 1.69)
58 zsets with 237 members (00.18% of keys, avg size 4.09)

 结果说明

[95.07%] Biggest zset   found so far '"lizzZset"' with 30 members
  1. 表示当前在内存使用最大的键,不包括值内容
  2. 95.07% :当前扫描进度
  3. zset :键值类型为,包括zset、list、set、hash、string
  4. ‘”lizzZset”‘ : 键名
  5. n members:队列键值有n成员
  6. n items:队列键值有n个成员
  7. n bytes :字符串键值占用n个字节
  8. n fields : 集合键有n个字段
Sampled 32329 keys in the keyspace!
Total key length in bytes is 1496560 (avg len 46.29)
  • 对键空间采样,共检查了 32329 个键。
  • 键的总长度为 1496560 字节,平均长度为 46.29 字节。
Biggest   list found '"lizzList"' has 1 items
Biggest   hash found '"hashlizz:123123"' has 2480 fields
Biggest string found '"string111:12321312"' has 445240 bytes
Biggest    set found '"setlizz:20"' has 8 members
Biggest   zset found '"lizzZset"' has 30 members
  • 每个数据类型的最大占用健 
31922 strings with 6028942 bytes (98.74% of keys, avg size 188.86)
  • 31922 个String类型的健,总的内存空间为6028942个字节,健数量的占比为98.74%,健值大小平均为188.86bytes。
  • 其他类型。

原文地址:https://blog.csdn.net/lizz861109/article/details/135977585

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_64587.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注