kubernetes - Redis 集群连接丢失
问题描述
我有一个使用 bitnami/redis-cluster 图表部署在 Kubernetes 中的 Redis 集群。我使用 redis-cluster npm 包从 nodejs 连接到集群。建立连接后,我尝试连续设置数千个键。完成所有过程的时间预计为十分钟。但连接两分钟后,Redis 连接丢失。
是否是连接问题,我该怎么办?比如改变配置什么的。
在我的场景或常见场景中丢失连接的确切原因可能是什么?
我的代码:
const redis = require('redis');
const redisCluster = require('redis-clustr')
const redisClient = new redisCluster({
servers: [
{ host: "IP", port: 6379 },
{ host: "IP", port: 6379 },
{ host: "IP", port: 6379 },
{ host: "IP", port: 6379 },
{ host: "IP", port: 6379 },
{ host: "IP", port: 6379 }
],
createClient: (port, host) => {
return redis.createClient({
port,
host,
auth_pass: 'PASSWORD',
});
}
});
<My data processing code to set thousands of keys>
(node:15827) UnhandledPromiseRejectionWarning: AbortError: Redis connection lost and command aborted. It might have been processed.
at RedisClient.flush_and_error (/root/data-pipeline/node_modules/redis/index.js:362:23)
at RedisClient.connection_gone (/root/data-pipeline/node_modules/redis/index.js:664:14)
at Socket.<anonymous> (/root/data-pipeline/node_modules/redis/index.js:293:14)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:15827) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15827) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
解决方案
推荐阅读
- elasticsearch - 为弹性搜索查询添加模糊性
- python - 如何使用 IDLE 或终端为 Python 安装 pandas?
- python - 字典列表列表到元组列表列表
- javascript - 如何将用户限制为只有一个帖子请求
- c++ - 在 Visual Studio 2019 中打开 .h 或 .cpp 文件时,注释和包含被折叠
- python - 使用 tkinter 添加标签/文本(理想情况下位于倒数计时器上方)
- javascript - 跟随鼠标悬停在 Div 上,但仅在 Div 上
- css - 如何设置 flexbox 容器中的最大行数并隐藏额外元素?
- c# - 我可以使用常规 C# 类初始化 gRPC 回复消息重复字段吗?
- android - agora.io Android SDK:如何调整麦克风音量