是否可以启动单节点/容器redis集群?
我正在使用bitnami/redis-cluster
映像,当我使用以下命令启动master时
docker run --name redis-cluster -e ALLOW_EMPTY_PASSWORD=yes -e REDIS_NODES=1 -e REDIS_PORT_NUMBER=30001 -p 30001:30001 -e REDIS_REPLICATION_MODE=master bitnami/redis-cluster:latest
有一个节点,但当我尝试获取群集信息时
127.0.0.1:30001> CLUSTER INFO
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:1
cluster_size:0
cluster_current_epoch:0
cluster_my_epoch:0
cluster_stats_messages_sent:0
cluster_stats_messages_received:0
当我使用设置为localhost:30001的redis集群IP启动应用程序时,它会给出如下错误
[] [] [2021-11-25 15:30:29] [ WARN] [] - [lettuce-nioEventLoop-4-3] - [ClusterTopologyRefresh] - Unable to connect to 172.17.0.4:30001 io.netty.channel.ConnectTimeoutException: connection timed out: /172.17.0.4:30001
我不确定它为什么要尝试连接到172.17.0.4。
当我尝试在python中连接时
>>> from rediscluster import RedisCluster
>>> startup_nodes = [{"host": "127.0.0.1", "port": "30001"}]
>>> rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True)
>>> rc.set("foo", "bar")
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/rediscluster/connection.py", line 376, in get_master_node_by_slot
return self.nodes.slots[slot][0]
KeyError: 12182
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 1801, in set
return self.execute_command('SET', *pieces)
File "/usr/local/lib/python3.8/site-packages/rediscluster/client.py", line 555, in execute_command
return self._execute_command(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/rediscluster/client.py", line 643, in _execute_command
raise e
File "/usr/local/lib/python3.8/site-packages/rediscluster/client.py", line 606, in _execute_command
node = self.connection_pool.get_master_node_by_slot(slot)
File "/usr/local/lib/python3.8/site-packages/rediscluster/connection.py", line 378, in get_master_node_by_slot
raise SlotNotCoveredError('Slot "{slot}" not covered by the cluster. "skip_full_coverage_check={skip_full_coverage_check}"'.format(
rediscluster.exceptions.SlotNotCoveredError: Slot "12182" not covered by the cluster. "skip_full_coverage_check=False"
1条答案
按热度按时间9rbhqvlz1#
我们可以使用Grokzen/docker-redis-cluster,它本身就支持这个功能。
updateGrokzen软件包需要root权限才能运行。目前没有修复此问题的计划。
我最终使用了这样的bitnami图像