连接threashhold,同时负载平衡tomcat。使用apache和mod_jk

时间:2016-11-16 12:24:37

标签: apache tomcat load-balancing mod-jk

我继承了在两个tomcat实例上运行的java webapp,并通过apache2.2 mod_jk 1.2.19进行负载均衡。这连接到单独服务器上的DB。总共4台服务器。

数据库管理员在过去几天注意到在某些时间与数据库的应用程序连接突然增加,然后在几分钟后自动减少。这导致最大数量的会话在数据库中用完。

如果你能看一下下面的内容我会非常感激,并给出一些建议。

workers.properties文件如下。

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status

# Define tomcatA
# modify the host as your host IP or DNS name.
worker.tomcatA.port=8009
worker.tomcatA.host=10.1.26.21
worker.tomcatA.type=ajp13
worker.tomcatA.lbfactor=1
worker.tomcatA.cachesize=10
worker.tomcatA.socket_keepalive=1
worker.tomcatA.socket_timeout=30
worker.tomcatA.connection_pool_timeout=600
worker.tomcatA.connect_timeout=60000
# Define tomcatB as the failover for tomcatA
worker.tomcatA.redirect=tomcatB

# Define tomcatB
# modify the host as your host IP or DNS name.
worker.tomcatB.port=8009
worker.tomcatB.host=10.1.26.23
worker.tomcatB.type=ajp13
worker.tomcatB.lbfactor=1
worker.tomcatB.cachesize=10
worker.tomcatB.socket_keepalive=1
worker.tomcatB.socket_timeout=30
worker.tomcatB.connection_pool_timeout=600
worker.tomcatB.connect_timeout=60000
# Define tomcatA as the failover for tomcatB
worker.tomcatB.redirect=tomcatA

# Load-balancing behaviour
worker.loadbalancer.type=lb
# Setting the number of retries for a worker
worker.retries=4
worker.loadbalancer.balance_workers=tomcatA,tomcatB
worker.loadbalancer.sticky_session=1
# worker.list=loadbalancer

# Status worker for managing load balancer
worker.status.type=status

以下错误开始出现在mod_jk日志中。

[Wed Nov 16 09:49:27 2016] [1380:5076] [error] jk_ajp_common.c (947): (tomcatB) can't receive the response message from tomcat, network problems or tomcat is down (10.1.26.23:8009), err=-60 [Wed Nov 16 09:49:27 2016] [1380:5076] [error] jk_ajp_common.c (1536): (tomcatB) Tomcat is down or refused connection. No response has been sent to the client (yet) [Wed Nov 16 09:49:47 2016] [1380:4332] [error] jk_ajp_common.c (947): (tomcatA) can't receive the response message from tomcat, network problems or tomcat is down (10.1.26.21:8009), err=-60 [Wed Nov 16 09:49:47 2016] [1380:4332] [error] jk_ajp_common.c (1536): (tomcatA) Tomcat is down or refused connection. No response has been sent to the client (yet) [Wed Nov 16 09:49:47 2016] [1380:4332] [error] jk_ajp_common.c (1879): (tomcatA) Connecting to tomcat failed. Tomcat is probably not started or is listening on the wrong port

tomcat catalina logs

Nov 15, 2016 11:54:14 PM org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2
Nov 15, 2016 11:57:25 PM org.apache.jk.core.MsgContext action
WARNING: Error sending end packet
java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:518)
    at org.apache.jk.common.JkInputStream.endMessage(JkInputStream.java:112)
    at org.apache.jk.core.MsgContext.action(MsgContext.java:293)
    at org.apache.coyote.Response.action(Response.java:182)
    at org.apache.coyote.Response.finish(Response.java:304)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:204)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:722)
从上午6点到下午12点,卡塔琳娜有15000行含有确切的段落。下面只有其他8条线。它只出现过一次。

джЭ 15, 2016 6:41:11 г org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2
джЭ 15, 2016 6:43:49 г org.apache.catalina.tribes.group.interceptors.TcpFailureDetector memberDisappeared
INFO: Received memberDisappeared[org.apache.catalina.tribes.membership.MemberImpl[tcp://ptahq27escan1.scan.internal:4000,ptahq27escan1.scan.internal,4000, alive=188815394,id={60 83 112 -109 -10 -107 69 87 -112 -21 -49 103 -100 -111 -8 84 }, payload={}, command={}, domain={}, ]] message. Will verify.
джЭ 15, 2016 6:43:50 г org.apache.catalina.tribes.group.interceptors.TcpFailureDetector memberDisappeared
INFO: Verification complete. Member still alive[org.apache.catalina.tribes.membership.MemberImpl[tcp://ptahq27escan1.scan.internal:4000,ptahq27escan1.scan.internal,4000, alive=188815394,id={60 83 112 -109 -10 -107 69 87 -112 -21 -49 103 -100 -111 -8 84 }, payload={}, command={}, domain={}, ]]
джЭ 15, 2016 6:55:26 г org.apache.jk.core.MsgContext action
WARNING: Error sending end packet

在server.xml中设置以下connectionTimeout

<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1" 
           maxThreads="660" connectionTimeout="20000" 
           redirectPort="8443" URIEncoding="WINDOWS-1256" />

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" connectionTimeout="20000" URIEncoding="WINDOWS-1256"  />

如果需要任何其他详细信息,请与我们联系 问候

0 个答案:

没有答案