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。

  • 相关阅读:
    HTML5表单_form
    HTML第二篇
    快速创建1000个目录
    centos7忘记root密码重置
    centos7更改网卡名称
    centos7磁盘在线扩容
    sqlserver开启远程访问
    安装php后无法动态加载库
    编译openssl和Apache报错checking for SSL_CTX_new... no
    centos6.5设置key登录
  • 原文地址:https://www.cnblogs.com/klyjb/p/15078907.html
Copyright © 2011-2022 走看看