2012-07-26 341 views
5

我做了網絡搜索,但沒有發現任何東西。我正在羣集上運行redis,並希望找出哪臺機器連接到redis(特別是當沒有機器應該連接時,但redis仍然表示連接了某臺機器)。有沒有辦法在redis中獲取客戶端IP?

在此先感謝。

回答

7

帶顯示器,實際上只流發送到Redis的客戶端將被顯示。如果您只需要獲取連接的客戶端列表,則可以使用CLIENT LIST命令。

$ redis-cli client list 

它會返回一個表,它的字段有描述:

Redis "Client List" purpose and description

+0

很大,這正是我需要的。 – qkhhly 2012-07-27 15:33:22

2

您是否嘗試過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. 
相關問題