9

我进行了网络搜索,但对此一无所获。我在集群上运行 redis 并想找出哪台机器正在连接到 redis(尤其是当没有机器应该连接,但 redis 仍然说某些机器已连接时)。

提前致谢。

4

2 回答 2

10

使用 MONITOR,只会显示实际向 Redis 发送流量的客户端。如果只需要获取已连接客户端的列表,可以使用 CLIENT LIST 命令。

$ redis-cli client list

它将返回一个表,其中描述了其中的字段:

Redis“客户列表”的用途和说明

于 2012-07-26T12:09:56.063 回答
5

您是否尝试过 MONITOR 命令?

http://redis.io/commands/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"
 Use SIGINT (Ctrl-C) to stop a MONITOR stream running via redis-cli.

 # OR 
 $ 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.
于 2012-07-26T02:49:26.180 回答