采用apache实现tomcat的集群配置方案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

采用apache实现tomcat的集群配置方案1.目标1)采用Apache作为负载均衡服务器,实现tomcat具备故障恢复能力的集群配置。2)采用terracotta作为cache服务器,实现ehcache的集群配置。2.环境准备一个Apache作为负载均衡服务器,多个tomcat作为应用服务器apache_2.2.13、tomcat6.0.29、mod_jk-1.2.30-httpd-2.2.3.so、terracotta-3.2.1-installer.jar、ehcache2.0、jdk1.6该方案在一台windowsXP上测试通过,如果需要在多台硬件服务器上配置,只需要进行相应修改即可。3.负载均衡配置1)安装apache,我的安装路径为默认C:\ProgramFiles\ApacheSoftwareFoundation\Apache2.22)将mod_jk-1.2.30-httpd-2.2.3.so改名为mod_jk.so并复制到apache的安装目录下的modules目录中3)在apache的安装目录下的conf目录中新建mod_jk.conf文件,内容如下LoadModulejk_modulemodules/mod_jk.soJkWorkersFileconf/workers.propertiesJkMount/*controller4)相同目录下新建workers.properties文件,内容如下#node1和node2是两个tomcat实例worker.list=controller,node1,node2worker.node1.port=8009worker.node1.host=localhost#node1的ip或服务名worker.node1.type=ajp13worker.node1.lbfactor=1worker.node2.port=9009worker.node2.host=localhost#node2的ip或服务名worker.node2.type=ajp13worker.node2.lbfactor=1worker.controller.type=lbworker.controller.balanced_workers=node1,node2worker.controller.sticky_session=15)相同目录下修改http.conf,在文件最后添加如下内容includeconf/mod_jk.conf6)安装两个tomcat实例,我的安装路径为e:/node1和e:/node2,由于node1和node2安装在同一台系统下,需要修改node2的端口。修改node2的server.xml,内容如下!--默认为8005--Serverport=9005shutdown=SHUTDOWN!--默认为8080--Connectorport=9080protocol=HTTP/1.1connectionTimeout=20000redirectPort=8443/!--默认为8009--Connectorport=9009protocol=AJP/1.3redirectPort=8443/4.故障恢复配置1)修改node1的server.xml文件,内容如下Enginename=CatalinadefaultHost=localhostjvmRoute=node1ClusterclassName=org.apache.catalina.ha.tcp.SimpleTcpClusterchannelSendOptions=6ManagerclassName=org.apache.catalina.ha.session.BackupManagerexpireSessionsOnShutdown=falsenotifyListenersOnReplication=truemapSendOptions=6/ChannelclassName=org.apache.catalina.tribes.group.GroupChannelMembershipclassName=org.apache.catalina.tribes.membership.McastServiceaddress=228.0.0.4port=45564frequency=500dropTime=3000/ReceiverclassName=org.apache.catalina.tribes.transport.nio.NioReceiveraddress=autoport=4001selectorTimeout=100maxThreads=6/SenderclassName=org.apache.catalina.tribes.transport.ReplicationTransmitterTransportclassName=org.apache.catalina.tribes.transport.nio.PooledParallelSender//SenderInterceptorclassName=org.apache.catalina.tribes.group.interceptors.TcpFailureDetector/InterceptorclassName=org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor/InterceptorclassName=org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor//ChannelValveclassName=org.apache.catalina.ha.tcp.ReplicationValvefilter=.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;/DeployerclassName=org.apache.catalina.ha.deploy.FarmWarDeployertempDir=/tmp/war-temp/deployDir=/tmp/war-deploy/watchDir=/tmp/war-listen/watchEnabled=false/ClusterListenerclassName=org.apache.catalina.ha.session.ClusterSessionListener//Cluster2)修改node2的server.xml文件,内容如下Enginename=CatalinadefaultHost=localhostjvmRoute=node2ClusterclassName=org.apache.catalina.ha.tcp.SimpleTcpClusterchannelSendOptions=6ManagerclassName=org.apache.catalina.ha.session.BackupManagerexpireSessionsOnShutdown=falsenotifyListenersOnReplication=truemapSendOptions=6/ChannelclassName=org.apache.catalina.tribes.group.GroupChannelMembershipclassName=org.apache.catalina.tribes.membership.McastServiceaddress=228.0.0.4port=45564frequency=500dropTime=3000/ReceiverclassName=org.apache.catalina.tribes.transport.nio.NioReceiveraddress=autoport=4002selectorTimeout=100maxThreads=6/SenderclassName=org.apache.catalina.tribes.transport.ReplicationTransmitterTransportclassName=org.apache.catalina.tribes.transport.nio.PooledParallelSender//SenderInterceptorclassName=org.apache.catalina.tribes.group.interceptors.TcpFailureDetector/InterceptorclassName=org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor/InterceptorclassName=org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor//ChannelValveclassName=org.apache.catalina.ha.tcp.ReplicationValvefilter=.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;/DeployerclassName=org.apache.catalina.ha.deploy.FarmWarDeployertempDir=/tmp/war-temp/deployDir=/tmp/war-deploy/watchDir=/tmp/war-listen/watchEnabled=false/ClusterListenerclassName=org.apache.catalina.ha.session.ClusterSessionListener//Cluster3)布署web应用到node1和node2的webapps目录,并修改web应用的web.xml文件,添加如下内容distributable/5.Cache集群配置cache集群配置可以配置多个cache服务器,下面的例子只配置了一个cache服务器,如果需要多个cache服务器可以进行相应配置。1)安装terracottajava-jarterracotta-3.2.1-installer.jar2)修改ehcache的ehcache.xml文件,添加,内容如下terracottaConfigurl=localhost:9510/cachename=syscachemaxElementsInMemory=100000eternal=falsetimeToIdleSeconds=0timeToLiveSeconds=0overflowToDisk=falsememoryStoreEvictionPolicy=LFUterracottaclustered=true//cache6.启动系统1)启动terracotta/bin/start-tc-server.bat2)启动node1和node2e:/node1/bin/startup.bat等node1启动完成后再启动node2e:/node2/bin/startup.bat3)等node1和node2都启动完成后,再启动apache4)当关闭系统时,采用相反的过程。7.方案的优化1)Terracotta可以配置多个服务器,实现热备,预防单点故障2)静态资源如图片、js、css采用Apache直接处理,不交给tomcat,可以提高性能。3)T

1 / 8
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功