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>

谢谢支持! 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/31466.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机视觉算法实战——老虎个体识别(主页有源码)

✨个人主页欢迎您的访问 ✨期待您的三连 ✨ ✨个人主页欢迎您的访问 ✨期待您的三连 ✨ ✨个人主页欢迎您的访问 ✨期待您的三连✨ ​ ​​​ 1. 领域介绍 老虎个体识别是计算机视觉中的一个重要应用领域&#xff0c;旨在通过分析老虎的独特条纹图案&#xff0c;自动识别和区…

【数据结构】初识集合框架及背后的数据结构(简单了解)

目录 前言 如何学好数据结构 1. 什么是集合框架 2. 集合框架的重要性 3. 背后所涉及的数据结构以及算法 3.1 什么是数据结构 3.2 容器背后对应的数据结构 3.3 相关java知识 3.4 什么是算法 3.5 基本关系说明&#xff08;重要&#xff0c;简单了解&#xff09; 前言 …

Hadoop命令行语句

一、前言 1、启动虚拟机 2、连接工具 3、启动Hadoop并查询确保进程为51 start-all.shjps练习完请一定 stop-all.sh 关掉hadoop进程 关掉虚拟机 再关机电脑 二、Hadoop命令行主命令 1、进入Hadoop安装目录的bin路径 cd /training/hadoop-3.3.0/bin/2、查看低下的执行文…

TypeScript系列07-类型声明文件

在现代前端开发中&#xff0c;TypeScript已成为提升代码质量和开发体验的利器。对于React和React Native项目&#xff0c;合理利用类型声明文件不仅能提供更好的智能提示和类型检查&#xff0c;还能显著减少运行时错误。本文将深入探讨类型声明文件的编写与使用。 1. 声明文件…

迎接AI智能体新时代,推动新质生产力加快发展

随着人工智能技术的飞速发展&#xff0c;AI智能体正逐步成为推动新质生产力加快发展的重要力量。2025年&#xff0c;被业界普遍认为是AI智能体的爆发元年&#xff0c;这一技术范式的深刻变革&#xff0c;正重塑着人机关系&#xff0c;为各行各业带来前所未有的机遇与挑战。本文…

python: DDD using postgeSQL and SQL Server

postgreSQL 注意&#xff1a; # psycopg 2 驱动的连接字符串 #engine create_engine(postgresql://post:geovindulocalhost:5433/TechnologyGame) #Session sessionmaker(bindengine)# 使用 psycopg3 驱动的连接字符串 #engine create_engine(postgresqlpsycopg://user:g…

【redis】string类型相关操作:SET、GET、MSET、MGET、SETNX、SETEX、PSETEX

文章目录 二进制存储编码转换SET 和 GETSETGET MSET 和 MGETSETNX、SETEX 和 PSETEX Redis 所有的 key 都是字符串&#xff0c;value 的类型是存在差异的 二进制存储 Redis 中的字符串&#xff0c;直接就是按照二进制数据的方式存储的 不仅仅可以存储文本数据&#xff0c;还可…

嵌入式设备的功能安全和信息安全?

在现代社会中&#xff0c;嵌入式设备已经无处不在&#xff0c;从我们日常生活中的智能家居&#xff0c;到工业控制、医疗设备等各个行业&#xff0c;嵌入式设备的应用层出不穷。 那么&#xff0c;嵌入式设备的功能安全和信息安全究竟有什么不同&#xff0c;又如何保证它们在实…

爬虫案例七Python协程爬取视频

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、Python协程爬取视频 前言 提示&#xff1a;这里可以添加本文要记录的大概内容&#xff1a; 爬虫案例七协程爬取视频 提示&#xff1a;以下是本篇文章正文…

【C++指南】一文总结C++类和对象【中】

&#x1f31f; 各位看官好&#xff0c;我是egoist2023&#xff01; &#x1f30d; 种一棵树最好是十年前&#xff0c;其次是现在&#xff01; &#x1f680; 今天来学习C类和对象的语法知识。注意&#xff1a;在本章节中&#xff0c;小编会以Date类举例 &#x1f44d; 如果觉得…

Python 入

