containers icon indicating copy to clipboard operation
containers copied to clipboard

[bitnami/redis-cluster] After changing portmapping, redis-cluster doesnot work

Open bryanxtong opened this issue 1 year ago • 12 comments

Name and Version

bitnami/redis-cluster:7.2

What architecture are you using?

amd64

What steps will reproduce the bug?

With different port mapping, It gives different results and when using all the default redis port 6379 for container, It is working but It doesnot work when using different redis port in different containers, please refer to attached for full files which includes the correct and wrong file, the only difference is the port mapping.

---It is working----

version: '3'
services:
  redis-node-0:
    user: root
    container_name: redis-node-0
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - 6379:6379
      - 16379:16379
    volumes:
      - ./redis_data-0:/bitnami/redis/data
    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_CLUSTER_DYNAMIC_IPS=no'
      - 'REDIS_CLUSTER_ANNOUNCE_IP=192.168.71.4'
      - 'REDIS_CLUSTER_ANNOUNCE_PORT=6379'
      - 'REDIS_CLUSTER_ANNOUNCE_BUS_PORT=16379'
    networks:
      redis-cluster-network:
        ipv4_address: 172.20.0.2
.....

---Not working---

version: '3'
services:
  redis-node-0:
    user: root
    container_name: redis-node-0
    image: docker.io/bitnami/redis-cluster:7.2
    ports:
      - 6380:6380
      - 16380:16380
    volumes:
      - ./redis_data-0:/bitnami/redis/data
    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_PORT_NUMBER=6380'
      - 'REDIS_CLUSTER_DYNAMIC_IPS=no'
      - 'REDIS_CLUSTER_ANNOUNCE_IP=192.168.71.4'
      - 'REDIS_CLUSTER_ANNOUNCE_PORT=6380'
      - 'REDIS_CLUSTER_ANNOUNCE_BUS_PORT=16380'
    networks:
      redis-cluster-network:
        ipv4_address: 172.20.0.2
....

The error is as below

redis-node-5  | Node redis-node-0 not ready, waiting for all the nodes to be ready...
redis-node-5  | Could not connect to Redis at redis-node-0:6385: Connection refused
redis-node-5  | Node redis-node-0 not ready, waiting for all the nodes to be ready...
redis-node-5  | Could not connect to Redis at redis-node-0:6385: Connection refused
redis-node-5  | Node redis-node-0 not ready, waiting for all the nodes to be ready...
redis-node-5  | Could not connect to Redis at redis-node-0:6385: Connection refused
redis-node-5  | Node redis-node-0 not ready, waiting for all the nodes to be ready...
redis-node-5  | Could not connect to Redis at redis-node-0:6385: Connection refused
redis-node-5  | Node redis-node-0 not ready, waiting for all the nodes to be ready...

What is the expected behavior?

No response

What do you see instead?

It should create redis cluster successfully whatever port mapping we are using

Additional information

No response

bryanxtong avatar May 20 '24 02:05 bryanxtong

docker-compose-redis-cluster.zip docker-compose files

bryanxtong avatar May 20 '24 02:05 bryanxtong

Hi @bryanxtong,

I just made a quick test, changed the default port in the cluster using the default docker-compose.yml file

diff --git a/bitnami/redis-cluster/docker-compose.yml b/bitnami/redis-cluster/docker-compose.yml
index 9f17c63b48f..c5d565367be 100644
--- a/bitnami/redis-cluster/docker-compose.yml
+++ b/bitnami/redis-cluster/docker-compose.yml
@@ -10,6 +10,9 @@ services:
     environment:
       - 'REDIS_PASSWORD=bitnami'
       - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
+      - REDIS_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
   redis-node-1:
     image: docker.io/bitnami/redis-cluster:7.2
@@ -18,6 +21,9 @@ services:
     environment:
       - 'REDIS_PASSWORD=bitnami'
       - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
+      - REDIS_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
   redis-node-2:
     image: docker.io/bitnami/redis-cluster:7.2
@@ -26,6 +32,9 @@ services:
     environment:
       - 'REDIS_PASSWORD=bitnami'
       - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
+      - REDIS_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
   redis-node-3:
     image: docker.io/bitnami/redis-cluster:7.2
@@ -34,6 +43,9 @@ services:
     environment:
       - 'REDIS_PASSWORD=bitnami'
       - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
