AWS Builder Center: Learn, Build and Connect with builders in the AWS community
AWS Builder Center is the official home for builders on AWS. Share and read what others are working on, follow people who inspire you, explore training and workshops, and find tools to support what you're building.
如何在 EC2 windows 的机器上,使用 Redis 客户端工具去连接 ElastiCache Redis 集群?
在本文中旨在介绍,如何透过以下 Redis 客户端工具,在 EC2 Windows 的机器,来连接及操作 ElastiCache Redis 集群,分别为 redis-cli 及 图型化介面工具: Redis Insight。
这边介绍两个工具分别如下,您可以透过以下工具来连接 ElastiCache Redis 终端位置 Endpoint,並登入 Redis 节点来操作您的数据。
- 命令列工具: redis-cli on windows
- 图型化介面工具: Redis Insight
命令列工具: redis-cli 介绍
Redis-cli 是 Redis 的命令行界面工具,它是一个用于与 Redis 服务器交互的命令行客户端工具。使用 redis-cli 可以执行以下操作:
- 连接 Redis 服务器:
连接指定主机和端口: redis-cli -h <host> -p <port>
- 执行 Redis 命令:
在 redis-cli 提示符下直接输入 Redis 命令, 比如 SET key value、GET key等。
- 监控 Redis 服务器:
redis-cli monitor 可以监控 Redis 服务器接收的所有请求。
- 其他功能:
redis-cli --help 可以查看更多 redis-cli 的用法和功能。
命令列工具: redis-cli on windows
您可以在以下 GitHub 来找到相关资讯,请先下载安装档,并安装在您的 EC2 Windows 实例内。
[+] GitHub - microsoftarchive/redis: https://github.com/MicrosoftArchive/redis/
[+] Release 3.0.504 · microsoftarchive/redis · GitHub: https://github.com/microsoftarchive/redis/releases/tag/win-3.0.504
https://github.com/microsoftarchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
然后开启 Windows 终端机(Windows Terminal) 并且切换工作目录到 安装目录 下,即可以直接使用 命令列工具: redis-cli 来连接您的 Redis 节点。
图型化介面工具: Redis Insight
Redis Insight 是 Redis Labs 提供的一款可视化管理工具。它主要有以下特点:
- 图形化界面
Redis Insight 提供了一个友好的图形化界面,可以直观地查看 Redis 实例的数据结构、配置信息、性能统计等。
- 多 Redis 集群管理
可以同时管理多个 Redis 集群,包括本地和 ElastiCache Redis。
- 执行 Redis 命令
实时分析发送到命令到 Redis 集群,例如直接输入 Redis 命令, 比如 SET key value、GET key等。
- 消息发布及订阅
支持 Redis 发布/订阅,可订阅频道并向频道发布消息。
您可以在以下 Redis 官方网站中,来找到相关资讯,请先下载安装档( Redis-Insight-win-installer.exe),并安装在您的 EC2 Windows 实例内。
[+] Redis Insight - The Best Redis GUI: https://redis.io/insight/
!!! 当您在安装完成后,请您先添加一个新的 Redis database,这边填入的是 ElastiCache Redis 终端位置 Endpoint 的资讯。
添加一个新的 Redis database
填入的是 ElastiCache Redis 终端位置 Endpoint 的资讯
您可以在上面直接使用 SET/GET 等命令,来直接操作您的键值。
xxx1.usw2.cache.amazonaws.com:6379> monitor
OK
1724209478.037386 [0 10.0.200.88:56534] "info"
1724209483.039615 [0 10.0.200.88:56534] "info"
1724209486.861913 [0 10.0.200.88:60146] "info"
1724209486.862943 [0 10.0.200.88:60146] "client" "setname" "redisinsight-workbench-e02c5e20" <---- !!!
1724209486.864681 [0 10.0.200.88:60146] "set" "key" "111" <---- !!!
1724209488.040031 [0 10.0.200.88:56534] "info"
1724209558.185069 [0 10.0.200.88:56534] "info"
1724209598.038869 [0 10.0.200.88:56534] "info"
1724209602.895008 [0 10.0.200.88:60146] "get" "key" <---- !!!
1724209603.190325 [0 10.0.200.88:56534] "info"
可以直接使用该工具所提供的分析功能,例如查询内存使用量、键值笔数等等。
xxx1.usw2.cache.amazonaws.com:6379> monitor
OK
1724209669.410269 [0 10.0.200.88:34106] "client" "setname" "redisinsight-common-e02c5e20"
1724209669.411271 [0 10.0.200.88:34106] "dbsize"
1724209669.412869 [0 10.0.200.88:34106] "scan" "0" "count" "2000" "match" "*"
1724209669.421569 [0 10.0.200.88:34106] "memory" "usage" "sample_restaurant:4" "samples" "0"
1724209669.421589 [0 10.0.200.88:34106] "memory" "usage" "sample_bicycle:1056" "samples" "0"
...
1724209669.429127 [0 10.0.200.88:34106] "type" "sample_restaurant:4"
1724209669.429145 [0 10.0.200.88:34106] "type" "sample_bicycle:1056"
...
1724209669.435644 [0 10.0.200.88:34106] "ttl" "sample_restaurant:4"
1724209669.435661 [0 10.0.200.88:34106] "ttl" "sample_bicycle:1056"
...
1724209669.485852 [0 10.0.200.88:34106] "info" "memory"
1724209669.486070 [0 10.0.200.88:34106] "info" "clients"
1724209669.486320 [0 10.0.200.88:34106] "info" "keyspace"
1724209669.488082 [0 10.0.200.88:34106] "info" "server"
最后,该工具也可以透过 docker 的方式来连行,您可以在以下连结,找到 Docker Image 来运行。
[+] redis/redisinsight - Docker Image | Docker Hub: https://hub.docker.com/r/redis/redisinsight
$ docker run -d --name redisinsight -p 5540:5540 redis/redisinsight:latest
- 主題
- 資料庫
- 語言
- 中文 (繁體)
相關內容
已提問 1 年前
