gpt4 book ai didi

java - 如何在集群模式下运行docker redis?

转载 作者:IT王子 更新时间:2023-10-29 06:08:27 25 4
gpt4 key购买 nike

我启动了我的 redis docker 容器:

docker run --privileged=true -p 6379:6379 --name TestRedis -d redis

当我尝试在集群模式下从 Spring Redis 使用它时,出现错误:

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled
at redis.clients.jedis.Protocol.processError(Protocol.java:127)
at redis.clients.jedis.Protocol.process(Protocol.java:161)
at redis.clients.jedis.Protocol.read(Protocol.java:215)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:285)
at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:291)
at redis.clients.jedis.Jedis.clusterSlots(Jedis.java:3376)
at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:54)
at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:39)
at redis.clients.jedis.JedisClusterConnectionHandler.<init>(JedisClusterConnectionHandler.java:17)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:20)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:15)
at redis.clients.jedis.BinaryJedisCluster.<init>(BinaryJedisCluster.java:41)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:83)
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createCluster(JedisConnectionFactory.java:306)
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createCluster(JedisConnectionFactory.java:280)
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:241)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 110 common frames omitted

我需要做什么才能使其以集群方式运行?

最佳答案

当你只是像你一样运行redis Docker镜像时,它会根据它的Dockerfile和内置配置启动,它没有开启集群。 Chris Tanner 向您指出的存储库使用相同的基础镜像,但添加了激活集群的配置。但是,您需要克隆该存储库并构建镜像,然后才能运行它。存储库在自述文件中有关于如何构建和运行它的很好的说明,尽管 docker run 出于某种原因遗漏了图像名称。克隆 repo,cd 到其中,然后执行以下操作:

docker build -t testredis/redis-cluster .
docker run -i -t -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -p 7006:7006 -p 7007:7007 testredis/redis-cluster

这将使集群运行,您可以将客户端指向端口 7000。

关于java - 如何在集群模式下运行docker redis?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49582544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com