Redis内存满了故障排查

针对Redis的故障排查有很多手段,以下列举一些:

  1. Redis是基于内存的key-value数据库,如果想对整个存储的数据做一个分析,可以从redis下载Rdb.dump 文件进行分析,也可以使用bgsave命令生成RDB快照文件,切记不要使用save命令,否则会阻塞主线程;
  2. 对某一个key进行内存大小分析,使用命令: memory usage key 对某个key占用的内存进行统计
  3. 使用redis的monitor命令,举个栗子:redis-cli -h localhost -p 6379 MONITOR | head -n 100000 | ./redis-faina.py , 这条命令的意思是,对10万条命令进行动态监控,将结果输送给faina进行分析;有关faina的知识可以看它的git官网https://github.com/facebookarchive/redis-faina
  4. 下面简单介绍一下faina,redis-faina是由Instagram 开发并开源的一个Redis 查询分析小工具,安装:git clone https://github.com/facebookarchive/redis-faina.git , 执行./redis-faina.py -h
  5. redis监控命令monitor,如下图在这里插入图片描述
    但是实际上monitor对redis的性能是有影响的,利用bench-mark进行测试src/redis-benchmark -c 10 -n 100000 -q得出结论,吞吐量大概会有50%的减少。
  6. 使用命令查看内存状况,memory stats
    peak.allocated: 已分配最大内存 bytes
    total.allocated: 已分配的总内存
    startup.allocated: 初始分配内存
    replication.backlog: 复制缓冲大小
    clients.slaves: 复制的内存大小
    clients.normal: The total size in bytes of all clients overheads (output and query buffers, connection contexts)
    aof.buffer: The summed size in bytes of AOF related buffers.
    lua.caches: the summed size in bytes of the overheads of the Lua scripts’ caches
    dbXXX: For each of the server’s databases, the overheads of the main and expiry dictionaries (overhead.hashtable.main and overhead.hashtable.expires, respectively) are reported in bytes
    overhead.total: The sum of all overheads, i.e. startup.allocated, replication.backlog, clients.slaves, clients.normal, aof.buffer and those of the internal data structures that are used in managing the Redis keyspace (see INFO’s used_memory_overhead)
    keys.count: key总数
    keys.bytes-per-key: key平均大小
    dataset.bytes: 数据库大小
    dataset.percentage: The percentage of dataset.bytes out of the net memory usage
    peak.percentage: The percentage of peak.allocated out of total.allocated

版权声明:本文为qq_29220057原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。