一台服务部署多个tomcat注意事项

第一步 

添加tomcat环境变量

# vim /etc/profile
加入下代码

# TOMCAT

ATALINA_BASE=/usr/local/tomcat8
CATALINA_HOME=/usr/local/tomcat8
TOMCAT_HOME=/usr/local/tomcat8
export ATALINA_BASE CATALINA_HOME TOMCAT_HOME

修改应用环境变量,是配置生效
# source /etc/profile

第二步

cd  /usr/local/tomcat8/conf

vim server.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">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- 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/TLS HTTP/1.1 Connector on port 8080
    -->

        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
         URIEncoding="UTF-8"
              useBodyEncodingForURI="true" />

    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" 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">

      <!--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"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- 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"/>
      </Realm>
<!--
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
-->
        <!-- 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
             Note: The pattern used is equivalent to using pattern="common" -->
<!--
     <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
-->    

      <!--
     <Host appBase="webapps" autoDeploy="true" name="center" unpackWARs="true">
                <Context path="/db-center" docBase="/data/zhiqiyun/webapp/center"/>
                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                       prefix="localhost_access_log" suffix=".txt"
                        pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          </Host>

      <Host appBase="webapps" autoDeploy="true" name="wox.woxiaoyun.com"  unpackWARs="true">
            <Context path="" docBase="/data/zhiqiyun/webapp/wox/showWeb"/>
      </Host>

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

修改

1.<Server port="8005" shutdown="SHUTDOWN">

2.

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
useBodyEncodingForURI="true" />

3.

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

第三步


cd /usr/local/tomcat8/bin

vim catalina.sh

设置指向对应的base 文件地址

在文件顶部写入:

export JAVA_HOME=/usr/local/java/jdk1.8.0_20
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib.tools.jar

export CATALINA_BASE=$CATALINA_3_BASE

时间: 2024-10-19 15:28:53

一台服务部署多个tomcat注意事项的相关文章

Window下同一台服务器部署多个tomcat服务

本文使用tomcat 8.0压缩版进行部署. 工具 apache-tomcat-8.0.30 安装tomcat步骤 1. 下载apache-tomcat-8.0.30 ,下载下来的文件为apache-tomcat-8.0.30-windows-x64.zip 2. 解压该压缩包到D:/目录下. 3. 修改解压文件夹名字为:tomcat-8080 4. 在D:/目录下创建该文件夹的两个副本,分别更名为:tomcat-8081.tomcat-8082 5. 添加环境变量:右键单击我的电脑->选择属性

同一台机器部署多个tomcat

1.解压tomcat绿色安装包 2.修改conf/server.xml文件,修改里面所有位置涉及到的端口,目的是不跟服务器上已安装的tomcat服务端口冲突 参考: 查找8080,修改为8088: 查找8443,修改为8448: 查找8009,修改为8089: 查找8005,修改为8085: 查找8082,修改为8882 3.进入bin目录,右键编辑service.bat 查找 set SERVICE_NAME 修改service_name,记得不要和安装版里面的重复了: 修改set PR_DI

一台服务器部署多台tomcat

如题,多个项目部署在一台服务器.减少容错性,觉得分开部署,这样一个tomcat挂了不会影响另一个项目.看配置和应用大小决定数量,一般四五个没问题,也有单台服务器部署8个tomcat稳定运行的. 下面记录方法 1. 修改/etc/profile文件 需要在文件中添加多组CATALINA环境变量(有几个tomcat就添加几组)后面的地址为tomcat实际安装的地址. ####第一个Tomcat####export CATALINA_BASE=/usr/local/tomcat/apache-tomc

详解Nginx + Tomcat 反向代理 如何在高效的在一台服务器部署多个站点

转载请注明出处:http://blog.csdn.net/smartbetter/article/details/53615313 上一篇分享了 Nginx + Tomcat 反向代理 负载均衡 集群 部署指南,感觉还是相当实用型的,但是一般集群部署是基于大访问量的,可能有的企业用不到,类似一些企业官网,访问量并不是很大,基于这个新需求,今天专门为大家分享一下 Nginx + Tomcat 反向代理 如何在一台服务器部署多个站点,节省服务器开支,就在这篇文章了. 首先我们需要安装好Nginx.j

Nginx + Tomcat 反向代理 如何在高效的在一台服务器部署多个站点

转载请注明出处:http://blog.csdn.net/smartbetter/article/details/53615313 上一篇分享了 Nginx + Tomcat 反向代理 负载均衡 集群 部署指南,感觉还是相当实用型的,但是一般集群部署是基于大访问量的,可能有的企业用不到,类似一些企业官网,访问量并不是很大,基于这个新需求,今天专门为大家分享一下 Nginx + Tomcat 反向代理 如何在一台服务器部署多个站点,节省服务器开支,就在这篇文章了. 首先我们需要安装好Nginx.j

在一台服务器上部署多个Tomcat

在一台服务器上配置多个Tomcat的方法: 这几天由于在研究OGSA-DQP,但是其网站上只提供了在Linux下的安装文档,而且需要在一天服务器上配置两个Tomcat,但是我一直没有弄懂怎么在Windows下实现. 如果要在一台服务器上配置多个Tomcat,主要就是要避免Tomcat服务器的端口冲突的问题.只需要修改CATALINA_HOME\conf\server.xml中的启动端口和连接端口就OK了! 下面我们把配置的详细过程写在下面,以供参考:(此例以配置两个Tomcat为例) 1. 下载

Window下同一台服务器部署多个MariaDB(Mysql)、服务方式启动简要配置

版本:MariaDB 10 环境:D盘下,放2个MariaDB解压版,分别是D:\MariaDB.D:\MariaDBA 1.进入MariaDB.MariaDBA,复制my-XXX.ini(不同的文件对应不同的硬件配置),改名为my.ini 2.文本编辑器打开D:\MariaDBA的my.ini,修改把2个涉及端口的地方,避免与MariaDB的冲突 3.注册服务,进入D:\MariaDB\bin,命令运行"mysqld.exe --install MariaDB10",进入D:\Mar

tomcat服务部署与优化

JDK的安装: 下载jdk安装包 wget http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz?AuthParam=1470388116_8d0b1125c26b81742b2e7542395d7ed1 解压安装包 tat -zxvf jdk-8u101-linux-x64.tar.gz 复制解压出来的目录到/usr/local目录下 mv jdk1.8.0_101/ /usr/loca

Linux常用服务部署与优化

Linux常用服务部署与优化 A.NFS部署和优化1 1. 安装NFS服务端与配置文件 [[email protected] mnt]# yum install -y nfs-utils rpcbind     //安装服务端 [[email protected] mnt]# vim /etc/exports    //打开配置文件,配置共享文件,文件默认是空的 /mnt  10.30.4.137(rw,sync)    //配置共享文件/mnt [[email protected] mnt]#