zoukankan      html  css  js  c++  java
  • redis 对外访问

    Redis 对第三方应用使用

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

    第一处:

    释掉bind 127.0.0.1,或者将 bind 127.0.0.1 改成了bind 0.0.0.0 (开启对外)

    第二处:

    protected-mode yes  改为 no (关闭保护模式)

    第三处:

    # masterauth <master-password> 后添加 自己的密  requirepass 123456(此方法为永久密码,通过

    redis 127.0.0.1:6379>CONFIG SET requirepass "root"
    
    OK
    
    redis 127.0.0.1:6379>AUTH "root"
    
    OK

    设置的密码,在redis重启后则会失效)

    在终端中使用命令进入redis时 需要输入密码

     ./redis-cli 
    127.0.0.1:6379> keys *
    (error) NOAUTH Authentication required.
    127.0.0.1:6379> auth 123456
    OK
    127.0.0.1:6379> keys *
    1) "test1"
    2) "key"
    127.0.0.1:6379> 

    提示:启动时使用命令为: ./redis-server ../redis.conf(该文件路径为以上配置的文件路径)

    注意:若启动Redis时不指定配置文件,默认会选用内部的conf文件,而不是安装目录下的,最好启动时指定配置文件。

     

    此时可正常访问reids。

  • 相关阅读:
    处理客户端无法及时更新js、css
    关于JQ判断单选复选被选中
    一路风景,一路欣赏,一路有你
    Adobe Dreamweaver CC 2015新功能
    Eclipse导出APK文件报错 android lint problem
    swift2.0 计算圆面积
    zendStudio连接远程服务器报错java.net.SocketException
    IOS tableview 消除 分割线短 15 像素 ios8方法 swift版
    应用之间调用 UIApplication类的OpenURL方法
    iOS8 今日扩展
  • 原文地址:https://www.cnblogs.com/klyjb/p/15078907.html
Copyright © 2011-2022 走看看