我试图连接到我的redis集群容器,但是不能。我的脚本总是卡住,每次执行它都没有任何响应。下面是我的python脚本:
import redis
r = redis.RedisCluster(
host='127.0.0.1',
port=36379
)
r.set('foo', 'bar')
value = r.get('foo')
print(value)
这里是我的redis集群的docker compose:
version : '3.4'
services:
redis:
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
ports:
- 36379:6379
redis-node-1:
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
redis-node-2:
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
redis-node-3:
# <<: *redis-common
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
redis-node-4:
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
redis-node-5:
image: docker.io/bitnami/redis-cluster:7.0
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=redis redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
- 'REDIS_CLUSTER_REPLICAS=1'
- 'REDIS_CLUSTER_CREATOR=yes'
depends_on:
- redis
- redis-node-1
- redis-node-2
- redis-node-3
- redis-node-4
有人知道为什么吗?
我尝试了各种redis客户端库,如redis-py-cluster和redis,但结果仍然相同
1条答案
按热度按时间0mkxixxg1#
你试过用这种方法输入节点吗?我想你可以给予一试。