Redis企业集群命令错误“ CLUSTER”

时间:2020-03-04 16:13:47

标签: redis node-redis redis-cluster

我们刚刚安装了Redis Enterprise,并在数据库上进行了一些配置。

enter image description here

我们在应用程序上创建了一个简单的脚本,集群命令无效,这是正确的,它是无效的:

var RedisClustr = require('redis-clustr');
var redis = new RedisClustr({
  servers: [
    {
      host: 'URL',
      port: 18611
    }
  ],
  redisOptions: {
    password: 'ourpassword'
  }
});

redis.get('KSHJDK', function(err, res) {
  console.log(res, err);
});

外壳错误:

undefined Error: couldn't get slot allocation'
    at tryClient (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/src/RedisClustr.js:194:17)
    at /Users/machine/Sites/redis-testing/node_modules/redis-clustr/src/RedisClustr.js:205:16
    at Object.callbackOrEmit [as callback_or_emit] (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis/lib/utils.js:89:9)
    at RedisClient.return_error (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis/index.js:706:11)
    at JavascriptRedisParser.returnError (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis/index.js:196:18)
    at JavascriptRedisParser.execute (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis-parser/lib/parser.js:572:12)
    at Socket.<anonymous> (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis/index.js:274:27)
    at Socket.emit (events.js:321:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9) {
  errors: [
    ReplyError: ERR command is not allowed
        at parseError (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis-parser/lib/parser.js:193:12)
        at parseType (/Users/machine/Sites/redis-testing/node_modules/redis-clustr/node_modules/redis-parser/lib/parser.js:303:14) {
      command: 'CLUSTER',
      args: [Array],
      code: 'ERR'
    }
  ]
}

我们在配置上缺少什么吗? 我们不知道在群集上还是在Redis Enterprise上是否出错。

1 个答案:

答案 0 :(得分:1)

Redis Enterprise支持两种集群形式。 对于常规的OSS群集,您需要一个与您使用的客户端一样的群集感知客户端。 您正在使用的是面向群集的客户端,您应该将其与常规客户端一起使用(就像您要连接到单个Redis进程一样)。