`
weir2009
  • 浏览: 263824 次
  • 性别: Icon_minigender_1
  • 来自: 惠州
社区版块
存档分类
最新评论

apache 2.X+tomcat 6.X/7.X集群配置

 
阅读更多

httpd-2.2.22-win32-x86-no_ssl.msi

tomcat-connectors-1.2.35-windows-i386-httpd-2.2.x.zip

tomcat 6 和tomcat7 都行  tomcat8 没有测试。

 

安装就不演示了,直接配置:

1.首先将下载的tomcat-connectors-1.2.35-windows-i386-httpd-2.2.x.zip解压复制里面的

mod_jk.so 复制到Apache安装目录的modules目录下

 

2.修改:

D:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

 

最后一行加入:

include "D:\Program Files\Apache Software Foundation\Apache2.2\conf\mod_jk.conf"

访问系统路径

Alias /q2c "D:/q2c/q2c"

<Directory "D:/q2c/q2c">

     Options Indexes MultiViews

     AllowOverride None

     Order allow,deny

     Allow from all

</Directory>

注意:D:/q2c/q2c 红色的q2c为项目根目录,即我把项目放在了D盘q2c的文件夹下面

 

 

3.

 

创建:D:\Program Files\Apache Software Foundation\Apache2.2\conf\mod_jk.conf

 

 内容

 

LoadModule jk_module modules/mod_jk.so

 

JkWorkersFile conf/workers.properties

 

JkMount /* controller

 

#静态文件都例外,交给apache来处理 

 

JkUnMount /*.gif controller

 

JkUnMount /*.jpg controller

 

JkUnMount /*.png controller

 

JkUnMount /*.css controller

 

JkUnMount /*.js controller

 

JkUnMount /*.htm controller

 

JkUnMount /*.html controller

 

JkUnMount /*.xml controller

 

JkUnMount /*.db controller

 

JkUnMount /*.ico controller

 

JkUnMount /*.bmp controller

 

JkUnMount /*.swf controller

 

JkUnMount /*.doc controller

 

JkUnMount /*.ppt controller

 

JkUnMount /*.xls controller

 

JkUnMount /*.docx controller

 

JkUnMount /*.pptx controller

 

JkUnMount /*.xlsx controller

 

JkUnMount /*.pdf controller

 

JkUnMount /*.txt controller

 

 

 

 

 

4.新建:

D:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties

内容

#server

worker.list = controller

#========tomcat1========

worker.tomcat1.port=8009

worker.tomcat1.host=172.168.20.4

worker.tomcat1.type=ajp13

worker.tomcat1.lbfactor = 1

#========tomcat2========

worker.tomcat2.port=8009

worker.tomcat2.host=172.168.20.5

worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor = 1

#========tomcat3========

worker.tomcat3.port=8009

worker.tomcat3.host=172.168.20.6

worker.tomcat3.type=ajp13

worker.tomcat3.lbfactor = 1

#========controller,负载均衡控制器========

worker.controller.type=lb

worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3

worker.controller.sticky_session=1

worker.controller.sticky_session_force=0

 

5.配置每个tomcatserver.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
   
   
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8081
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->          
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
     
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
     

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="d:/q2c"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
  </Service>
</Server>

修改红色地方。注意与workers.properties文件里面的配置一致。

ok了。放入自己的项目试一下吧。

说明一点apache server下的项目目录放静态文件

如果你的项目是war包,直接复制到tomcat指定的工程目录就行了。

分享到:
评论

相关推荐

    Apache2.2.x+Tomcat6.x+jk2.x做集群配置

    本资源为小夜的传说Apache2.2.x+Tomcat6.x+jk2.x做集群配置源码!

    Apache2.2.25 + Tomcat6.0.45 + mod_jk + 测试页面 + 集群

    本资源包含了文章Apache2.2.x + Tomcat6.x + JK 集群配置,http://blog.csdn.net/qq396229783/article/details/74295797里面所用到的软件配置

    Apache+多个Tomcat 服务器集群配置

    将以下Module的注释去掉,这里并没有使用mod_jk.so进行apache和tomcat的链接,从2.X以后apache自身已集成了mod_jk.so的功能。只需简单的把下面几行去掉注释,就相当于以前用mod_jk.so比较繁琐的配置了。这里主要采用...

    nginx+tomcat高可用、高性能jsp集群

    The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.6.0_25/jre/lib/i386/client:/usr/local/jdk...

    APACHE 2.2.9+TOMCAT6.0.18配置负载均衡

    将以下Module的注释去掉,这里并没有使用mod_jk.so进行apache和tomcat的链接,从2.X以后apache自身已集成了mod_jk.so的功能。只需简单的把下面几行去掉注释,就相当于以前用mod_jk.so比较繁琐的配置了。这里主要采用...

    Apache+tomcat

    Html Apache + tomcat 集群配置文档 Apache 2.2.4 + tomcat6.x

    mod_jk-apache-2.4.x

    在Windows环境下的Tomcat + Apache配置整合,集群。mod_jk-apache-2.4.x

    Apace2.4.x版本配置tomcat集群 mod-jk.so

    解决Apace2.4.x版本配置tomcat集群时启动apache报错:Cannot load modules/mod_jk.so into server: /apache/httpd/modules/mod_jk.so: wrong ELF class: ELFCLASS32

    Nginx+Tomcat负载均衡

    tomcatX 在这里表示不同的tomcat,我的两个 tomcat 分别使用 tomcat1和tomcat2;来区分。 这个设置是主要用以tomcat的集群。 如果看不懂可以去看我提供的tomcat我已经改好了。 启动tomcat服务 分别到两个tomcat下,...

    linux配置tomcat集群

    1), VM虚拟机: VMware-workstation-full-10.0 (2),linux系统ubuntu-12.04.3-server-amd64 ...(6),tomcat: apache-tomcat-7.0.47 (7),mysql: 5.5.34-0ubuntu0.12.04.1 (8),测试工具:apache-jmeter-2.9

    apache & tomcat 负载均衡配置文件和tomcat connector

    本人电脑上已经配置好的相关配置文件 包括: tomcat-connectors-1.2.40-windows-x86_64-httpd-2.4.x.zip httpd.conf server.xml(tomcat) mod_jk.conf uriworkermap.properties vhosts.conf workers.properties

    Tomcat和Apache集群和负载均衡配置

    JK是Tomcat提供给http服务器的插件,这里是tomcat-connectors-1.2.39-windows-x86_64-httpd-2.4.x,对应64位操作系统。

    Nginx+Tomcat高性能负载均衡集群搭建教程

    其占有内存少,并发能力强,在同类型的网页服务器中表现较好。...在这里我们采用集群部署方式,使用多个Tomcat,反向代理使用Nginx。 架构如下: 准备工作 apache-tomcat-7.0.61 nginx-1.12.2 Redis-x64-3.2.10

    JAVA web.xml配置详解

    -- 配置集群的时候,要用到,在这篇文章:“apache+tomcat集群、负载均衡及session复制”里的第三条(http://jiajun.javaeye.com/admin/blogs/278586) --&gt; &lt;distributable/&gt; &lt;!-- context-param 元素用来设定...

    centos7.5分布式平台搭建.docx

    8.1. 配置tomcat的环境变量和内存设置 29 8.2. 服务自启动 30 9. Mysql 30 9.1. 离线安装 30 9.2. 在线安装 30 9.2.1. 检测系统是否自带安装mysql 30 9.2.2. 下载yum包 30 9.2.3. 安装mysql 30 9.2.4. 启动服务 30 ...

    单点登录源码

    ├── zheng-config -- 配置中心[端口:1001] ├── zheng-upms -- 用户权限管理系统 | ├── zheng-upms-common -- upms系统公共模块 | ├── zheng-upms-dao -- 代码生成模块,无需开发 | ├── zheng-upms-...

    mod_jk-1.2.26-httpd-2.0.61.so

    它是Tomcat-Apache插件,处理Tomcat和Apache之间的通信,在集群配置中充当负载均衡器的作用

    Red Hat Linux,Apache2.0+Weblogic9.2负载均衡集群安装配置

    ************************************************************************************************************************ JDK安装步骤 1. 以root身份登录系统 2. 到java.sun.com去下载...4. 执行./jdk-1_5_0_1

    Jetty中文手册

    Binding JAX-WS 2.x Endpoints to Jetty Contexts Java Management Extensions (JMX) 配置JMX教程 处理JVM NIO Bug Rewrite模块 Inversion of Control and Dependency Injection Frameworks Jetty XML IOC 如何使用...

Global site tag (gtag.js) - Google Analytics