1.能用yum或rpm安装jdk、tomcat、mysql、httpd最好,可以避免很多不必要的错误。
2.安装完Apache HttpServer后,注释掉/etc/httpd/httpd.conf中的DocumentRoot。
用proxy的方式集群(mod_jk方式参考以前文章):
#stick session 配置
LoadModule headers_module modules/mod_headers.so
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyRequests Off
<proxy balancer://lbcluster1>
BalancerMember ajp://IP1:8009 loadfactor=1 route=TomcatA
BalancerMember ajp://IP2:8009 loadfactor=1 route=TomcatB
BalancerMember ajp://IP3:8009 loadfactor=1 route=TomcatC
ProxySet stickysession=ROUTEID
</proxy>
<VirtualHost *:80>
ServerName localhost
ProxyVia On
ProxyPass / balancer://lbcluster1/
ProxyPassReverse / balancer://lbcluster1/
<Proxy *>
Require all granted
</Proxy>
<Location / >
Require all granted
</Location>
</VirtualHost>
将上述内容新建文件httpd-proxy.conf保存到/etc/httpd/conf.d下即可。因为httpd.conf里面默认配置了
IncludeOptional conf.d/*.conf
3.Tomcat server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="TomcatB">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/opt/www/testaa" reloadable="true" crossContext="true" />
</Host>
</Engine>
其中jvmRoute="TomcatB"就是上面 httpd-proxy.conf中route=TomcatB,几个tomcat配置几个。
4. 项目中的web.xml在<web-app>节点中加 <distributable/> 标签。