Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: DENIED Redis isrunningin 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 fromthe loopback interface. If you want to connect from external computers to Redis you may adopt one ofthe following solutions:
1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' fromthe loopback interface by connecting to Redis fromthe same host the server isrunning, however MAKE SURE Redis isnot 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', andthen restarting the server
3) If you started the server manually just for testing, restart itwiththe '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one oftheabove things in order forthe server to start accepting connections fromthe 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)
4.好吧,此时你以为轻松解决问题了,于是再次在Linux启动redis服务器后,在外部连接还是报错,真是too young too native,起初我以为是配置没有生效,因为明明配置都写好了,于是杀掉redis的相关进程重启服务,结果发现还是没卵用。最后研究发现问题所在:之前启动redis-server并没有指定配置文件,而Linux上的redis比较操蛋的一点就是如果你不指定配置文件去启动,那么你做的修改就没有用,会读取默认配置(PS:至于这个默认配置在哪我也不清楚),于是用下面这种方式启动就可以使修改的配置文件生效,至于config rewrite命令我测试了并没有什么卵用。