当前位置: 首页 > news >正文

tomcat单机多实例部署

一、部署方法

多实例可以运行多个不同的应用,也可以运行相同的应用,类似于虚拟主机,但是他可以做负载均衡。


方式一:

把tomcat的主目录挨个复制,然后把每台主机的端口给改掉就行了。

优点是最简单最直接,缺点是会占用更多的物理空间。

方法二:

就用一个tomcat,然后用这一个tomcat去启动多个tomcat实例出来,这样就不用复制多份,只用一个tomcat就行,但是呢,个别的数据目录就得有多个,因为你不可能几个共用同一个数据目录的。

优点是更节省你的物理空间,缺点是比较复杂。


二、多实例配置过程

这里用方法二作为展示,我们来配置三个实例

instance1:                                                                                        

/usr/local/tomcat/multi-ins/instance1/{conf,logs,temp,work,webapps} 8081 9001 10001

instance2:

/usr/local/tomcat/multi-ins/instance2/{conf,logs,temp,work,webapps} 8082 9002 10002

instance3:

/usr/local/tomcat/multi-ins/instance3/{conf,logs,temp,work,webapps} 8083 9003 10003

(这里的三个端口,以instance 1为例,8081对应的是你的8080端口,也就是tomcat默认的HTTP服务端口,9001对应的是你的8005端口,也就是tomcat 的关闭端口,用于接收关闭tomcat服务器的命令,10001对应的是你的8009端口,也就是 tomcat 默认的AJP协议端口,主要用于tomcat和其他web服务器之间的通信) 

1.配置instance1(8081 9001 10001

创建目录拷贝修改配置——

[root@xxx /]# mkdir -p /usr/local/tomcat/multi-ins/instance1

[root@xxx /]# cp -r /usr/local/tomcat/{conf,logs,temp,work,webapps} /usr/local/tomcat/multi-ins/instance1/

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance1/conf/server.xml

(考虑到在操作的过程中可能出现失误把全部配置搞丢了而且没有做备份,在本文章的末尾我会把全配置给粘贴过去,不在开头复制是为了避免开头的篇幅过长,还请见谅)

(说明:这个配置文件里面的注释符号是<!-- 内容 --> ,如果之前做过虚拟主机,请把他们给注释掉,以免影响测试)

修改发布目录——

<Host name="localhost"  appBase="/usr/local/tomcat/multi-ins/instance1/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>
 

修改端口—— 

<Server port="9001" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" /> 

<Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

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

编写测试网页——

[root@xxx /]# rm -rf /usr/local/tomcat/multi-ins/instance1/webapps/ROOT/*

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance1/webapps/ROOT/index.html

instance111111

[root@xxx /]# cat /usr/local/tomcat/multi-ins/instance1/webapps/ROOT/index.html
instance111111

编写instance1启动脚本——

[root@xxx]# touch /usr/local/tomcat/multi-ins/instance1/ins1.sh

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance1/ins1.sh

#!/bin/bash
#instance1
. /etc/init.d/functions
export CATALINA_HOME="/usr/local/tomcat"
export CATALINA_BASE="/usr/local/tomcat/multi-ins/instance1"

case "$1" in
start)
        $CATALINA_HOME/bin/startup.sh
        ;;
stop)
        $CATALINA_HOME/bin/shutdown.sh
        ;;
restart)
        $CATALINA_HOME/bin/shutdown.sh
        sleep 2
        $CATALINA_HOME/bin/startup.sh
esac

(这里为了做展示,脚本写的比较粗糙,见谅见谅)

测试脚本——

[root@xxx /]# /usr/local/tomcat/multi-ins/instance1/ins1.sh start        #启动

[root@xxx /]# /usr/local/tomcat/multi-ins/instance1/ins1.sh stop        #关闭

[root@xxx /]# /usr/local/tomcat/multi-ins/instance1/ins1.sh start

