首页 > 代码库 > 无法连接redis问题
无法连接redis问题
今天加入redis但连接一直报无法获取到连接,看配置
今天加入redis但连接一直报无法获取到连接,看配置
```
<bean id="redisResources" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>classpath*:jedis.properties</value>
</list>
</constructor-arg>
</bean>
<bean id="redisProp" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="http://www.mamicode.com/11" />
<property name="ignoreUnresolvablePlaceholders" value="http://www.mamicode.com/true" />
<property name="locations" ref="redisResources" />
</bean>
<bean id="sentinelConfig" class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
<constructor-arg name="master" value="http://www.mamicode.com/mymaster" />
<constructor-arg name="sentinelHostAndPorts">
<set>
<!-- <value>abcd</value> -->
<value>192.168.82.242</value>
</set>
</constructor-arg>
</bean>
jedis.properties
redis.ip=192.168.82.224
#Port
redis.port=6379
redis.timeout=5000
redis.password=chelizi
都是正确的
登录242服务器,查看sentinal的配置
# The valid charset is A-z 0-9 and the three characters ".-_".
sentinel monitor mymaster 127.0.0.1 6379 2
也是对的,怎么连不进了?
用wireshark跟踪一下网络包,发现连接redis的时候竟然是去连192.168.63.247, why?
赶紧登录服务器
./redis-cli -p 26379
执行命令
SENTINEL masters
返回
1) 1) "name"
2) "mymaster"
3) "ip"
4) "192.168.63.247"
5) "port"
6) "6379"
shit, 看来是改了配置之后没有重启sentinal, 执行命令
先移除之前的监控
127.0.0.1:26379> SENTINEL REMOVE mymaster
OK
再添加监控
127.0.0.1:26379> SENTINEL MONITOR mymaster 192.168.82.242 6379 2
OK
127.0.0.1:26379> SENTINEL masters
1) 1) "name"
2) "mymaster"
3) "ip"
4) "192.168.82.242"
5) "port"
6) "6379"
问题解决
无法连接redis问题