redis-cli - pipe屈服在大量上传到启用群集模式的弹性时移动错误

发布于 2025-01-20 05:23:33 字数 1199 浏览 0 评论 0原文

我正在尝试使用redis-cli - pipe将一些命令上传到我的AWS Elasticache以进行REDIS群集。这些命令来自通过自定义awk命令解析文件,该命令有助于生成一些HSET命令。 awk命令在自定义Shell脚本中。当我的Redis服务器的Elasticache已禁用群集模式时,执行以下操作就像魅力一样:

sh script_containing_awk.sh $FILE_TO_PARSE | redis-cli -h <Primary_endpoint> -p <port> --tls --cacert <path/to/cert> --pipe

由于内部项目的要求,Redis Server的Elasticache已通过启用了群集模式重新创建,因此我正在添加-c标记到上述命令,以这样指定。

我在尝试使用启用群集模式的Redis Server的Elasticache工作时看到了以下结果:

  • 我可以通过配置端点连接到群集没有问题!
  • 单个命令上传工作(即:redis -cli -h&lt; config_endpoint&gt; -p&lt; port&gt; -c -tls -tls -cacert&cacert&lt; path/to/certs&certs&gt; set键值

)只需将我的脚本输出输出到CLI即可到达:

sh script_containing_awk.sh $FILE_TO_PARSE | redis-cli -h <config_endpoint> -p <port> -c --tls --cacert <path/to/cert> --pipe

但是添加- PIPE标志在“移动”错误中结果。

我已经尝试将脚本修改为包括{}(ex:hset {user1}:hash field1 val1 field2 field2 val2 ...支架,以将密钥强制到同一群集 所以我认为它们都不会适合同一插槽。

插槽,但我仍然会遇到“移动”错误,我正在尝试上传数百万键, 代码>使用启用cluster-mode redis/Eprosticach

I am trying to use redis-cli --pipe to bulk upload some commands to my AWS Elasticache for redis cluster. The commands come from parsing a file via a custom awk command, which helps generate some HSET commands. The awk command is in a custom shell script. When my Elasticache for redis server had cluster-mode disabled, doing something like the following worked like a charm:

sh script_containing_awk.sh $FILE_TO_PARSE | redis-cli -h <Primary_endpoint> -p <port> --tls --cacert <path/to/cert> --pipe

Due to an internal project requirement, the Elasticache for Redis server has been re-created with cluster-mode enabled, and hence I am adding the -c flag to the above command to specify as such.

I see the following results when trying to work with my Elasticache for Redis server with cluster-mode enabled:

  • I can connect to the cluster via the configuration endpoint no problem!
  • Single command uploads work (i.e: redis-cli -h <config_endpoint> -p <port> -c --tls --cacert <path/to/certs> SET key value)

It would be extremely convenient to just pipe output from my script to the cli:

sh script_containing_awk.sh $FILE_TO_PARSE | redis-cli -h <config_endpoint> -p <port> -c --tls --cacert <path/to/cert> --pipe

but adding the --pipe flag results in "MOVED" errors.

I have tried modifying the script to include {} (ex: HSET {user1}:hash field1 val1 field2 val2 ... brackets to try to force keys to the same CLUSTER SLOTS, but I still get the "MOVED" errors and I am attempting to bulk upload millions of keys so I don't think they would all fit in the same slot anyway.

Does anyone have experience getting --pipe to work with cluster-mode enabled Redis/Elasticache?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好久不见√ 2025-01-27 05:23:33

我相信您了解禁用集群模式和启用集群模式之间的核心区别在于您的总密钥槽位存在分割。

只是为了结合上下文;
CMD - 假设我们有 4 个节点集群,其中 1 个主节点和 3 个副本节点。
如果我们有 100 个钥匙槽 -
所有 100 个密钥槽都将存在于所有节点中。其中 3 个节点将提供只读命令,1 个节点将提供所有命令。

CME - 假设我们有 4 个节点,分为 2 个分片 - 每个分片有 1 个副本和 1 个主分片。
我们可以将它们视为逻辑子簇,即。他们将有不同组的键槽。理想情况下是 50-50 的分配。

现在,MOVED 消息不一定是错误。
当您连接到配置端点时,默认情况下您将连接到一个主节点(首先随机选择)。
当您发出命令时,客户端发送该命令,并且主节点决定它是否具有正确的哈希槽来服务该命令。

正如此处所解释的,如果节点没有散列-您的客户正在寻找的插槽,它将使用 MOVED 消息重定向您。

因此,我认为 MOVED 消息在某种程度上是 CME 集群所期望的。

I am sure you understand that the core difference between Cluster Mode Disabled and Cluster Mode Enabled is that there is a split in your total Key slots.

Just to put in context;
CMD - Let's say we have 4 node cluster with 1 Primary and 3 Replicas.
if we have 100 key slots -
All the 100 key slots will be there in all the nodes. 3 of them will serve Read only commands and 1 of the node will serve all the commands.

CME - Let's say we have 4 nodes split in 2 shards - 1 replica and 1 primary each.
We can look at them as logical sub-clusters ie. they will have different sets of key-slots. Ideally a 50-50 split.

Now, the MOVED message is not necessarily an error.
When you connect to the configuration endpoint, by default you are being connected with one of the primary nodes (chosen at random, at first).
when you make a command, the client sends that command and the primary node decides if it has the correct hash-slot to serve that command.

As explained here, if the node does not have the hash-slot that your client is looking for, it will redirect you with a MOVED message.

So, I would assume MOVED messages are somewhat expected with CME clusters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文