Connect to redis Sentinel with Python leads to MasterNotFound Error

Viewed 328

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?

0 Answers
Related