1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
When connecting to Redis with cluster mode enabled, many clients will try to connect to all cluster nodes on initialization. The replica node(s) will not be reachable given the network setup that you have described. If you disable this behaviour of pre-connecting to all nodes, you should be able to successfully connect to the individual node that you have opened a tunnel onto.
Here is an example of how to connect without attempting to connect to all nodes, using the popular ioredis library:
let Redis = require('ioredis');
let cluster = new Redis.Cluster([{
host: 'localhost',
port: 6378
}], {
lazyConnect: true
});
async function main() {
await cluster.set("foo", "bar");
console.log(await cluster.get("foo"));
cluster.disconnect();
}
main();
NB: If more than one shard was setup in the cluster, this method would experience issues when hitting a shard on a different node to the node that you have tunnelled to.
답변함 일 년 전
관련 콘텐츠
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 2년 전