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 "%r" %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 "%r" %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 "%r" %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 athttp://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 "%r" %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 "%r" %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 "%r" %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 athttp://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 "%r" %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 "%r" %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 "%r" %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 athttp://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 "%r" %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 "%r" %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 "%r" %s %b" /></Host>-->
</Engine>
</Service>
</Server>
谢谢支持!
相关文章:
tomcat单机多实例部署
一、部署方法 多实例可以运行多个不同的应用,也可以运行相同的应用,类似于虚拟主机,但是他可以做负载均衡。 方式一: 把tomcat的主目录挨个复制,然后把每台主机的端口给改掉就行了。 优点是最简单最直接,…...
Java开发者如何接入并使用DeepSeek
目录 一、准备工作 二、添加DeepSeek SDK依赖 三、初始化DeepSeek客户端 四、数据上传与查询 五、数据处理与分析 六、实际应用案例 七、总结 【博主推荐】:最近发现了一个超棒的人工智能学习网站,内容通俗易懂,风格风趣幽默ÿ…...
win10电脑鼠标速度突然变的很慢?
电脑鼠标突然变很慢,杀毒检测后没问题,鼠标设置也没变,最后发现可能是误触鼠标的“DPI”调节键。 DPI调节键在鼠标滚轮下方,再次点击即可恢复正常鼠标速度。 如果有和-的按键,速度变快,-速度变慢。 图源&…...
第四次CCF-CSP认证(含C++源码)
第四次CCF-CSP认证 第一道(easy)思路及AC代码 第二道(easy)思路及AC代码遇到的问题 第三道(mid)思路及AC代码 第一道(easy) 题目链接 思路及AC代码 这题就是将这个矩阵旋转之后输出…...
Netty基础—1.网络编程基础一
大纲 1.什么是OSI开放系统互连 2.OSI七层模型各层的作用 3.TCP/IP协议的简介 4.TCP和UDP的简介 5.TCP连接的三次握手 6.TCP连接的四次挥手 7.TCP/IP中的数据包 8.TCP通过确认应答与序列号提高可靠性 9.HTTP请求的传输过程 10.HTTP协议报文结构 11.Socket、短连接、长…...
【理想解法学习笔记】
目录 理想解法原理简介算法步骤属性值规范化方法代码示例 理想解法 原理简介 TOPSIS(Technique for Order Preference by Simi larity to IdealSolution)法是一种逼近理想解的排序方法。其基本的处理思路是:首先建立初始化决策矩阵,而后基于规范化后的初…...
98.在 Vue3 中使用 OpenLayers 根据 Resolution 的不同显示不同的地图
在 Vue3 中使用 OpenLayers 根据 Resolution 的不同显示不同的地图 前言 在 Web GIS(地理信息系统)应用开发中,地图的 Resolution(分辨率)是一个重要的概念。不同的 Resolution 适用于不同的地图层级,有时…...
Docker 部署 Vaultwarden
一、前言 1. 官网 1.1 Vaultwarden https://github.com/dani-garcia/vaultwarden https://github.com/wcjxixi/Vaultwarden-Wiki-Chn https://hub.docker.com/r/vaultwarden/server https://rs.ppgg.in/ # Vaultwarden Wiki 中文版 https://geekdaxue.co/read/Vaultward…...
Smart contract -- 自毁合约
在区块链开发中,Solidity 语言提供了强大的功能,其中自毁合约是一个独特且重要的特性。今天,就让我们深入探讨一下 Solidity 中的自毁合约,以及如何使用 selfdestruct 函数。 注意:使用继承时请确保代码的正确性&#…...
unity学习64,第3个小游戏:一个2D跑酷游戏
目录 学习参考 素材资源导入 1 创建项目 1.1 创建1个2D项目 1.2 导入素材 2 背景图bg 2.0 bg素材 2.1 创建背景 2.2 修改素材,且修改摄像机等 2.2.1 修改导入的原始prefab素材 2.2.2 对应调整摄像机 2.2.3 弄好背景 2.3 背景相关脚本实现 2.3.1 错误…...
Python Flask 在网页应用程序中处理错误和异常
Python Flask 在网页应用程序中处理错误和异常 Python Flask 在网页应用程序中处理错误和异常 Python Flask 在网页应用程序中处理错误和异常 在我们所有的代码示例中,我们没有注意如何处理用户在浏览器中输入错误的URL或向我们的应用程序发送错误的参数集的情况。…...
模板方法模式的C++实现示例
核心思想 模板方法设计模式是一种行为设计模式,它定义了一个算法的框架,并将某些步骤的具体实现延迟到子类中。通过这种方式,模板方法模式允许子类在不改变算法结构的情况下重新定义算法的某些步骤。 模板方法模式的核心在于: …...
水下机器人推进器PID参数整定与MATLAB仿真
水下机器人推进器PID参数整定与MATLAB仿真 1. PID控制原理 目标:通过调节比例(P)、积分(I)、微分(D)参数,使推进器输出力快速稳定跟踪期望值。传递函数(示例):推进器动力学模型可简化为: [ G(s) = \frac{K}{\tau s + 1} \cdot e^{-Ts} ] 其中:K为增益,τ为时间常…...
在本地部署DeepSeek等大模型时,需警惕的潜在安全风险
在本地部署DeepSeek等大模型时,尽管数据存储在本地环境(而非云端),但仍需警惕以下潜在安全风险: 1. 模型与数据存储风险 未加密的存储介质:若训练数据、模型权重或日志以明文形式存储,可能被物…...
智能焊机监测系统:打造工业安全的数字化盾牌
在现代工业生产中,焊机作为核心设备之一,其稳定性和安全性直接关系到生产效率和产品质量。德州迪格特科技有限公司推出的智能焊机监测系统,通过先进的技术手段,为工业生产构筑了一道坚固的安全防线。 智能监测,保障焊…...
【redis】string类型相关操作:SET、GET、MSET、MGET、SETNX、SETEX、PSETEX
文章目录 二进制存储编码转换SET 和 GETSETGET MSET 和 MGETSETNX、SETEX 和 PSETEX Redis 所有的 key 都是字符串,value 的类型是存在差异的 二进制存储 Redis 中的字符串,直接就是按照二进制数据的方式存储的 不仅仅可以存储文本数据,还可…...
GaussDB安全配置指南:从认证到防御的全方面防护
一、引言 随着企业数据规模的扩大和云端化进程加速,数据库安全性成为运维的核心挑战之一。GaussDB作为一款高性能分布式数据库,提供了丰富的安全功能。本文将从 认证机制、权限控制、数据加密、审计日志 等维度,系统性地讲解如何加固 Ga…...
总结学习课程
1. 数据加载与预处理 PyTorch工具加载和预处理数据(如MNIST数据集)。 2. 定义模型 - 使用nn.Module构建神经网络,定义各层和前向传播。 3. 损失函数与优化器: 选择损失函数(如交叉熵损失)和优化…...
Ubuntu20.04搭建gerrit code review
一、环境准备 1. 安装 Java 环境 Gerrit 依赖 Java 运行环境(推荐 JDK 8): sudo apt install openjdk-11-jdk 验证安装: java -version 2. 安装 Git sudo apt install git 3. 可选依赖 数据库:Gerrit …...
MacOS安装FFmpeg和FFprobe
按照网上很多教程安装,结果都失败了,后来才发现是路径问题,其实安装过程很简单(无奈) 第一步: 在官网下载 打开页面后,可以看到FFmpeg、FFprobe、FFplay和FFserver的下载图标 第二步࿱…...
Redis7系列:设置开机自启
前面的文章讲了Redis和Redis Stack的安装,随着服务器的重启,导致Redis 客户端无法连接。原来的是Redis没有配置开机自启。此文记录一下如何配置开机自启。 1、修改配置文件 前面的Redis和Redis Stack的安装的文章中已经讲了redis.config的配置…...
SpringAI介绍及本地模型使用方法
博客原文地址 前言 Spring在Java语言中一直稳居高位,与AI的洪流碰撞后也产生了一些有趣的”化学反应“,当然你要非要说碰撞属于物理反应也可以, 在经历了一系列复杂的反应方程后,Spring家族的新成员——SpringAI,就…...
Zookeeper实践指南
Zookeeper实践指南 1. 什么是 Zookeeper? Zookeeper 是 Apache 旗下的一个开源分布式协调框架,主要用于解决分布式系统中的一致性问题,提供高效可靠的分布式数据管理能力。 1.1 Zookeeper 的核心特性 顺序一致性:客户端的更新…...
Unity 基础知识总结(持续更新中...)
引擎基础 Unity有哪几个主要窗口? Scene窗口 用于场景搭建和UI界面拼接 Game窗口 游戏运行预览 Hierarchy窗口 查看和调整场景对象层级结构 Project窗口 游戏工程资源 Inspector创建 属性查看器,属性设置、脚本组件挂载 Unity提供了几种光源…...
IDEA接入阿里云百炼中免费的通义千问[2025版]
安装deepseek 上一篇文章IDEA安装deepseek最新教程2025中说明了怎么用idea安装codeGPT插件,并接入DeepSeek,无奈接入的官方api已经不能使用了,所以我们尝试从其他地方接入 阿里云百炼https://bailian.console.aliyun.com/ 阿里云百炼是阿…...
中级网络工程师面试题参考示例(1)
一、基础理论 1. OSI七层模型与TCP/IP四层模型的区别是什么?请举例说明第三层(网络层)和第四层(传输层)的核心协议。 参考答案: OSI七层模型分为物理层、数据链路层、网络层、传输层、会话层、表示层、应用…...
主流大语言模型中Token的生成过程本质是串行的
主流大语言模型中Token的生成过程本质是串行的 flyfish 1. 串行生成 自回归模型的核心逻辑: 大模型(如GPT-2)采用自回归架构,每个Token的生成必须基于已生成的完整历史序列。例如,生成“今天天气很好”时:…...
3.03-3.09 Web3 游戏周报:Sunflower Land 周留存率 74.2%,谁是本周最稳链游?
回顾上周的区块链游戏概况,查看 Footprint Analytics 与 ABGA 最新发布的数据报告。 【3.03–3.09】Web3 游戏行业动态 Sui 背后开发公司 Mysten Labs 宣布收购游戏开发平台 ParasolYescoin 创始人因合伙人纠纷被警方带走,案件升级为刑事案件Animoca B…...
高级java每日一道面试题-2025年2月18日-数据库篇-MySQL 如何做到高可用方案?
如果有遗漏,评论区告诉我进行补充 面试官: MySQL 如何做到高可用方案? 我回答: 在Java高级面试中,讨论MySQL如何实现高可用性方案是一个重要话题。这不仅涉及到数据库的稳定性和可靠性,还关系到系统的整体性能和用户体验。以下是结合提供的信息进行综…...
【编程题】7-5 堆中的路径
7-5 堆中的路径 1 题目原文2 思路解析3 代码实现 1 题目原文 题目链接:7-5 堆中的路径 将一系列给定数字插入一个初始为空的最小堆 h h h。随后对任意给定的下标 i i i,打印从第 i i i 个结点到根结点的路径。 输入格式: 每组测试第 1 1 1 行包含 …...
