How to connect to a Bitnami Redis Cluster from another host?

389 Views Asked by At

I have a configuration in my docker-compose.yml file, and I'm using Bitnami. Everything runs correctly, and the cluster is created successfully. I have a Java application where I use Jedis to connect to the Redis cluster. When I connect to the cluster from the same host as the app, it works fine. However, when I try to run the app from another host (on the same network) pointing to the same Redis cluster, it fails to connect. It's important to mention that I can connect perfectly to any of the cluster nodes' CLI from the other host. But when I attempt to connect from the app or even from DataGrip, I get an error; it's simply impossible for me to establish a connection. I've tried various configurations, but unfortunately, I haven't been able to resolve it. Here's my docker-compose.yml file:

version: '3.8'

services:   redis-node-0:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6385:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_BIND=192.168.100.12'

  redis-node-1:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6380:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_BIND=192.168.100.12'

  redis-node-2:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6381:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_BIND=192.168.100.12'

  redis-node-3:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6382:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_BIND=192.168.100.12'

  redis-node-4:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6383:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_BIND=192.168.100.12'

  redis-node-5:
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - '6384:6379'
    environment:
      - 'ALLOW_EMPTY_PASSWORD=yes'
      - 'REDIS_CLUSTER_REPLICAS=1'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_CLUSTER_CREATOR=yes'
      - 'REDIS_BIND=192.168.100.12'

volumes:   redis-cluster_data-0:
    driver: local   redis-cluster_data-1:
    driver: local   redis-cluster_data-2:
    driver: local   redis-cluster_data-3:
    driver: local   redis-cluster_data-4:
    driver: local   redis-cluster_data-5:
    driver: local`

Now, this is what I get when I run 'docker ps' from the terminal: Docker images cluster nodes

I need help overcoming this issue

– how to connect to a Bitnami Redis cluster from another host.

I would expect to be able to connect to the Bitnami Redis cluster from any other host within the same network. However, when attempting to connect from another host, the app displays the following exception:

redis.clients.jedis.exceptions.JedisClusterOperationException: Cluster retry deadline exceeded.
    at redis.clients.jedis.executors.ClusterCommandExecutor.executeCommand(ClusterCommandExecutor.java:124) ~[jedis-5.0.2.jar:na]
    at redis.clients.jedis.UnifiedJedis.executeCommand(UnifiedJedis.java:244) ~[jedis-5.0.2.jar:na]
    at redis.clients.jedis.UnifiedJedis.llen(UnifiedJedis.java:1074) ~[jedis-5.0.2.jar:na]
    at org.paic.insertdata.component.Worker.smResponseWorker(Worker.java:125) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-6.0.12.jar:6.0.12]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) ~[spring-aop-6.0.12.jar:6.0.12]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-6.0.12.jar:6.0.12]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751) ~[spring-aop-6.0.12.jar:6.0.12]
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-6.0.12.jar:6.0.12]
    at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:na]
0

There are 0 best solutions below