I am trying to setup Redis cluster. The configuration is the bare minimum setup of the cluster. I am using docker-compose to run my application. But it always throwing the following error. However, when I connect Redis to an external tool it gets connected successfully.
ClusterAllFailedError: Failed to refresh slots cache
const db = new Redis.Cluster([{
host: "redis",
port: 6379
}])
I can see Redis master and replica instance on docker container
master
container ID - 8a7f4d9fc877
image - bitnami/redis:latest
ports - 0.0.0.0:32862->6379/tcp
name - mogus_redis_1
slave
container ID - f04433e04de5
image - bitnami/redis:latest
ports - 0.0.0.0:32863->6379/tcp
name - mogus_redis-replica_1
yml file
redis:
image: "bitnami/redis:latest"
ports:
- 6379
environment:
REDIS_REPLICATION_MODE: master
ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- redis-data:/bitnami
redis-replica:
image: "bitnami/redis:latest"
ports:
- 6379
depends_on:
- redis
environment:
REDIS_REPLICATION_MODE: slave
REDIS_MASTER_HOST: redis
REDIS_MASTER_PORT_NUMBER: 6379
ALLOW_EMPTY_PASSWORD: "yes"