1

使用(64 位 centos,8 gb ram)、mysql、apache 运行 tomcat 5.5

"-server -Xss1M -Xms2G -Xmx3550m -XX:+UseConcMarkSweepGC -XX:NewSize=1G -XX:MaxPermSize=512m XX:CMSInitiatingOccupancyFraction=70"

通过 apache 作为前端在 tomcat 上运行多个应用程序(几乎 10 个域用于 tomcat 上的各种上下文路径)

apache config:
httpd.conf:

KeepAlive On

ProxyRequests Off

ProxyPreserveHost On

Timeout 1800

ProxyPass         /demo  http : //127.0.0.1:8080/demo

ProxyPassReverse  /demo  http :// 127.0.0.1.22:8080/demo

ProxyPass         /demo2  http :// 127.0.0.1:8080/demo2

ProxyPassReverse  /demo2  http :// 127.0.0.1.22:8080/demo2

SetEnv force-proxy-request-1.0 1

SetEnv proxy-nokeepalive 1

.htaccess

RewriteEngine on

RewriteCond %{HTTP_HOST} ^test\.web\.com$ [NC]

RewriteRule (.*) http : //test.web.com/demo/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^test2\.web\.com$ [NC]

RewriteRule (.*) http : //test2.web.com/demo2/$1 [L,R=301]

一切都很好,包括响应时间和所有 10 个实例(各种域),但每天 3-4 次:http: //test.web.com没有给出任何响应,它在空白的时间,直接 url:http://127.0.0.1:8080/demo工作正常。这意味着 tomcat 仍然可以正常工作,似乎 apache 无法将请求转发给 tomcat - 现在每个实例的负载是每分钟 20 个。

有时一切工作 3-4 天,然后它发生,有时它继续发生。空白页出现了一段时间 - 3-4 分钟后 - 页面开始出现。

4

2 回答 2

0

尝试使用 JKMount 而不是您的代理配置?

我与 apache config 有类似的东西:

# 
# Mod_jk settings 
# 
JkWorkersFile "conf/workers.properties" 
JkLogFile "logs/mod_jk.log" 
JkLogLevel info

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE, 
JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format 
JkRequestLogFormat     "%w %V %T"


<VirtualHost 127.0.0.1:8443>
    SSLEngine On
    SSLCertificateFile conf/ssl/domainacom.cert
    SSLCertificateKeyFile conf/ssl/domainacom.key
    ServerAdmin boss@domain.com
    ServerName wwwdomainacom
    ErrorLog logs/wwwdomainacom-error_log
    CustomLog logs/wwwdomainacom-access_log common
    JkMount /* wwwdomainacom
</VirtualHost>

然后在 conf/workers.properties 中:

worker.list=domainacom,domainbcom

# Set properties for domainacom (ajp13) 
worker.domainacom.port=8009
worker.domainacom.host=localhost
worker.domainacom.type=ajp13
worker.domainacom.lbfactor=50
worker.domainacom.cachesize=10
worker.domainacom.cache_timeout=600
worker.domainacom.socket_keepalive=1
worker.domainacom.reclycle_timeout=300

# Set properties for domainbcom (ajp13) 
worker.domainbcom.port=8011
worker.domainbcom.host=localhost
worker.domainbcom.type=ajp13
worker.domainbcom.lbfactor=50
worker.domainbcom.cachesize=10
worker.domainbcom.cache_timeout=600
worker.domainbcom.socket_keepalive=1
worker.domainbcom.reclycle_timeout=300

最后在tomcat中:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" 
           enableLookups="true" redirectPort="8443" protocol="AJP/1.3" URIEncoding="UTF-8" />

据我所知,我从来没有丢失过任何请求。

于 2011-06-08T21:53:38.120 回答
0

你在使用负载均衡器吗?请确保它不是基于 PING 的。有时托管服务提供商会拒绝基于 ping 的网络负载。

于 2011-09-22T12:27:36.220 回答