info命令
最常用的就是Redis内置的info命令了。通过info命令,可以打印有关Redis服务器的指标和信息。
输出的信息分为以下10组:server, client, memory, persistence, stats, replication, cpu, commandstats, cluster, keyspace。
启用慢日志[1]
Redis 慢日志是一种记录超过指定执行时间的查询的系统。执行时间不包括与客户端通信、发送回复等 I/O 操作,而只是实际执行命令所需的时间(这是命令执行的唯一阶段,该阶段Redis线程会被阻塞)。
可以通过编辑redis.conf
或在服务器运行时使用 CONFIG GET 和 CONFIG SET 命令来完成配置。
如,可以通过以下命令设置慢日志监控参数:
1 | # 命令执行超过5毫秒则记录为慢日志,注意,设置为负数会禁用慢日志,设置为0会强制记录每个命令 |
redis-stat
Redis-stat是一个Redis指标可视化监控工具,采用ruby开发,基于Redis的info命令来统计,不影响Redis性能。
RedisLive
RedisLive是一个采用Python开发的Redis可视化及查询分析工具。
redis_exporter
如果您正在使用Prometheus,则可以使用这个工具。redis_exporter是为Prometheus提供的Redis指标监控exporter,支持Redis 2.x, 3.x, 4.x, 5.x, and 6.x。
redmon
简单的基于 sinatra 的 redis 仪表板,提供了用于管理 redis 的 Web 界面:cli、admin,同时能够实时监控Redis。
接下来介绍其中最常用的性能指标[2]。