Redis集群应用报错:
redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster
具体异常信息如下:
redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster
at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnection(JedisSlotBasedConnectionHandler.java:61)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnectionFromSlot(JedisSlotBasedConnectionHandler.java:78)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:113)
at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:30)
at redis.clients.jedis.JedisCluster.del(JedisCluster.java:1216)
at com.jt.controller.UserController.logout(UserController.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServle
异常:Redis集群的node(节点)连接失败;
造成原因:<1>检查Redis是否正常启动(如图正常)
Linux命令:ps -ef | grep redis
<2>检查防火墙是否关闭(Linux与windows均需要关闭);
命令:Centos 6/6.4/6.5
永久关闭防火墙: chkconfig iptables off
永久打开防火墙: chkconfig iptables on
临时关闭防火墙:service iptables stop
临时打开防火墙:service iptables start
查看防火墙状态:service iptables status
命令:Centos 7及以上
启动: systemctl start firewalld.service (.service可以省略)
关闭: systemctl stop firewalld.service
查看状态: systemctl status firewalld.service
开机禁用 : systemctl disable firewalld.service
开机启用 : systemctl enable firewalld.service
<2>Redis集群的node节点IP异常(本文便是由此错误造成)
我的Linux系统IP:
源文件配置节点信息:
改正为: