RedisDesktopManager無法遠端連線Redis解決方法
下載RedisDesktopManager客戶端,輸入伺服器IP地址,埠(預設值:6379);點選 “連線測試” 按鈕測試連線,連線失敗!
什麼問題呢?原因是Redis預設只支援本地連結,輸入程序命令檢視得知(127.0.0.1:7000)
[email protected]:~/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[email protected]:~/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!!再檢視程序情況:
[email protected]:~/hproj/redis-3.0/cluster$ ./redis-start.sh
[email protected]:~/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
哇塞,*.7000,這意味著已經成功開放IP訪問許可權了。萬事俱備,只欠點選RedisDesktopManager客戶端測試連結按鈕了。
防火牆問題
[[email protected] 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防火牆
[[email protected] src]# vi /etc/sysconfig/iptables
加入防火牆規則:-A INPUT -m state –state NEW -m tcp -p tcp –dport 6379 -j ACCEPT
[[email protected] 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 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:6379
10 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
重啟Linux防火牆
[[email protected] src]# service iptables restart
點選 “測試連線” 按鈕測試連線,顯示 “連線Redis 伺服器成功”,問題解決了。
點選 "好" 按鈕,進行操作,出現如下:
參考文章:http://blog.csdn.net/qq_19260029/article/details/77920423