当前位置: 移动技术网 > IT编程>数据库>Redis > RedisDesktopManager无法远程连接Redis的完美解决方法

RedisDesktopManager无法远程连接Redis的完美解决方法

2019年05月28日  | 移动技术网IT编程  | 我要评论

linux环境:ubuntu16.04
redis服务端版本:3.2.6
redis客户端下载链接:

省略linux系统安装redis教程,网上安装教程很多;建议用tar.gz包安装

redis官网tar.gz下载地址:wget

下载redisdesktopmanager客户端,输入服务器ip地址,端口(缺省值:6379);点击test connection按钮测试连接,连接失败!

链接失败

什么问题呢?原因是redis默认只支持本地链接,输入进程命令查看得知(127.0.0.1:7000)

./redis-cli shutdown
could not connect to redis at 127.0.0.1:6379: connection refused
could not connect to redis at 127.0.0.1:6379: connection refused
ps -ef | grep redis
wl        12046   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7001 [cluster]
wl        12047   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7000 [cluster]
wl        12048   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7004 [cluster]
wl        12049   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7002 [cluster]
wl        12050   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7003 [cluster]
wl        12059   1416  0 10:50 ?        00:00:20 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server 127.0.0.1:7005 [cluster]
wl        14070   8680  0 13:52 pts/21   00:00:00 grep --color=auto redis

把集群的redis全部kill命令全部kill掉,问题解决:编辑redis.conf配置文件;注释掉61行本地链接限制以及80行配置修改为no

61 # bind 127.0.0.1
80 protected-mode no

读取最新配置文件并重启,查看redis进程情况!都开放ip链接权限了,怎么还是127.0.0.1:6379!!再查看进程情况:

wl@ubuntu:~/hproj/redis-3.0/cluster$ ./redis-start.sh 
wl@ubuntu:~/hproj/redis-3.0/cluster$ ps -ef | grep redis
wl  14200 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7000 [cluster]
wl  14201 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7002 [cluster]
wl  14202 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7001 [cluster]
wl  14205 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7004 [cluster]
wl  14207 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7003 [cluster]
wl  14211 1416 0 14:00 ?  00:00:00 /home/wl/hproj/redis-3.0/redis-3.2.6/src/redis-server *:7005 [cluster]
wl  14225 8680 0 14:01 pts/21 00:00:00 grep --color=auto redis

哇塞,*.6379,这意味着已经成功开放ip访问权限了。万事俱备,只欠点击redisdesktopmanager客户端测试链接按钮了。好,走起。

当你信心满满的时候,现实总泼你一盆冷水来清醒!链接失败,链接失败,我都不好意思截图上传了!!这又是闹哪样啊?还让我活不???

左思右想,突然,我想到一个词——防火墙

[root@karle src]# service iptables status
表格:filter
chain input (policy accept)
num target  prot opt source    destination   
1 accept  all -- 0.0.0.0/0   0.0.0.0/0   state related,established 
2 accept  icmp -- 0.0.0.0/0   0.0.0.0/0   
3 accept  all -- 0.0.0.0/0   0.0.0.0/0   
4 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:22 
5 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:8080 
6 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:80 
7 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:3306 
8 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:15672 
9 reject  all -- 0.0.0.0/0   0.0.0.0/0   reject-with icmp-host-prohibited

编辑linux防火墙

[root@karle src]# vi /etc/sysconfig/iptables

加入防火墙规则:-a input -m state –state new -m tcp -p tcp –dport 6379 -j accept

[root@karle src]# service iptables status

表格:filter

chain input (policy accept)
num target  prot opt source    destination   
 accept  all -- 0.0.0.0/0   0.0.0.0/0   state related,established 
 accept  icmp -- 0.0.0.0/0   0.0.0.0/0   
 accept  all -- 0.0.0.0/0   0.0.0.0/0   
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:22 
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:8080 
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:80 
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:3306 
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:15672 
 accept  tcp -- 0.0.0.0/0   0.0.0.0/0   state new tcp dpt:6379 
 reject  all -- 0.0.0.0/0   0.0.0.0/0   reject-with icmp-host-prohibited

重启linux防火墙

[root@karle src]# service iptables restart

点击 “测试连接” 按钮测试连接,显示 “连接redis 服务器成功”,问题解决了。

总结

以上所述是小编给大家介绍的redisdesktopmanager无法远程连接redis解决方法,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网