+      - REDIS_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
   redis-node-4:
     image: docker.io/bitnami/redis-cluster:7.2
@@ -42,6 +54,9 @@ services:
     environment:
       - 'REDIS_PASSWORD=bitnami'
       - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
+      - REDIS_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
   redis-node-5:
     image: docker.io/bitnami/redis-cluster:7.2
@@ -59,6 +74,9 @@ services:
       - '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_PORT_NUMBER=6380
+      - REDIS_MASTER_PORT_NUMBER=6380
+      - REDIS_CLUSTER_ANNOUNCE_PORT=6380
 
 volumes:
   redis-cluster_data-0:

and everything worked as expected

# Replication
role:master
connected_slaves:1
slave0:ip=172.20.0.2,port=6380,state=online,offset=280,lag=1

Could you please take a look at this?

jotamartos avatar May 23 '24 13:05 jotamartos

Yes, if all the container shares the same port, It works. My problem is that why different ports in different container port doesnot work.

bryanxtong avatar May 23 '24 13:05 bryanxtong

docker-compose-wrong.zip

try this version which different ports are set for different containers

bryanxtong avatar May 23 '24 13:05 bryanxtong

Hi @bryanxtong,

I'm afraid that that configuration is not supported in the solution. Would like to contribute? You can follow our contributing guidelines and improve the solution based on your needs. Our team will be more than happy to review the changes.

However, I also offer you a "solution", why don't you use the default configuration (port 6379) and expose each container using a different port in the host machine using the ports field? Would that work for you?

jotamartos avatar May 27 '24 09:05 jotamartos

Once I used others docker compose for testing redis cluster with different ports and then switch to bitnami later. Ok since It is not an issue,you can close it now.

bryanxtong avatar May 27 '24 12:05 bryanxtong

By configuring the port in REDIS_NODES, I was able to launch the Redis cluster on a different port.

- 'REDIS_NODES=redis-node-0:port0 redis-node-1:port1 redis-node-2:port2 redis-node-3:port3 redis-node-4:port4 redis-node-5:port5'

takkyuuplayer avatar Jun 10 '24 01:06 takkyuuplayer

By configuring the port in REDIS_NODES, I was able to launch the Redis cluster on a different port.

- 'REDIS_NODES=redis-node-0:port0 redis-node-1:port1 redis-node-2:port2 redis-node-3:port3 redis-node-4:port4 redis-node-5:port5'

I tried but It doesnot work, please refer to attachment. docker-compose-diff-port.zip

bryanxtong avatar Jun 10 '24 05:06 bryanxtong

When you set REDIS_CLUSTER_ANNOUNCE_IP, REDIS_NODES must be

REDIS_NODES=192.168.71.4:6380 ...

The REDIS_NODES items should match the result of redis-cli -c -p 6380 cluster nodes

takkyuuplayer avatar Jun 11 '24 08:06 takkyuuplayer

When you set REDIS_CLUSTER_ANNOUNCE_IP, REDIS_NODES must be

REDIS_NODES=192.168.71.4:6380 ...

The REDIS_NODES items should match the result of redis-cli -c -p 6380 cluster nodes

Hi takkyuuplayer,

Thanks for the answer and It is working. I provided the attachment for both hostname(needs hosts file config) and ip for other people who may encounter the same issue and this version supported external access by java.

and now you can help close the ticket.

docker-compose-redis-cluster-working.zip

Br Bryan

bryanxtong avatar Jun 11 '24 12:06 bryanxtong

Thanks for providing that useful information @takkyuuplayer. It'll be really helpful for all those users who want to use different ports during the deployment

jotamartos avatar Jun 12 '24 07:06 jotamartos

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar Jun 28 '24 01:06 github-actions[bot]

Hi @bryanxtong ,

and now you can help close the ticket.

docker-compose-redis-cluster-working.zip

This link is broken now. If possible can you reupload the working zip? Thanks in advance

senthalan avatar Sep 10 '24 06:09 senthalan

Hi @bryanxtong ,

and now you can help close the ticket. docker-compose-redis-cluster-working.zip

This link is broken now. If possible can you reupload the working zip? Thanks in advance

docker-compose-redis-cluster-working.zip

bryanxtong avatar Sep 10 '24 11:09 bryanxtong