Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Swarm Redis and Sentinel with master - slave replication IP resolution client failure

I am running into an issue and I am not sure how to resolve this. My redis sentinel eco system is as follows:

3 sentinel cluster --> Managing 1 master and 2 slaves using docker-compose

I have created a docker overlay network for the eco system and using docker stack deploy to run the docker compose yml. The redis-cli on each node displays the correct INFO configuration. However external clients are running into an issue.

When I supply the sentinel address to the client application (in my case it's a spring redis app) I am getting the overlay network's internal IP address for the master redis. This is not recognizable to the client and it fails. How can I get an IP address that can be resolved externally? Secondly is it even possible since docker swarm manages the IP addresses on the overlay network. Is this the right approach i.e. using docker swarm? Any feedback would be greatly appreciated.

version: '3'

services:
  redis-master:
    image: redis:latest
    volumes:
      - "/docker-service-data/master:/data"
      - /redis-docker/redis.conf:/etc/redis.conf
    command: redis-server /etc/redis.conf
    ports:
      - 6379:6379
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
    networks:
       - rev_proxy
  redis-slave:
    image: redis:latest
    volumes:
      - "/docker-service-data/slave:/data"
      - /redis-docker/redis.conf:/etc/redis.conf
    command: redis-server /etc/redis.conf --slaveof redis-master 6379 
    deploy:
      mode: replicated
      replicas: 2
      placement:
        constraints: [node.role == worker]
    networks:
       - rev_proxy
  sentinel_1:
    image: <private-registry>/redis-sentinel:1
    deploy:
      mode: replicated
      replicas: 3
    ports:
      - 26379:26379
    depends_on:
      - redis-master
    networks:
      - rev_proxy
networks:
  rev_proxy:
     external:
       name: rev_proxy_net

redis.conf:

I have commented the bind statement so that the replica listens to all interfaces protected mode is no There is no authentication at this point.

sentinel.conf:

sentinel monitor master redis-master 6379 2
sentinel down-after-milliseconds master 1000
sentinel parallel-syncs master 1
sentinel failover-timeout master 1000
like image 653
sharman Avatar asked Aug 27 '17 05:08

sharman


People also ask

How do I connect to Redis Sentinel?

Commands. Use “redis-cli” with port 26379 to connect to sentinel. Note: you always want to tail the /var/log/sentinel/sentinel. log on all sentinels to see the cluster interaction.

How do I stop Redis Sentinel?

Because Redis Sentinel is not storing any data that really needs, you should be able to kill it without worry. You received this message because you are subscribed to the Google Groups "Redis DB" group. To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u... @googlegroups.com.

What is Sentinel mode in Redis?

Redis Sentinel is the high-availability solution for open-source Redis server. It provides monitoring of all Redis nodes and automatic failover should the master node become unavailable. This guide provides a sample configuration for a three-node Redis cluster.

How do I know if Redis Sentinel is running?

You can also use monitor to see what Sentinel is doing: $ redis-cli -p 6379 monitor OK 1546981642.808843 [0 127.0. 0.1:54765] "PING" 1546981642.866671 [0 127.0. 0.1:54765] "PUBLISH" "__sentinel__:hello" "127.0.


1 Answers

You might need version: '3.3' and endpoint_mode: vip option. Refer to this link, https://docs.docker.com/compose/compose-file/#endpoint_mode

like image 101
sMiLo Avatar answered Sep 21 '22 03:09

sMiLo