Redis性能监控
1.监视Redis实例
./redis-cli --stat
------- data ------ --------------------- load -------------------- - child - keys mem clients blocked requests connections 8 1.47M 3 0 29938813 (+0) 2816 8 1.47M 3 0 29940663 (+1850) 2816 8 1.47M 3 0 29942557 (+1894) 2816 8 1.47M 3 0 29944024 (+1467) 2816 8 1.47M 3 0 29945472 (+1448) 2816 8 1.47M 3 0 29946878 (+1406) 2816 8 1.47M 3 0 29948331 (+1453) 2816 8 1.47M 3 0 29949734 (+1403) 2816 8 1.47M 3 0 29951126 (+1392) 2816 8 1.47M 3 0 29952611 (+1485) 2816 8 1.47M 3 0 29954056 (+1445) 2816 8 1.47M 3 0 29955494 (+1438) 2816 8 1.47M 3 0 29956915 (+1421) 2816 8 1.47M 3 0 29958298 (+1383) 2816 8 1.47M 3 0 29959777 (+1479) 2816 8 1.47M 3 0 29961192 (+1415) 2816 8 1.47M 3 0 29962622 (+1430) 2816 8 1.47M 3 0 29963983 (+1361) 2816 8 1.47M 3 0 29965493 (+1510) 2816 8 1.47M 3 0 29966872 (+1379) 2816 ------- data ------ --------------------- load -------------------- - child - keys mem clients blocked requests connections 8 1.47M 3 0 29968343 (+1471) 2816 8 1.47M 3 0 29969669 (+1326) 2816 8 1.47M 3 0 29971173 (+1504) 2816 8 1.47M 3 0 29972615 (+1442) 2816 8 1.47M 3 0 29974036 (+1421) 2816 8 1.47M 3 0 29975443 (+1407) 2816 8 1.47M 3 0 29976899 (+1456) 2816 8 1.47M 3 0 29978310 (+1411) 2816 8 1.47M 3 0 29979754 (+1444) 2816 8 1.47M 3 0 29981159 (+1405) 2816 8 1.47M 3 0 29982590 (+1431) 2816 8 1.47M 3 0 29984009 (+1419) 2816 8 1.47M 3 0 29985462 (+1453) 2816 8 1.47M 3 0 29986855 (+1393) 2816 8 1.47M 3 0 29988289 (+1434) 2816 8 1.47M 3 0 29989752 (+1463) 2816 8 1.47M 3 0 29991165 (+1413) 2816 8 1.47M 3 0 29992598 (+1433) 2816 8 1.47M 3 0 29994028 (+1430) 2816 8 1.47M 3 0 29995453 (+1425) 2816
keys:当前节点缓存的key总数
mem:当前节点缓存总的占用内存
clients:当前节点的活跃连接数,或者说未断开连接的总连接数
blocked:当前节点正在等待阻塞命令的数量
requests:当前处理的请求数,与上一次请求数相减可知1秒所处理的请求,或者说所执行的命令数。
connections:是历史连接总数,即到目前为止,一共新建了多少个连接。与前一次相减,可以得出一秒内新建的连接数。
2.网络延迟
[root@iZnflZ bin]# ./redis-cli --latency min: 0, max: 8, avg: 0.16 (7983 samples)
最小值0毫秒,最大值8毫秒,平均0,16毫秒,总共记录了7983个样例
若是集群,查询本机到其他节点的网络延迟,添加 " -h ip "即可
3.慢查询
首先看看redis.conf文件slowlog的配置,单位是微秒,默认配置10000微秒也就是10毫秒
# The following time is expressed in microseconds, so 1000000 is equivalent # to one second. Note that a negative number disables the slow log, while # a value of zero forces the logging of every command. slowlog-log-slower-than 10000
使用redis.cli slowlog get 1打印最后一条,由于没有慢查询,展示的是empty list or set
[root@iZnflZ bin]# ./redis-cli 127.0.0.1:6379> slowlog get 1 (empty list or set) 127.0.0.1:6379>