2.配置instance2(8082 9002 10002

创建目录拷贝修改配置——

[root@xxx /]# cp -r /usr/local/tomcat/multi-ins/instance1 /usr/local/tomcat/multi-ins/instance2

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance2/conf/server.xml

修改发布目录——

<Host name="localhost"  appBase="/usr/local/tomcat/multi-ins/instance2/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>

(没别的,就是把1改成2就行) 

修改端口—— 

<Server port="9002" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" /> 

 <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

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

编写测试网页——

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance2/webapps/ROOT/index.html

instance222222

[root@xxx /]# cat /usr/local/tomcat/multi-ins/instance2/webapps/ROOT/index.html
instance222222

编写instance2启动脚本——

[root@xxx /]# mv /usr/local/tomcat/multi-ins/instance2/ins1.sh /usr/local/tomcat/multi-ins/instance2/ins2.sh

#!/bin/bash
#instance2
. /etc/init.d/functions
export CATALINA_HOME="/usr/local/tomcat"
export CATALINA_BASE="/usr/local/tomcat/multi-ins/instance2"

case "$1" in
start)
        $CATALINA_HOME/bin/startup.sh
        ;;
stop)
        $CATALINA_HOME/bin/shutdown.sh
        ;;
restart)
        $CATALINA_HOME/bin/shutdown.sh
        sleep 2
        $CATALINA_HOME/bin/startup.sh
esac

测试脚本——

和instance1完全相同,不在赘述。

3.配置instance3(8083 9003 10003

创建目录拷贝修改配置——

[root@xxx /]# cp -r /usr/local/tomcat/multi-ins/instance1 /usr/local/tomcat/multi-ins/instance3

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance3/conf/server.xml

修改发布目录——

<Host name="localhost"  appBase="/usr/local/tomcat/multi-ins/instance3/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>

(没别的,就是把1改成3就行) 

修改端口—— 

<Server port="9003" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" /> 

 <Connector port="8083" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

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

编写测试网页——

[root@xxx /]# vim /usr/local/tomcat/multi-ins/instance3/webapps/ROOT/index.html

instance333333

[root@xxx /]# cat /usr/local/tomcat/multi-ins/instance3/webapps/ROOT/index.html
instance333333

编写instance3启动脚本——

[root@xxx /]# mv /usr/local/tomcat/multi-ins/instance3/ins1.sh /usr/local/tomcat/multi-ins/instance3/ins3.sh

#!/bin/bash
#instance3
. /etc/init.d/functions
export CATALINA_HOME="/usr/local/tomcat"
export CATALINA_BASE="/usr/local/tomcat/multi-ins/instance3"

case "$1" in
start)
        $CATALINA_HOME/bin/startup.sh
        ;;
stop)
        $CATALINA_HOME/bin/shutdown.sh
        ;;
restart)
        $CATALINA_HOME/bin/shutdown.sh
        sleep 2
        $CATALINA_HOME/bin/startup.sh
esac

测试脚本——

和instance1完全相同,不在赘述。

三、多实例启动脚本

[root@xxx /]# touch /usr/local/tomcat/multi-ins/all_instance.sh

[root@xxx /]# vim /usr/local/tomcat/multi-ins/all_instance.sh

#!/bin/bash

case $1 in

start)
        for i in {1..3};do
                /usr/local/tomcat/multi-ins/instance$i/ins${i}.sh start
        done
        ;;
stop)
        for i in {1..3};do
                /usr/local/tomcat/multi-ins/instance$i/ins${i}.sh stop
        done
        ;;
restart)
        for i in {1..3};do
                /usr/local/tomcat/multi-ins/instance$i/ins${i}.sh stop
                sleep 2
                /usr/local/tomcat/multi-ins/instance$i/ins${i}.sh start
        done
        ;;
esac

脚本测试:

[root@xxx /]# /usr/local/tomcat/multi-ins/all_instance.sh start        #启动

[root@xxx /]# /usr/local/tomcat/multi-ins/all_instance.sh stop        #停止

[root@xxx /]# /usr/local/tomcat/multi-ins/all_instance.sh restart        #重启

四、多实例部署验证

[root@xxx /]# /usr/local/tomcat/multi-ins/all_instance.sh start

[root@xxx /]# firefox

 

 部署成功!

五、server.xml配置备份

instance1——

<?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="9001" shutdown="SHUTDOWN">
  <!-- 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" />
  <!--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" />
  <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 HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" 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="10001" 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="/usr/local/tomcat/multi-ins/instance1/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 name="www.sns.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Context docBase="sns" path="" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.sns.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
      <Host name="www.bbs.com"  appBase="webroot"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.bbs.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

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

instance2—— 

