在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/人工智能  Java  Linux  數(shù)據(jù)庫/ Springboot集成Redis在開發(fā)環(huán)境中能夠連接使用,部署至linux后拋

Springboot集成Redis在開發(fā)環(huán)境中能夠連接使用,部署至linux后拋出異常

部署于某云的Linux服務(wù)器上,一直沒出過問題,今日發(fā)現(xiàn)無法訪問并拋出

[ERROR] org.springframework.boot.context.web.ErrorPageFilter - Forwarding to error page from request [/act/1] due to exception [Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool]
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:162)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:251)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:58)
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:178)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86)
    at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:43)
    at com.ucw.ucwclient.web.interceptors.TokenInterceptor.preHandle(TokenInterceptor.java:62)
    at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:956)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1519)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1475)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at redis.clients.util.Pool.getResource(Pool.java:50)
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:99)
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:12)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:155)
    ... 50 common frames omitted
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
    at redis.clients.jedis.Connection.connect(Connection.java:164)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:82)
    at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1641)
    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:85)
    at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
    at redis.clients.util.Pool.getResource(Pool.java:48)
    ... 53 common frames omitted
Caused by: java.net.SocketTimeoutException: connect timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at redis.clients.jedis.Connection.connect(Connection.java:158)
    ... 60 common frames omitted
12:31:54.818 [http-nio-8080-exec-1] [INFO] 

經(jīng)過測試redis服務(wù)沒有問題,其他的linux服務(wù)器能夠正常訪問,且在開發(fā)環(huán)境中也能夠正常訪問
redis 配置如下:

spring.redis.database=0
spring.redis.host="host"
spring.redis.port=6379
spring.redis.password="password"
spring.redis.timeout=0
spring.redis.pool.max-active=-1
spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0

補(bǔ)充: 從搭建了redis的服務(wù)器查看了一下redis (info命令)的運(yùn)行狀況為正常,且有另外3臺(tái)服務(wù)器鏈接該redis且正常使用,而且這臺(tái)服務(wù)器平時(shí)都正常運(yùn)行,完全猜不到哪里會(huì)有問題,會(huì)不會(huì)問題在阿里云上?

--
再次補(bǔ)充
從無法鏈接的服務(wù)器 telnet Redis服務(wù)器顯示被拒絕 而且我關(guān)閉了所有防火墻,且由其他服務(wù)器正常使用該Redis 這個(gè)問題實(shí)在讓人費(fèi)解啊 現(xiàn)在只能使用其他服務(wù)器代替該服務(wù)器了 很無語

回答
編輯回答
過客

從異常看是redis無法連接導(dǎo)致,超時(shí)java.net.SocketTimeoutException: connect timed out
手動(dòng)檢測部署應(yīng)用服務(wù)器能否連接redis.

telnet <host> 6379

如果沒telnet,可使用python

$ python
...                                                                                                                                                                                                         
>>> import socket                                                                                                                                                                                                                                                              
>>> conn=socket.create_connection(('<host>',6379))   
>>>                                               //如果沒出現(xiàn)錯(cuò)誤說明可以連接上
2018年9月14日 09:45
編輯回答
汐顏

看報(bào)錯(cuò)是redis鏈接池出問題了?開啟鏈接池,鏈接使用結(jié)束后沒有放回,導(dǎo)致泄漏,慢慢累積鏈接池中的鏈接最后都被占用導(dǎo)致從連接池中獲取不到鏈接了。
其他應(yīng)用鏈接redis正常,說明不是redis問題了。

應(yīng)用運(yùn)行一段時(shí)間正常,說明應(yīng)用鏈接redis也沒問題。你先重啟看下是否可以解決此問題。
如果不報(bào)錯(cuò)了,十有八九就是鏈接使用后沒有關(guān)閉導(dǎo)致的。然后就去找哪里導(dǎo)致的鏈接泄漏吧。
如果還是報(bào)鏈接redis失敗就看看是不是應(yīng)用服務(wù)器不通redis服務(wù)了,防火墻之類的限制住了?

2017年1月8日 17:53
編輯回答
有點(diǎn)壞

看著像是網(wǎng)絡(luò)不好或者并發(fā)量太大導(dǎo)致連接池耗盡,可以把Jedis的連接池設(shè)置一下borrow多長時(shí)間以后拋棄,同時(shí)把連接池的狀態(tài)打印出來看看是不是需要調(diào)大一些

另外,如果是Java7的話可以Jstack一下看看是不是有線程卡在socket的read0上,Java7某些版本有這個(gè)BUG,即便設(shè)置了超時(shí)時(shí)間也不會(huì)超時(shí),會(huì)一直hang死

2018年4月12日 18:34
編輯回答
安于心

端口號(hào)對(duì)外開放了嗎?配置阿里云安全組規(guī)則將端口號(hào)對(duì)外開放。

2018年4月14日 03:21