问题结论&解决方案
防火墙拦截导致,找到服务的端口,然后在防火墙中配置给端口放行,同时设置重启后也生效
在root权限下执行:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
然后执行(即时生效,重启失效):
service iptables stop
service iptables start
要想重启后也生效,则执行:
chkconfig iptabels on
chkconfig iptabels off
问题场景
给客户线上排查问题OA服务的应用获取登录框加载异常缓慢,客户有部署Redis,通过分析线程日志发现并结合业务日志锁定到如下报错内容,JedisConnectionException: Could not get a resource from the pool
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:53)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
at redis.clients.jedis.Connection.connect(Connection.java:207)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1767)
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:106)
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
at redis.clients.util.Pool.getResource(Pool.java:49)
问题分析
根据日志直接判断应该是redis服务不可用,那么要么是服务本身有问题,比如没启动,要么就是服务不可达。然后借助网上的经验判断有了思路,可能是防火墙拦截的原因,客户最近有重启过服务,可能防火墙配置好了,重启又还原了导致
防火墙检测的相关命令
1、查看已经开放的端口
firewall-cmd --list-ports
2、放行端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
--zone 作用域
--permanent 永久生效
3、重启防火墙
systemctl reload firewalld
4、查询指定端口是否开启成功
firewall-cmd --query-port=5601/tcp
5、停止防火墙
systemctl stop firewalld
或:
systemctl stop firewalld.service
6、启动防火墙
systemctl start firewalld
或:
systemctl start firewalld.service
7、查看防火墙是否在运行
systemctl status firewalld