Python 入侵交换机 随着网络安全威胁不断增加&#xff0c;对于网络设备的安全防护变得愈发重要。而交换机作为网络中重要的设备之一&#xff0c;也需要加强安全保护。本文将介绍如何利用Python来入侵交换机&#xff0c;并对其进行漏洞扫描和安全检测。 1. Python 入侵交换机原…

『PostgreSQL』PGSQL备份与还原实操指南

&#x1f4e3;读完这篇文章里你能收获到 了解逻辑备份与物理备份的区别及适用场景&#x1f50d;。掌握全库、指定库、指定表备份还原的命令及参数&#x1f4dd;。学会如何根据业务需求选择合适的备份策略&#x1f4ca;。熟悉常见备份还原问题的排查与解决方法&#x1f527;。 …

《Python实战进阶》No20: 网络爬虫开发:Scrapy框架详解

No20: 网络爬虫开发&#xff1a;Scrapy框架详解 摘要 本文深入解析Scrapy核心架构&#xff0c;通过中间件链式处理、布隆过滤器增量爬取、Splash动态渲染、分布式指纹策略四大核心技术&#xff0c;结合政府数据爬取与动态API逆向工程实战案例&#xff0c;构建企业级爬虫系统。…

Spring Boot整合WebSocket

目录 ?引言 1.WebSocket 基础知识 ?1.1 什么是 WebSocket&#xff1f; ?1.2 WebSocket 的应用场景 ?2.Spring Boot WebSocket 整合步骤 2.1 创建 Spring Boot 项目 2.2 添加 Maven 依赖 2.3 配置 WebSocket 2.4 创建 WebSocket 控制器 2.5 创建前端页面 引言 在…

《OkHttp:工作原理 拦截器链深度解析》

目录 一、OKHttp 的基本使用 1. 添加依赖 2. 发起 HTTP 请求 3. 拦截器&#xff08;Interceptor&#xff09; 4. 高级配置 二、OKHttp 核心原理 1. 责任链模式&#xff08;Interceptor Chain&#xff09; 2. 连接池&#xff08;ConnectionPool&#xff09; 3. 请求调度…

【前端】BOM DOM

两天更新完毕&#xff0c;建议关注收藏点赞 友情链接&#xff1a; HTML&CSS&LESS&Bootstrap&Emmet Axios & AJAX & Fetch BOM DOM 待整理 js2 Web API 是浏览器提供的一套操作浏览器功能和页面元素的 API ( BOM 和 DOM)。官方文档点击跳转 目录 BOMDOM…

产品需求分析-概览

产品需求分析-概览 产品需求分析(上)-理论流程 需求产生(来源) 公司内部(老板、其他部门同事)产品经理自己(策划、挖掘)外部(用户、客户、伙伴) 需求分类 功能类数据类运营类体验类设计类 需求决策 战略定位产品定位用户需求 需求分位&#xff1a;四象限定位法 重要又…

小程序事件系统 —— 32 事件系统 - 事件分类以及阻止事件冒泡

在微信小程序中&#xff0c;事件分为 冒泡事件 和 非冒泡事件 &#xff1a; 冒泡事件&#xff1a;当一个组件的事件被触发后&#xff0c;该事件会向父节点传递&#xff1b;&#xff08;如果父节点中也绑定了一个事件&#xff0c;父节点事件也会被触发&#xff0c;也就是说子组…

spring6概述

spring6 1、概述 1.1、Spring是什么&#xff1f;1.2、Spring 的狭义和广义1.3、Spring Framework特点1.4、Spring模块组成1.5、Spring6特点 1.5.1、版本要求 2.2、构建模块2.3、程序开发 2.3.1、引入依赖2.3.3、创建配置文件2.3.4、创建测试类测试2.3.5、运行测试程序 2.4、程序…

【Linux docker】关于docker启动出错的解决方法。

无论遇到什么docker启动不了的问题 就是 查看docker状态sytemctl status docker查看docker日志sudo journalctl -u docker.service查看docker三个配置文件&#xff08;可能是配置的时候格式错误&#xff09;&#xff1a;/etc/docker/daemon.json&#xff08;如果存在&#xf…