kubernetes - Kubernetes 上的 Redis 主/从设置抛出错误 : BRPOPLPUSH { ReplyError: MOVED 2651

标签 kubernetes redis bull.js

我正在使用基于 Redis 的出色 Bull.js作为 Kubernetes 上的作业队列。

它被配置为一个集群:

enter image description here

当 Kubernetes 在部署后重新启动时,我遇到了以下错误:

BRPOPLPUSH { ReplyError: MOVED 2651 <IP_ADDRESS>:6379
at parseError (/usr/src/app/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/usr/src/app/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:302:14)
command:
{ name: 'brpoplpush',
args:
[ '{slack}:slack notifications:wait',
'{slack}:slack notifications:active',
'5' ] } }

在哪里<IP_ADDRESS>是,我认为 集群 IP?我没有配置它,但我正在尝试调试它。我想知道我是否需要为 Bull.js 启用集群模式,或者这是否是 Bull.js 项目之外的配置问题?

或者是 K8s 的网络问题?

将启用:https://github.com/OptimalBits/bull#cluster-support是解决方案吗?这是正确的方法吗?

这是我的代码:

import Queue from 'bull';
import config from 'config';
import { run as slackRun } from './tasks/send-slack-message';
import { run as emailRun } from './tasks/send-email';

const redisConfig = {
  redis: {
    host: config.redis.host,
    port: config.redis.port
  }
};

const slackQueue = new Queue('slack notifications', { ...redisConfig, ...{ prefix: '{slack}' } });
const emailQueue = new Queue('email notifications', { ...redisConfig, ...{ prefix: '{email}' } });

slackQueue.process(slackRun);
emailQueue.process(emailRun);

emailQueue.on('completed', (job, result) => {
  job.remove();
});

export { emailQueue, slackQueue };
import { emailQueue, slackQueue } from 'worker/worker';

const queueOptions = {
  attempts: 2,
  removeOnComplete: true,
  backoff: {
    type: 'exponential',
    delay: 60 * 1000
  }
};

emailQueue.add(
  {
    params: {
      from: email,
      fromname: name,
      text: body
    }
  },
  queueOptions
);
slackQueue.add(
  {
    channelId: SLACK_CHANNELS.FEEDBACK,
    attachments: [
      {
        text: req.body.body
      }
    ]
  },
  queueOptions
);

这是配置图:

Name:         redis-cluster-config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
update-node.sh:
----
#!/bin/sh
REDIS_NODES="/data/nodes.conf"
sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${REDIS_NODES}
exec "$@"

redis.conf:
----
cluster-enabled yes
cluster-require-full-coverage no
cluster-node-timeout 15000
cluster-config-file nodes.conf
cluster-migration-barrier 1
appendonly yes
# Other cluster members need to be able to connect
protected-mode no

Events:  <none>

最佳答案

Hitobat不过是对的。

如果这没有帮助:

const Redis = require('ioredis');
...
const ioCluster = new Redis.Cluster([redisConfig.redis]);
const slackQueue = new Queue('slack notifications', {
  prefix: '{slack}' ,
  createClient: () => ioCluster
});
const emailQueue = new Queue('email notifications', {
  prefix: '{email}' ,
  createClient: () => ioCluster
});

我会不用 ioredis 或尝试将 redis 引擎降级到 4.x。

关于kubernetes - Kubernetes 上的 Redis 主/从设置抛出错误 : BRPOPLPUSH { ReplyError: MOVED 2651,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56140999/

相关文章:

redis - 我应该如何在 redis 中存储一长串 ID?

kubernetes - 无法将 ClusterRoleBinding 附加到 Kubernetes ServiceAccount

docker - kubernetes 无法从 spark master 主机中提取图像

python - 向 Redis 发送大量数据的最佳实践

Redis 内存使用情况和信息内存

spring-boot - 在kubernetes集群上部署spring应用

kubernetes - Helm : how to mount configMap if not supported by values. yaml?

javascript - 牛队列的process方法返回的promise可以忽略不计吗?

bull.js - 服务器 1 如何可靠地知道服务器 2 何时完成了特定工作? (bull.js)