就在刚刚,我干掉了18年最后一个bug
2018-12-31 本文已影响1人
KKyKK
刚才部署项目的时候报了个异常
Cannot get Jedis connection 用过redis的估计都见过这样异常,连接不上redis嘛,ok小问题。
登录redis服务器先使用netstat命令看下redis是否启动,没问题,已经启动,
使用redis-cli 登录确认密码是否正确,同样没问题,
那就修改一下配置文件的连接池,再次启动还是同样的异常
嘶 ~ 好吧!接着翻log!
看到了这样一段话
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:
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. 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.
If you started the server manually just for testing, restart it with the '--protected-mode no' option. 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为保护模式启动
可我明明已经设置了密码,为什么还是保护模式
翻翻百度看到了一个回答说 redis没有绑定IP
回来使用netstat命令重新看一下redis端口,果然显示127.0.0.1 (因为这台服务器上的redis是刚刚安装的)
打开配置文件 在address后面加上服务器外网ip
重新启动tomcat,打开项目主页,成功访问。搞定!