DENIED Redis is running in protected mode because protected mode is enabled

背景:在codis的admin界面中准备添加redis时提示错误

DENIED Redis is running in protected mode because protected mode is enabled

具体错误如下:

 "Cause": "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.",    "Stack": [
        {
            "Name": "github.com/CodisLabs/codis/pkg/utils/redis.(*Client).Do",            "File": "/opt/gowork/src/github.com/CodisLabs/codis/pkg/utils/redis/client.go",            "Line": 74
        },        {
            "Name": "github.com/CodisLabs/codis/pkg/utils/redis.(*Client).SlotsInfo",            "Line": 269
        },        {
            "Name": "github.com/CodisLabs/codis/pkg/topom.(*apiServer).GroupAddServer",            "File": "/opt/gowork/src/github.com/CodisLabs/codis/pkg/topom/topom_api.go",            "Line": 375
        },        {
            "Name": "github.com/CodisLabs/codis/pkg/topom.(*apiServer).GroupAddServer-fm",            "Line": 91
        }
    ]
}

解决办法:

打开redis的配置文件,如/etc/codis/codis-server/redis7021.conf

# bind 127.0.0.1 
protected-mode no  # 保护模式

杀死原本的redis进程

>>> ps -ef | grep codis  # 查看codis运行的进程

root     13695     1  0 11:47 ?        00:00:05 codis-server *:7021
root     13700     1  0 11:47 ?        00:00:05 codis-server *:7022
root     13719 26723  0 11:55 pts/21   00:00:07 codis-proxy --ncpu=1 --config=/etc/codis/codis-proxy/proxy.toml --log=/usr/local/codis/logs/proxy.log --log-level=warn

>>> kill -9 13695
>>> kill -9 13700

开启codis-server

codis-server /etc/codis/codis-server/redis7021.conf 
codis-server /etc/codis/codis-server/redis7022.conf

如果部分无法看懂,请参考文章:

ubuntu 安装codis详细教程


相关文章

文章浏览阅读1.3k次。在 Redis 中,键(Keys)是非常重要的概...
文章浏览阅读3.3k次,点赞44次,收藏88次。本篇是对单节点的...
文章浏览阅读8.4k次,点赞8次,收藏18次。Spring Boot 整合R...
文章浏览阅读978次,点赞25次,收藏21次。在Centos上安装Red...
文章浏览阅读1.2k次,点赞21次,收藏22次。Docker-Compose部...
文章浏览阅读2.2k次,点赞59次,收藏38次。合理的JedisPool资...