报错:
(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
解析:
Redis配置文件中此项【protected-mode yes】为yes,表示不接受使用除环回地址外的链接,解决方法以在返回的错误中给出。
我的解决方法:上面的配置面不变,添加 bind 配置:
bind 192.168.1.132
报错:
[root@localhost redis-cluster]# ./redis-trib.rb create 192.168.1.132:7001 192.168.1.132:7002 192.168.1.132:7003 192.168.1.132:7004 192.168.1.132:7005 192.168.1.132:7006
Creating cluster
[ERR] Sorry, can't connect to node 192.168.1.132:7001
解析:
- 网络,比如 ping 、 telnet 检查
- 集群模式,每个基点的配置文件不能配置密码
- 默认每个节点是启用[protected-mode yes]配置的,要修正
报错:
[root@localhost ~]# redis-cli -h 192.168.1.132 -p 7001
192.168.1.132:7001> KEYS *
(empty list or set)
192.168.1.132:7001> set name 11
(error) MOVED 5798 192.168.1.132:7002
192.168.1.132:7001> exit
[root@localhost ~]# redis-cli -h 192.168.1.132 -p 7001 -c
192.168.1.132:7001> set name 11
-> Redirected to slot [5798] located at 192.168.1.132:7002
OK
192.168.1.132:7002>
解决:
redis-cli 默认是链接到单个实例的Redis Server,如果链接到集群,则需要添加 -c 参数