Spring XD分布式模式Redis Sentinel

时间:2015-12-31 20:02:49

标签: redis spring-xd

我试图在2个Ubuntu VM上以distruibuted模式运行spring xd。我的目标是在运行spring xd的其中一个VM上部署一个模块,并使其对另一个VM(hostname:container1)上的容器可见。在主VM(主机名:xd-admin)上,我在servers.yml中使用此配置运行redis-sentinel

spring:
  redis:
   port: 6379
   host: 127.0.0.1
   sentinel:
     master: 127.0.0.1:26379
     nodes: 127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381

在container1中,我在servers.yml

中有以下内容
spring:
  redis:
   port: 6379
   host: 127.0.0.1
   sentinel:
     master:  xd-admin:26379
     nodes: 127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381

zk:
  namespace: xd
  client:
     connect: xd-admin:2181
     sessionTimeout: 60000
     connectionTimeout: 30000
     initialRetryWait: 1000
     retryMaxAttempts: 3

当我在xd-admin主机上运行xd-container时,我得到了

Caused by: redis.clients.jedis.exceptions.JedisException: Can connect to sentinel, but 127.0.0.1:26379 seems to be not monitored...
        at redis.clients.jedis.JedisSentinelPool.initSentinels(JedisSentinelPool.java:150) ~[jedis-2.6.2.jar:na]
        at redis.clients.jedis.JedisSentinelPool.<init>(JedisSentinelPool.java:69) ~[jedis-2.6.2.jar:na]
        at redis.clients.jedis.JedisSentinelPool.<init>(JedisSentinelPool.java:47) ~[jedis-2.6.2.jar:na]
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisSentinelPool(JedisConnectionFactory.java:215) ~[spring-data-redis-1.5.0.RELEASE.jar:1.5.0.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createPool(JedisConnectionFactory.java:202) ~[spring-data-redis-1.5.0.RELEASE.jar:1.5.0.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:195) ~[spring-data-redis-1.5.0.RELEASE.jar:1.5.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
        ... 30 common frames omitted

当我在container1主机上运行xd-container时,我得到了

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: All sentinels down, cannot determine where is 192.168.33.10:26379 master is running...
        at redis.clients.jedis.JedisSentinelPool.initSentinels(JedisSentinelPool.java:153)
        at redis.clients.jedis.JedisSentinelPool.<init>(JedisSentinelPool.java:69)
        at redis.clients.jedis.JedisSentinelPool.<init>(JedisSentinelPool.java:47)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisSentinelPool(JedisConnectionFactory.java:215)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createPool(JedisConnectionFactory.java:202)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:195)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        ... 31 more

我在xd-admin上运行了zookeeper和rabbit-mq。我在container1上运行了redis。我知道xd-admin可以从container1访问,因为我在xd-admin上安装了apache2,当我从container1运行curl xd-admin时收到响应。如何正确配置redis和/或我的servers.yml以便我的容器进行通信?

1 个答案:

答案 0 :(得分:0)

在我的servers.yml文件中,我评论了redis.sentinel及其子项,异常消失了。