我的目标是只添加从属uri,因为master在我的情况下不可用。但是莴苣库回来了
io.lettuce.core.RedisException: Master is currently unknown: [RedisMasterSlaveNode [redisURI=RedisURI [host='127.0.0.1', port=6382], role=SLAVE], RedisMasterSlaveNode [redisURI=RedisURI [host='127.0.0.1', port=6381], role=SLAVE]]
所以问题是:是否有可能以某种方式避免这种例外?可能是配置。提前谢谢你
更新:忘记说从池中借用对象后,我在运行命令之前设置了connection.readFrom(ReadFrom.SLAVE)

GenericObjectPoolConfig config = fromRedisConfig(properties);
List<RedisURI> nodes = new ArrayList<>(properties.getUrl().length);
for (String url : properties.getUrl()) {
  nodes.add(RedisURI.create(url));
}
return ConnectionPoolSupport.createGenericObjectPool(
        () -> MasterSlave.connect(redisClient, new ByteArrayCodec(), nodes), config);

最佳答案

问题是我试图设置数据,这是唯一可能的主节点。所以主仆没有问题。获取数据工作正常

07-26 05:52