<?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="9002" shutdown="SHUTDOWN">
  <!-- 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" />
  <!--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" />
  <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 HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" 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="10002" 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="/usr/local/tomcat/multi-ins/instance2/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 name="www.sns.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Context docBase="sns" path="" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.sns.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
      <Host name="www.bbs.com"  appBase="webroot"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.bbs.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

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

 instance3——

<?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="9003" shutdown="SHUTDOWN">
  <!-- 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" />
  <!--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" />
  <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 HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8083" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" 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="10003" 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="/usr/local/tomcat/multi-ins/instance3/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 name="www.sns.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Context docBase="sns" path="" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.sns.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
      <Host name="www.bbs.com"  appBase="webroot"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="www.bbs.com_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

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

谢谢支持! 

相关文章:

tomcat单机多实例部署

一、部署方法 多实例可以运行多个不同的应用&#xff0c;也可以运行相同的应用&#xff0c;类似于虚拟主机&#xff0c;但是他可以做负载均衡。 方式一&#xff1a; 把tomcat的主目录挨个复制&#xff0c;然后把每台主机的端口给改掉就行了。 优点是最简单最直接&#xff0c;…...

论文阅读分享——UMDF(AAAI-24)

概述 题目&#xff1a;A Unified Self-Distillation Framework for Multimodal Sentiment Analysis with Uncertain Missing Modalities 发表&#xff1a;The Thirty-Eighth AAAI Conference on Artificial Intelligence (AAAI-24) 年份&#xff1a;2024 Github&#xff1a;暂…...

解决asp.net mvc发布到iis下安全问题

解决asp.net mvc发布到iis下安全问题 环境信息1.The web/application server is leaking version information via the "Server" HTTP response2.确保您的Web服务器、应用程序服务器、负载均衡器等已配置为强制执行Strict-Transport-Security。3.在HTML提交表单中找不…...

概念|RabbitMQ 消息生命周期 待消费的消息和待应答的消息有什么区别

目录 消息生命周期 一、消息创建与发布阶段 二、消息路由与存储阶段 三、消息存活与过期阶段 四、消息投递与消费阶段 五、消息生命周期终止 关键配置建议 待消费的消息和待应答的消息 一、待消费的消息&#xff08;Unconsumed Messages&#xff09; 二、待应答的消息…...

springboot三层架构详细讲解

目录 springBoot三层架构 0.简介1.各层架构 1.1 Controller层1.2 Service层1.3 ServiceImpl1.4 Mapper1.5 Entity1.6 Mapper.xml 2.各层之间的联系 2.1 Controller 与 Service2.2 Service 与 ServiceImpl2.3 Service 与 Mapper2.4 Mapper 与 Mapper.xml2.5 Service 与 Entity2…...

2025最新群智能优化算法:云漂移优化(Cloud Drift Optimization,CDO)算法求解23个经典函数测试集,MATLAB

一、云漂移优化算法 云漂移优化&#xff08;Cloud Drift Optimization&#xff0c;CDO&#xff09;算法是2025年提出的一种受自然现象启发的元启发式算法&#xff0c;它模拟云在大气中漂移的动态行为来解决复杂的优化问题。云在大气中受到各种大气力的影响&#xff0c;其粒子的…...

2025年Draw.io最新版本下载安装教程,附详细图文

2025年Draw.io最新版本下载安装教程&#xff0c;附详细图文 大家好&#xff0c;今天给大家介绍一款非常实用的流程图绘制软件——Draw.io。不管你是平时需要设计流程图、绘制思维导图&#xff0c;还是制作架构图&#xff0c;甚至是简单的草图&#xff0c;它都能帮你轻松搞定。…...

记录--洛谷 P1451 求细胞数量

如果想查看完整题目&#xff0c;请前往洛谷 P1451 求细胞数量 P1451 求细胞数量 题目描述 一矩形阵列由数字 0 0 0 到 9 9 9 组成&#xff0c;数字 1 1 1 到 9 9 9 代表细胞&#xff0c;细胞的定义为沿细胞数字上下左右若还是细胞数字则为同一细胞&#xff0c;求给定矩形…...

Android Studio 配置国内镜像源

Android Studio版本号&#xff1a;2022.1.1 Patch 2 1、配置gradle国内镜像&#xff0c;用腾讯云 镜像源地址&#xff1a;https\://mirrors.cloud.tencent.com/gradle 2、配置Android SDK国内镜像 地址&#xff1a;Index of /AndroidSDK/...

做到哪一步才算精通SQL

