zoukankan      html  css  js  c++  java
  • 于Jedis连接Linux上的redis出现 DENIED Redis is running in protected mode问题的解决方案

     
    Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: 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.
        at redis.clients.jedis.Protocol.processError(Protocol.java:127)
        at redis.clients.jedis.Protocol.process(Protocol.java:161)
        at redis.clients.jedis.Protocol.read(Protocol.java:215)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
        at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:239)
        at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:196)
        at com.example.redis.JedisTest.main(JedisTest.java:24)

      经过我英语八级的翻译,上面一共提供了四种解决方案,但是综合考虑为了简单起见只需要执行以下几步即可: 
       
      1.修改redis.conf配置文件,将绑定的ip地址端口号给注释见下图 
      这里写图片描述

      2.由于Linux上的redis处于安全保护模式,这就让你无法从虚拟机外部去轻松建立连接,这里就有两种解决方法,一种是在redis.conf中设置保护模式为no,见下图 
      这里写图片描述

      3.另外一种方式是加上安全认证,即redis默认是没有密码的可以直接登录,这里加上密码,配置见下图 
      这里写图片描述

      4./redis-server ../redis.conf 命令启动,不然就是全局配置,redis.conf所做操作没有任何作用。
      这里写图片描述

     

  • 相关阅读:
    Windows内存布局 / MmPfnDataBase页帧数据库
    保护模式中的PDE与PTE
    保护模式101012分页机制
    Windows系统调用中的系统服务表描述符(SSDT)
    Windows系统调用中的系统服务表
    三环进入零环的细节(KiFastCallEntry函数分析)
    Windows系统调用中API从3环到0环(下)
    SQL反模式学习笔记5 外键约束【不用钥匙的入口】
    SQL反模式学习笔记3 单纯的树
    SQL反模式学习笔记2 乱穿马路
  • 原文地址:https://www.cnblogs.com/523823-wu/p/9071888.html
Copyright © 2011-2022 走看看