RedisDesktopManager无法远程连接Redis怎么办

37次阅读
没有评论

共计 4080 个字符,预计需要花费 11 分钟才能阅读完成。

自动写代码机器人,免费开通

丸趣 TV 小编给大家分享一下 RedisDesktopManager 无法远程连接 Redis 怎么办,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

Linux 环境:ubuntu16.04
Redis 服务端版本:3.2.6
Redis 客户端下载链接:https://redisdesktop.com/download

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

Redis 官网 tar.gz 下载地址:wget http://xiazai.jb51.net/201803/yuanma/redis-3.2.6(jb51.net).rar

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

RedisDesktopManager 无法远程连接 Redis 怎么办

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

wl@ubuntu:~/hproj/redis-3.0/redis-3.2.6/src$ ./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
wl@ubuntu:~/hproj/redis-3.0/redis-3.2.6/src$ 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 怎么办

以上是“RedisDesktopManager 无法远程连接 Redis 怎么办”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注丸趣 TV 行业资讯频道!

向 AI 问一下细节

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-04发表,共计4080字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)