做到哪一步才算精通SQL-Structured Query Language 数据定义语言 DDL for StructCREATE&#xff1a;用来创建数据库、表、索引等对象ALTER&#xff1a;用来修改已存在的数据库对象DROP&#xff1a;用来删除整个数据库或者数据库中的表TRUNCATE&#xff1a;用来删除表中所有的行…...

Manus演示案例: 英伟达财务估值建模 解锁投资洞察的深度剖析

在当今瞬息万变的金融投资领域&#xff0c;精准剖析企业价值是投资者决胜市场的关键。英伟达&#xff08;NVIDIA&#xff09;&#xff0c;作为科技行业的耀眼明星&#xff0c;其在人工智能和半导体领域的卓越表现备受瞩目。Manus 凭借专业的财务估值建模能力&#xff0c;深入挖…...

postman接口请求中的 Raw是什么

前言 在现代的网络开发中&#xff0c;API 的使用已经成为数据交换的核心方式之一。然而&#xff0c;在与 API 打交道时&#xff0c;关于如何发送请求体&#xff08;body&#xff09;内容类型的问题常常困扰着开发者们&#xff0c;尤其是“raw”和“json”这两个术语之间的区别…...

DeepSeek大语言模型下几个常用术语

昨天刷B站看到复旦赵斌老师说的一句话“科幻电影里在人脑中植入芯片或许在当下无法实现&#xff0c;但当下可以借助AI人工智能实现人类第二脑”&#xff08;大概是这个意思&#xff09; &#x1f49e;更多内容&#xff0c;可关注公众号“ 一名程序媛 ”&#xff0c;我们一起从 …...

ctf-WEB: 关于 GHCTF Message in a Bottle plus 与 Message in a Bottle 的非官方wp解法

Message in a Bottle from bottle import Bottle, request, template, runapp Bottle()# 存储留言的列表 messages [] def handle_message(message):message_items "".join([f"""<div class"message-card"><div class"me…...

测试用例详解

一、通用测试用例八要素   1、用例编号&#xff1b;    2、测试项目&#xff1b;   3、测试标题&#xff1b; 4、重要级别&#xff1b;    5、预置条件&#xff1b;    6、测试输入&#xff1b;    7、操作步骤&#xff1b;    8、预期输出 二、具体分析通…...

c#面试题整理7

1.UDP和TCP的区别 UDP是只要能连上终端就发送&#xff0c;至于终端是否收到&#xff0c;不管。 TCP则是会存在交换&#xff0c;即发送失败或成功&#xff0c;是可知的。 2.进程和线程的区别 双击一个程序的exe文件&#xff0c;程序执行了&#xff0c;这就是一个进程。 这个…...

OpenManus-通过源码方式本地运行OpenManus,含踩坑及处理方案,chrome.exe位置修改

前言&#xff1a;最近 Manus 火得一塌糊涂啊&#xff0c;OpenManus 也一夜之间爆火&#xff0c;那么作为程序员应该来尝尝鲜 1、前期准备 FastGithub&#xff1a;如果有科学上网且能正常访问 github 则不需要下载此软件&#xff0c;此软件是提供国内直接访问 githubGit&#…...

【性能测试】Jmeter下载安装、环境配置-小白使用手册(1)

本篇文章主要包含Jmeter的下载安装、环境配置 添加线程组、结果树、HTTP请求、请求头设置。JSON提取器的使用&#xff0c;用户自定义变量 目录 一&#xff1a;引入 1&#xff1a;软件介绍 2&#xff1a;工作原理 3&#xff1a;安装Jmeter 4&#xff1a;启动方式 &#xf…...

HTML星球大冒险之路线图

第一章&#xff1a;欢迎来到 HTML 星球&#xff01; 1.1 宇宙的基石&#xff1a;HTML 是什么&#xff1f; &#x1f30d; 比喻&#xff1a;HTML 是网页世界的「乐高积木」&#xff0c;用标签搭建一切可见内容&#x1f3af; 目标&#xff1a;理解 HTML 的作用&#xff0c;掌握…...

初识大模型——大语言模型 LLMBook 学习(一)

1. 大模型发展历程 &#x1f539; 1. 早期阶段&#xff08;1950s - 1990s&#xff09;&#xff1a;基于规则和统计的方法 代表技术&#xff1a; 1950s-1960s&#xff1a;规则驱动的语言处理 早期的 NLP 主要依赖 基于规则的系统&#xff0c;如 Noam Chomsky 提出的 生成语法&…...

