redis protected mode 的配置

redis從3.2版本後增長了幾個參數,其中 protected-mode參數注意的事項redis

protected-mode參數是爲了禁止外網訪問redis,若是啓用了,則只可以經過lookback ip(127.0.0.1)訪問Redis,若是外網訪問redis,會報出異常:ide

(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.

配置方式:oop

redis實例的配置文件中禁用bind參數this

#bind

redis實例的配置文件中設置protected-mode參數爲norest

protected-mode no

若是redis實例配置文件中禁用了bind參數,並將protected-mode設置爲no後,外網訪問redis依然報上述錯誤,由於 sentinel 實例的配置文件中須要增長參數 protected-mode  nocode

sentinel實例的配置文件中增長參數server

protected-mode no
相關文章
相關標籤/搜索