You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
监控 redis 执行命令
Intro
最近在用 redis 的时候想看看执行了哪些命令,于是发现了 redis-cli 提供的
Monitor
命令,直接使用这个就可以监控执行的大部分 redis 命令,之所以说是大部分,是因为有一些命令如:config
出于安全原因是不会记录的。Monitor 是调试用的命令
Redis-cli
使用redis-cli连接到redis服务器
之后执行 monitor 命令
使用 Ctrl+C 退出 monitor
Telnet
使用 telnet 连接 redis服务器,而后执行 monitor
使用 Quit 命令来退出 monitor
性能消耗
由于
MONITOR
命令返回 服务器处理的所有的 命令, 所以在性能上会有一些消耗.在不运行
MONITOR
命令的情况下,benchmark的测试结果:运行
MONITOR
命令的情况下,benchmark 的测试结果:在这种特定的情况下,运行一个 MONITOR 命令能够降低50%的吞吐量
所以,如果不是特别需要不推荐使用
Monitor
这个命令,仅供开发过程中的调试。Reference
The text was updated successfully, but these errors were encountered: