Redis command line redis-cli

redis-cli is the Redis command line interface, a simple program that allows to send commands to Redis, and read the replies sent by the server, directly from the terminal.

Jerry’s Notes
What’s next?
4 min readMar 20, 2022

--

Redis-cli: https://redis.io/topics/rediscli

Redis Commands: https://redis.io/commands

  • — latency
    Enter a special mode continuously sampling latency. If you use this mode in an interactive session, it runs forever displaying real-time stats.
  • — latency-history
    Like — latency but tracking latency changes over time. Default time interval is 15 sec. Change it using -i. 預設以15秒完成一次統計資訊,-i 可以調整預設秒數。
  •  — bigkeys: Sample Redis keys looking for keys with many elements (complexity).
     SCAN: version 2.8.0+ support
  •  — memkeys: Sample Redis keys looking for keys consuming a lot of memory.”
  •  — memkeys-samples <n>: Sample Redis keys looking for keys consuming a lot of memory, and define number of key elements to sample
  •  — hotkeys: Sample Redis keys looking for hot keys.

Only works when maxmemory-policy is *lfu.
 SCAN + LFU: version 4.0+ support

  • -c: cluster mode enabled
  • -h: ip address
  • -p: port
  • — tls: connect to redis cluster which in-transit encryption enabled.
  • -a: AUTH

Redis Desktop Manager (aka RDM)

https://rdm.dev/

http://docs.redisdesktop.com/en/docs/

RDM is a fast open source Redis database management application for Windows, Linux and MacOS. This tool offers you an easy-to-use GUI to access your Redis DB and perform some basic operations

Redis-cli install 安裝資訊

!!! 安裝 Redis-cli 的步驟,請注意 redis-cli 要 6.x 以上的版本,才支援 TLS 協定,並未必需在編譯階段加 “BUILD_TLS=yes”,才能支援。

而然後透過 redis-cli 指令,在您的實例上來連接您的 Redis 集群,來進行測試。範例如下,提供您參考。

monitor 監控命令

MONITOR is a debugging command that streams back every command processed by the Redis server. It can help in understanding what is happening to the database. This command can both be used via redis-cli and via telnet.

Commands not logged by MONITOR. Because of security concerns, all administrative commands are not logged by MONITOR’s output. Furthermore, the following commands are also not logged:

■ AUTH

■ EX

■ EC

■ HELLO

■ QUIT

!!! 此命令有可能造成大量 client output buffer 增加,造成內存不足,在極端的狀況下,有機會耗盡 FreeableMemory,進而使用到 SwapUsage,而造成系統異常。

client-list 命令

!!! 可以查看Client執行的命令及佔用的內存大小。

另外,也可以搭配使用 redis-faina 搭配 monitor 去即時分析。

https://github.com/facebookarchive/redis-faina

!!! monitor 命令,只適用於短時間的問題排查。

常見問題:

Q: 為什麼我的應用xxx,無法連接到 Redis 集群?

Q: 為什麼我的應用xxx,連接到 Redis 集群時出現yyy的錯誤?

Q: 為什麼我用 Redis-cli,無法連接到 Redis 集群?

Q: 為什麼我用 RDM(Redis Desktop Manager),無法連接到 Redis 集群?

Q: 如何查詢 Redis 系統運行日誌 (redis.log)?

Q: Redis連接超時問題? (Redis timeout exception?)

要檢查的地方很多,例如: Security Group? NACL? High Loading? Corrent Endpoint? Cluster? Client-side-latency issue? Instance throttling? etc..

--

--

Jerry’s Notes
What’s next?

An cloud support engineer focus on troubleshooting with customer reported issue ,and cloud solution architecture.