LabVIEW伺服阀高频振动测试

在伺服阀高频振动测试中&#xff0c;闭环控制系统的实时性与稳定性至关重要。针对用户提出的1kHz控制频率需求及Windows平台兼容性问题&#xff0c;本文重点分析NI PCIe-7842R实时扩展卡的功能与局限性&#xff0c;并提供其他替代方案的综合对比&#xff0c;以帮助用户选择适合…...

AI编程工具-(七)

250309,10这几天都在用通义灵码搞做建模分析。 感想&#xff0c;指令越具体&#xff0c;实现效果越好。 依然是之前的时许数据&#xff0c;这几天分析效果没有提升。 画的几个有意思的图表和效果 主要觉得这图好看&#xff0c;提示词不复杂。 预测效果 预测准确性提升不大聊…...

什么是一致性模型,在实践中如何选择?

一、一致性模型 1、强一致性(Strong Consistency) ①定义:强一致性意味着在分布式系统中的每个读取操作,都能读取到最近写入的数据。也就是说,所有节点都始终保持相同的数据状态。 ②特点:写操作对所有节点立即可见,所有的读取操作在任何节点上都能看到最新的写入。 …...

Python项目-智能家居控制系统的设计与实现

1. 引言 随着物联网技术的快速发展&#xff0c;智能家居系统已经成为现代家庭生活的重要组成部分。本文将详细介绍一个基于Python的智能家居控制系统的设计与实现过程&#xff0c;该系统能够实现对家庭设备的集中管理和智能控制&#xff0c;提升家居生活的便捷性和舒适度。 2…...

RDP连接无法复制粘贴问题的排查与解决指南

RDP连接无法复制粘贴问题的排查与解决指南 问题描述注意事项排查原因检查RDP剪贴板进程是否正常检查组策略设置检查权限和安全设置检查网络连接 解决方式重启rdpclip.exe进程启用RDP剪贴板重定向调整组策略设置检查并调整安全设置更新驱动程序和系统检查网络连接使用其他远程连…...

IDEA与Maven使用-学习记录(持续补充...)

1. 下载与安装 以ideaIU-2021.3.1为例&#xff0c;安装步骤&#xff1a; 以管理员身份启动ideaIU-2021.3.1修改安装路径为&#xff1a;D:\Program Files\JetBrains\IntelliJ IDEA 2021.3.1勾选【创建桌面快捷方式】&#xff08;可选&#xff09;、【打开文件夹作为项目】&…...

Go 语言封装 HTTP 请求的 Curl 工具包

文章目录 Go 语言封装 HTTP 请求的 Curl 工具包&#x1f3d7;️ 工具包结构简介核心结构体定义初始化函数 &#x1f31f; 功能实现1. 设置请求头2. 构建请求3. 发送请求4. 发送 GET 请求5. 发送 POST 请求6. 发送 PUT 请求7. 发送 DELETE 请求8. 读取响应体 &#x1f4a1; 实现…...

RK3568 SD卡调试记录

文章目录 1、环境介绍2、概念理清3、原理图查看4、dts配置5、验证6、SD卡启动6.1、启动优先级6.2、启动流程6.2.1、Maskrom(Boot ROM)启动优先级6.2.2、Pre-loader(SPL)启动优先级 6.3、如何从sd卡启动&#xff1f;6.3.1、制作sd启动卡6.3.2、sd卡启动 7、总结 1、环境介绍 硬…...

高效获取历史行情数据:xtquant的实战应用

高效获取历史行情数据&#xff1a;xtquant的实战应用 &#x1f680;量化软件开通 &#x1f680;量化实战教程 在量化交易领域&#xff0c;历史行情数据是构建和测试交易策略的基础。无论是回测策略的有效性&#xff0c;还是进行市场分析&#xff0c;高质量的历史数据都是不可…...

【python爬虫】酷狗音乐爬取练习

注意&#xff1a;本次爬取的音乐仅有1分钟试听&#xff0c;仅作学习爬虫的原理&#xff0c;完整音乐需要自行下载客户端。 一、 初步分析 登陆酷狗音乐后随机选取一首歌&#xff0c;在请求里发现一段mp3文件&#xff0c;复制网址&#xff0c;确实是我们需要的url。 复制音频的…...