有没有办法让redis中的客户端IP?

时间:2012-07-26 02:04:30

标签: redis

我进行了网络搜索,但没有发现任何内容。我在群集上运行redis并想知道哪台机器连接到redis(特别是当没有机器应该连接时,但redis仍然说连接了一些机器)。

提前感谢。

2 个答案:

答案 0 :(得分:8)

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

$ redis-cli client list

它将返回一个表,其字段在那里描述:

Redis "Client List" purpose and description

答案 1 :(得分:4)

您是否尝试过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.