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。

  • 相关阅读:
    java的装箱和拆箱详解
    java语法基础
    java变量与内存深入了解
    java的配置环境简介
    Python脚本--利用运算符重载简化MongoDB的命令
    Python多线程编程,线程锁
    Python多进程,同步互斥,信号量,锁补充上一篇文章
    Python多进程编程及多进程间的通信,数据传输
    Jmeter深度学习第一天——简单请求、带header请求、返回值乱码问题
    JAVA Spring工程一些配置问题的解决
  • 原文地址:https://www.cnblogs.com/klyjb/p/15078907.html
Copyright © 2011-2022 走看看