Redis中遇到的问题以及解决方案

1. DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified,
redis.exceptions.ResponseError: 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数据库的时候报这个错误
错误解析:因为redis运行在了受保护的模式下,所以在程序中才会报这个错误。
解决方式:找到redis配置文件,在配置文件中修改protected-mode yes改为protected-mode no。然后使用ps aux | grep redis命令查看redis-server的进程ID,进而杀死这个进程:

[root@instance-mtfsf05r redis-5.0.5]# ps aux | grep redis
[root@instance-mtfsf05r redis-5.0.5]# kill -9 10717
[root@instance-mtfsf05r redis-5.0.5]# srv/redis-server redis.conf
2. redis.exceptions.ConnectionError: Error 111 connecting to xxx.xxx.xxx.xxx:6379. Connection refused.
redis.exceptions.ConnectionError: Error 111 connecting to 106.12.115.136:6379. Connection refused.

问题来源:操作redis数据库的时候出现错误
错误解析:连接被拒绝,考虑是redis 绑定了127.0.0.1,拒绝远程访问
解决方式:修改redis配置文件,把127.0.0.1改为0.0.0.0

[root@instance-mtfsf05r redis-5.0.5]# ps aux | grep redis
[root@instance-mtfsf05r redis-5.0.5]# kill -9 10717
[root@instance-mtfsf05r redis-5.0.5]# vim redis.conf 
[root@instance-mtfsf05r redis-5.0.5]# src/redis-server redis.conf
发布了54 篇原创文章 · 获赞 138 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/Thanlon/article/details/101373805