JAVA连接Redis错误提示(一)

来源:互联网 发布:搜索算法工程师 编辑:程序博客网 时间:2024/05/18 12:31
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.Jedis.set(Jedis.java:121)    at test.JedisPoolTest.test(JedisPoolTest.java:22)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

这个问题解决是看前辈写的东西
  报错的大意就是:redis运行在保护模式,没有绑定访问地址,没有登录密码认证,在这种模式下,连接只接受环回接口(loopback,一种路由接口),

下面有几种解决办法:

  1)使用命令:“CONFIG SET protected-mode no” ,禁用保护模式。
  直接linux中登录redis然后打这个代码就行了
  
  2)修改配置文件,禁用保护模式。

  3)重新启动redis server 使用 “–protected-mode no” 参数

  4) 设置一个绑定ip或设置认证密码

redis 设置密码

  修改redis.conf 配置文件,找到 “requirepass”
  取消注释,在后面添加你的密码

 requirepass myRedis  //这是密码
原创粉丝点击