我将出色的基于Redis的Bull.js用作Kubernetes上的工作队列。
已配置为集群:
当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项目之外的配置问题?
还是K8的网络问题?
是否可以启用: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>
答案 0 :(得分:3)
Hitobat是正确的。
如果这没有帮助:
vid.className += " blur";
top_vid.className += " blur";
我会没有ioredis,或者尝试将Redis引擎降级到4.x。