server2003一台服务器配置多个tomcat和集群 博客分类: apache Tomcat XMLWindowsJSPApacheTomcat
程序员文章站
2024-03-07 11:55:27
...
apache版本:apache_2.2.4-win32-x86-no_ssl.msi JK版本:mod_jk-1.2.26-httpd-2.2.4.so tomcat版本:apache-tomcat-6.0.32-windows-x86.zip 首先安装apache地址可以填写本机IP,完成后修改 D:\Program Files\Apache Software Foundation\Apache2.2\conf 下面的 httpd.conf 在文件最后面增加:include conf\mod_jk.conf 然后再httpd.conf同级目录新建mod_jk.conf和workers.properties ------------------------mod_jk.conf---------------------------------- #加载mod_jk Module LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so #指定 workers.properties文件路径 JkWorkersFile conf/workers.properties #指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器 JkMount /* controller #JkMount /*.jsp controller #JkMount /*.do controller #加载集群中的workers #JkMountFile conf/uriworkermap.properties ------------------------mod_jk.conf---------------------------------- ---------------------workers.properties------------------------------ worker.list = controller #server 列表 #========tomcat1======== worker.tomcat1.port=8009 #ajp13 端口号,在tomcat下server.xml配置,默认8009 worker.tomcat1.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址 worker.tomcat1.type=ajp13 worker.tomcat1.lbfactor = 1 #server的加权比重,值越高,分得的请求越多 #========tomcat2======== worker.tomcat2.port=8019 #ajp13 端口号,在tomcat下server.xml配置,默认8009 worker.tomcat2.host=192.168.1.222 #tomcat的主机地址,如不为本机,请填写ip地址 worker.tomcat2.type=ajp13 worker.tomcat2.lbfactor = 1 #server的加权比重,值越高,分得的请求越多 #========tomcat3======== worker.tomcat3.port=8029 #ajp13 端口号,在tomcat下server.xml配置,默认8009 worker.tomcat3.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址 worker.tomcat3.type=ajp13 worker.tomcat3.lbfactor = 1 #server的加权比重,值越高,分得的请求越多 #========controller,负载均衡控制器======== worker.controller.type=lb worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3 #指定分担请求的tomcat ---------------------workers.properties------------------------------ 安装tomcat 直接解压到D:\
tomcat1 修改conf\server.xml文件 <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
tomcat3
在相同路径下拷贝一份,改名为apache-tomcat-6.0.32-2 修改配置文件conf\server.xml 修改三个端口 <Server port="8006" shutdown="SHUTDOWN"> <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8029" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat3">
然后修改session同步:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
把上面的内容替换成
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"> <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="4000" autoBind="100" selectorTimeout="5000" maxThreads="6"/> <!-- timeout="60000"--> <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=""/> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/> <!-- <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.JvmRouteSessionIDBinderListener"/> <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/> </Cluster>
这里的
<!-- <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/" watchEnabled="false"/> -->如果不去掉这部分,则tomcat启动会报"FarmWarDeployer can only work as host cluster subelement!."
tomcat2
配置到另一台机器上,和上面tomcat1的配置相同就可以
把mod_jk-1.2.26-httpd-2.2.4.so拷贝到modules/目录下