内容简介:最近在用 redis 的时候想看看执行了哪些命令,于是发现了 redis-cli 提供的Monitor 是调试用的命令使用redis-cli连接到redis服务器
监控 redis 执行命令
Intro
最近在用 redis 的时候想看看执行了哪些命令,于是发现了 redis-cli 提供的 Monitor
命令,直接使用这个就可以监控执行的大部分 redis 命令,之所以说是大部分,是因为有一些命令如: config
出于安全原因是不会记录的。
Monitor 是调试用的命令
Redis-cli
使用redis-cli连接到redis服务器
redis-cli -h [redis server ip/host] -p [redis server port] [-a accessKey]
之后执行 monitor 命令
$ redis-cli monitor 1339518083.107412 [0 127.0.0.1:60866] "keys" "*" 1339518087.877697 [0 127.0.0.1:60866] "dbsize" 1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" 1339518096.506257 [0 127.0.0.1:60866] "get" "x" 1339518099.363765 [0 127.0.0.1:60866] "del" "x" 1339518100.544926 [0 127.0.0.1:60866] "get" "x"
使用 Ctrl+C 退出 monitor
Telnet
使用 telnet 连接 redis服务器,而后执行 monitor
$ telnet localhost 6379 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. MONITOR +OK +1339518083.107412 [0 127.0.0.1:60866] "keys" "*" +1339518087.877697 [0 127.0.0.1:60866] "dbsize" +1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" +1339518096.506257 [0 127.0.0.1:60866] "get" "x" +1339518099.363765 [0 127.0.0.1:60866] "del" "x" +1339518100.544926 [0 127.0.0.1:60866] "get" "x" QUIT +OK Connection closed by foreign host.
使用 Quit 命令来退出 monitor
性能消耗
由于 MONITOR
命令返回 服务器处理的所有的 命令, 所以在性能上会有一些消耗.
在不运行 MONITOR
命令的情况下,benchmark的测试结果:
$ src/redis-benchmark -c 10 -n 100000 -q PING_INLINE: 101936.80 requests per second PING_BULK: 102880.66 requests per second SET: 95419.85 requests per second GET: 104275.29 requests per second INCR: 93283.58 requests per second
运行 MONITOR
命令的情况下,benchmark 的测试结果:
$ src/redis-benchmark -c 10 -n 100000 -q PING_INLINE: 58479.53 requests per second PING_BULK: 59136.61 requests per second SET: 41823.50 requests per second GET: 45330.91 requests per second INCR: 41771.09 requests per second
在这种特定的情况下,运行一个 MONITOR 命令能够降低50%的吞吐量
所以,如果不是特别需要不推荐使用 Monitor
这个命令,仅供开发过程中的调试。
Reference
以上所述就是小编给大家介绍的《监控 redis 执行命令》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- mongodb监控工具mongostat的使用及命令详解
- SMProxy 1.2.9 发布,新增状态命令监控面板功能
- 使用go-sniffer监控mysql、redis执行命令
- CentOS Linux 下使用 iotop 命令监控磁盘 I/O 活动
- composer更新命令及常用命令
- Linux命令行与命令
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Master Switch
Tim Wu / Knopf / 2010-11-2 / USD 27.95
In this age of an open Internet, it is easy to forget that every American information industry, beginning with the telephone, has eventually been taken captive by some ruthless monopoly or cartel. Wit......一起来看看 《The Master Switch》 这本书的介绍吧!