5

I have the following setup with Docker-Compose:

version: '2'

services:
  redis-sentinel:
    image: docker.io/bitnami/redis-sentinel:6.2
    volumes:
      - redis-sentinel_data:/bitnami
  redis:
    image: docker.io/bitnami/redis:6.2
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - redis_data:/bitnami
volumes:
  redis-sentinel_data:
    driver: local
  redis_data:
    driver: local

The name is my master should be mymaster:

(base)>docker exec redis_redis-sentinel_1 redis-cli -p 26379 sentinel get-master-addr-by-name mymaster
192.168.80.3
6379

I try to connect via Python:

from redis.sentinel import Sentinel

sentinel = Sentinel([("localhost", 26379)], socket_timeout=0.5)
r = sentinel.master_for("mymaster")

This results in the following error.

redis.sentinel.MasterNotFoundError: No master found for 'mymaster'

What I tried:

So what am I doing wrong here?

Data Mastery
  • 1,555
  • 4
  • 18
  • 60
  • What does `sentinel.discover_master('mymaster')` return? I would run `monitor` on the redis-cli to see what commands redispy client is sending to the server. – Max Feb 22 '22 at 20:19
  • In my company we actually solved it by adding a service in a container with a script.py entrypoint. It seems to be a docker network issue, but we were not able to solve it – Data Mastery Feb 23 '22 at 15:20

0 Answers0