is there a way to get the client IP in redis?

强颜欢笑 提交于 2021-02-18 22:37:12

问题


I did a web search but found nothing on this. I am running redis on a cluster and would like to find out which machine is connecting to redis ( especially when no machine is supposed to be connecting, but redis still says some machine connected).

thanks in advance.


回答1:


With MONITOR, only the clients actually sending traffic to Redis will be shown. If you just need to get a list of connected clients, you can use the CLIENT LIST command.

$ redis-cli client list

It will return a table whose fields are described there:

Redis "Client List" purpose and description




回答2:


Did you try the MONITOR command?

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.


来源:https://stackoverflow.com/questions/11661314/is-there-a-way-to-get-the-client-ip-in-redis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!