Could not connect ot Redis No route to host问题解决

局域网内访问另外一台服务器上的redis 报错: Could not connect to Redis No route to host 问题解决:

发现是防火墙问题。

于是设置:

iptables -N REDIS

iptables -A REDIS -s 192.168.10.1 -j ACCEPT

iptables -A REDIS -s 192168.10.2 -j ACCEPT

iptables -A REDIS -j LOG --log-prefix "unauth-redis-access"

iptables -A REDIS -j REJECT --reject-with icmp-port-unreachable

iptables -I INPUT -p tcp --dport 6379 -j REDIS

或者

sudo iptables -F #删除过滤规则,不建议

 

轻松解决。

 

如下测试

ndscbigdata@ubuntu-bigdata-3:/usr/local/bin$ redis-cli -h "192.168.2.195" -p 6379
Could not connect to Redis at 192.168.2.195:6379: No route to host
not connected> quit
ndscbigdata@ubuntu-bigdata-3:/usr/local/bin$ redis-cli -h "192.168.2.195" -p 6379
Could not connect to Redis at 192.168.2.195:6379: No route to host
not connected> quit
ndscbigdata@ubuntu-bigdata-3:/usr/local/bin$ redis-cli -h "192.168.2.195" -p 6379
192.168.2.195:6379> select 10
(error) NOAUTH Authentication required.
192.168.2.195:6379> quit
ndscbigdata@ubuntu-bigdata-3:/usr/local/bin$ redis-cli -h 192.168.2.195 -p 6379 -a ndscndscndsc
192.168.2.195:6379> select 10
OK
192.168.2.195:6379[10]> keys *
1) "189234234"
2) "123"
192.168.2.195:6379[10]> 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值