##Apache2下负载均衡tomcat##
#修改apache httpd.conf 去掉注释#
LoadModule proxy_module modules/mod_proxy.so?
LoadModule proxy_connect_module modules/mod_proxy_connect.so?
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so?
LoadModule proxy_http_module modules/mod_proxy_http.so?
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so?
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so?
#添加 DirectoryIndex #
DirectoryIndex index.jsp
#BalancerMember成员是我们配置的tomcat集群#
ProxyRequests Off?
<proxy balancer://cluster>?
①BalancerMember ajp://127.0.0.1:9001 loadfactor=1 route=jvm1
</proxy>?
#添加Virtual hosts #
检查 -- 去掉注释
# Virtual hosts?
Include conf/extra/httpd-vhosts.conf?
#在文件(extra/httpd-vhosts.conf)最下面加入#
<VirtualHost *:80>?
ServerAdmin weijie@126.com?
ServerName localhost?
ServerAlias localhost?
#下面两个配置对应httpd.conf中的<proxy balancer://cluster> 配置
ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On?
ProxyPassReverse / balancer://cluster/?
</VirtualHost>?
##tomcat \conf下的 server.xml ##?
#<Engine#
①<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">?
#<Cluster#
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" ?channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.BackupManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="6"/>
<!--
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
-->
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="5001"
selectorTimeout="100"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
#<Connector#
①<Connector port="9001" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
?