ioredis - ClusterAllFailedError:无法刷新插槽缓存

Cyb*_*min 11 amazon-web-services redis node.js amazon-elasticache

我正在处理ClusterAllFailedError: Failed to refresh slots cache.来自 ioredis 和 Elasticache的问题。这是我的集群配置

const clusterOptions = {
    enableReadyCheck: true,
    retryDelayOnClusterDown: 300,
    retryDelayOnFailover: 1000,
    retryDelayOnTryAgain: 3000,
    slotsRefreshTimeout: 200000000000000,
    clusterRetryStrategy: (times) => Math.min(times * 1000, 10000),
    dnsLookup: (address, callback) => callback(null, address),
    scaleReads: 'slave',
    showFriendlyErrorStack: true,
    redisOptions: {
        keyPrefix: config.queue.prefix,
        autoResubscribe: true,
        autoResendUnfulfilledCommands: true
    }
}

const redisClientInstance = new Redis.Cluster([{ host: '', port: ''}], clusterOptions);
Run Code Online (Sandbox Code Playgroud)

但是尝试访问 Redis 总是会导致Failed refresh slots cache. 还有其他人处理过这个问题吗?

谢谢你。

GSS*_*ain 8

以下对我有用。

Redis 版本5.0.4 on AWS ElastiCacheClustered with TLSand AUTHenabled。

ioredis 版本4.16.0

连接代码:

const redis = new Redis.Cluster(
            [{ "host": <ELASTI_CACHE_CONFIGURATION_ENDPOINT> }], {
                dnsLookup: (address, callback) => callback(null, address),
                redisOptions: {
                    tls: true,
                    password: <ELASTI_CACHE_REDIS_AUTH>
                }
            });
Run Code Online (Sandbox Code Playgroud)

当您启动 时ElastiCache,您需要指定一个或多个Subnet Group(通常是私有子网)和Security Group. 当您从任何计算(Lambda、EC2 等)运行上述代码时,您需要确保以下内容

  • ElastiCache从您的计算可达(把计算其中可的子网通信子网ElastiCache在相同的VPC。如果计算并Elasticache在不同的VPC,确保它们之间的对等启用VPC)。
  • 确保Security Group,NACL允许从您的 Compute连接到ElastiCache端口(6379默认)Subnet
  • 最后确保 Compute 可以承担IAM Role(EC2 实例配置文件、Lambda 角色等)对ElastiCache. 如果您在 EC2 实例上运行,请确保您的代码使用 EC2 实例配置文件中分配的角色的临时凭证。

  • 我尝试了您的解决方案,但一段时间后,它抛出错误“ClusterAllFailedError:无法刷新插槽缓存” (2认同)