多个tomcat同一个apache,使用jk建立关系时常出错!

多个项目,放在独立的tomcat上,并没有实现负载,要求实现静态化交给apache处理。

配置了3个tomcat通过jk和apache建立关系:

[list=1]
[*]tom1存放项目名:d1

[*]tom2存放项目名:news

[*]tom3存放项目名:root

[/list]
环境:(一台win2003服务器,,zip版本5.5.26的tomcat装了3个,,jk是1.2.26的,apache2.2.×)

我的实现方式:

每个tomcat根目录下写个bat脚本,用于同一个机器上启动多个tomcat

D:\Program\Tomcat5.5.26\startup_proname.bat

set CATALINA_HOME=D:\Program\Tomcat5.5.26
bin/startup.bat
(此处只写一个tomcat的配置server.xml就不多说了,其他的也如此)

贴出我的配置文件,一共5个:
[list]
[*]mod_jk.conf

[*]workers2.properties

[*]uriworkermap-d1.properties

[*]uriworkermap-news.properties

[*]uriworkermap-root.properties

[*]httpd-vhosts.conf

[/list]

[b]mod_jk.conf[/b]

# Load mod_jk module. Specify the filename
# of the mod_jk lib you’ve downloaded and
# installed in the previous section

#加载mod_jk模块
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers2.properties

# Where to find uriworkermap.properties
JkMountFile conf/uriworkermap-root.properties
JkMountFile conf/uriworkermap-news.properties
JkMountFile conf/uriworkermap-d1.properties

# Where to put jk logs
JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]
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"

#关掉主机Lookup,如果为on,很影响性能,可以有10多秒钟的延迟。
HostnameLookups Off

[b]workers2.properties[/b]

worker.list=root-loadbalancer,news-loadbalancer,d1-loadbalancer

#主工程
worker.root.type=ajp13
worker.root.host=localhost
worker.root.port=9009
worker.root.lbfactor=1

worker.root-loadbalancer.type=lb
worker.root-loadbalancer.balance_workers=root

#新闻工程(news)
worker.news.type=ajp13
worker.news.host=localhost
worker.news.port=9019
worker.news.lbfactor=1

worker.news-loadbalancer.type=lb
worker.news-loadbalancer.balance_workers=news

#文件服务器工程(d1)
worker.d1.type=ajp13
worker.d1.host=localhost
worker.d1.port=9029
worker.d1.lbfactor=1

worker.d1-loadbalancer.type=lb
worker.d1-loadbalancer.balance_workers=d1

worker.status.type=status

[b]uriworkermap-d1.properties[/b]

/*=d1-loadbalancer

!/*.gif=d1-loadbalancer
!/*.jpg=d1-loadbalancer
!/*.png=d1-loadbalancer
!/*.css=d1-loadbalancer
!/*.js=d1-loadbalancer
!/*.htm=d1-loadbalancer
!/*.html=d1-loadbalancer

[b]uriworkermap-news.properties[/b]

/*=news-loadbalancer

!/*.gif=news-loadbalancer
!/*.jpg=news-loadbalancer
!/*.png=news-loadbalancer
!/*.css=news-loadbalancer
!/*.js=news-loadbalancer
!/*.htm=news-loadbalancer
!/*.html=news-loadbalancer

[b]uriworkermap-root.properties[/b]

/*=root-loadbalancer

!/*.gif=root-loadbalancer
!/*.jpg=root-loadbalancer
!/*.png=root-loadbalancer
!/*.css=root-loadbalancer
!/*.js=root-loadbalancer
!/*.htm=root-loadbalancer
!/*.html=root-loadbalancer


[b]httpd-vhosts.conf[/b]


#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

#网站主工程
<VirtualHost *:80>
ServerAdmin sydney.sun@demo.com
DocumentRoot "D:\apache-tomcat-5.5.26-root\webapps\insurance"
ServerName *.demo.com
JkMountFile conf/uriworkermap-root.properties
ErrorLog logs/demo-error.log
CustomLog logs/demo-access.log common
DirectoryIndex index.jsp

<Directory "D:\apache-tomcat-5.5.26-root\webapps\insurance">
Options FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

<IfModule mod_rewrite.c>

Rewriteengine on

#配置满足什么条件进行重写
RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.demo\.com$
RewriteCond %{HTTP_HOST} !^www.demo.com
RewriteCond %{HTTP_HOST} !^bbs.demo.com
RewriteCond %{HTTP_HOST} !^d1.demo.com
RewriteCond %{HTTP_HOST} !^news.demo.com
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.jpg|\.gif|\.png|\.html|\.htm)$

RewriteRule ^/(.*)$ /%{HTTP_HOST}/$1

#网站后台进行二级域名解析
RewriteRule ^/manage\.demo\.com/?$ /panel/login.do [L,PT]

#频道的首页进行二级域名解析
RewriteRule ^/zx\.demo\.com/?$ /advisory/index.do [L,PT]
RewriteRule ^/bid\.demo\.com/?$ /bid/bid_index.do [L,PT]
RewriteRule ^/job\.demo\.com/?$ /job/job_index.do [L,PT]
RewriteRule ^/download\.demo\.com/?$ /download/downloadIndex.do [L,PT]
RewriteRule ^/ts\.demo\.com/?$ /complain/complain_index.do [L,PT]
RewriteRule ^/video\.demo\.com/?$ /shipin/videoIndex.do [L,PT]
RewriteRule ^/yellow\.demo\.com/?$ /yellow/yellow_index.do [L,PT]
RewriteRule ^/fun\.demo\.com/?$ /fun/index.do [L,PT]

#空间会员进行泛域名解析
RewriteRule ^/([a-z0-9\-]+)\.demo\.com/?$ /space/index.do?SLD=$1 [L,PT]
RewriteRule ^/([a-z0-9\-]+)\.demo\.com/space(/(.*))*$ /space/$2?SLD=$1&%{QUERY_STRING} [L,PT]
</IfModule>

</VirtualHost>


#保险新闻工程
<VirtualHost *:80>
ServerAdmin sydney.sun@demo.com
DocumentRoot "D:\apache-tomcat-5.5.26-news\webapps\news"
ServerName news.demo.com
JkMountFile conf/uriworkermap-news.properties
ErrorLog logs/news-error.log
CustomLog logs/news-access.log common
DirectoryIndex index.jsp

<Directory "D:\apache-tomcat-5.5.26-news\webapps\news">
Options FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

</VirtualHost>


#文件服务器工程
<VirtualHost *:80>
ServerAdmin sydney.sun@demo.com
DocumentRoot "D:\apache-tomcat-5.5.26-d1\webapps\d1"
ServerName d1.demo.com
JkMountFile conf/uriworkermap-d1.properties
ErrorLog logs/d1-error.log
CustomLog logs/d1-access.log common
DirectoryIndex index.jsp

<Directory "D:\apache-tomcat-5.5.26-d1\webapps\d1">
Options FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

</VirtualHost>



最后一个配置了,强调:我这里是3个项目分别用了3个tomcat,主要工程root实现了二级域名,其他两个功能有相应的域名

现在运行了2,3天时间发现偶尔会有异常,打不开现象,重启下影响不大,不过不知道原因很痛苦!

tomcat日志:

2008-10-28 13:18:59 org.apache.jasper.compiler.TldLocationsCache processWebDotXml
警告: Internal Error: File /WEB-INF/web.xml not found
2008-10-28 13:50:22 org.apache.jk.core.MsgContext action
警告: Error sending end packet
java.net.SocketException: Software caused connection abort: socket write error
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值