memcached-session-manager-tc6-${version}.jar for tomcat6,
memcached-session-manager-tc7-${version}.jar for tomcat7
(attention: tomcat 7.0.23+) or memcached-session-manager-tc8-${version}.jar for tomcat8.
#docker 运行容器名称m2m1 端口本地201 远端11211 基础镜像
docker run -it--name mem1 -p 201:11211 mem
docker run -it--name mem2 -p 202:11211 mem
docker ps
# 测试容器memcached是否运行成功 本地运行telnet
容器tom2号 session信息
JSESSIONID=A4B7390062C98E719D1CBF5C198F835D-n2
JSESSIONID=A4B7390062C98E719D1CBF5C198F835D-n2
验证
Session信息一致说明成功
Service.xml文件内容
[root@1xx tom]# cat server.xml
<?xmlversion='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
thiswork for additional information regarding copyright ownership.
The ASF licenses this file to You under theApache License, Version 2.0
(the "License"); you may not usethis 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 agreedto in writing, software
distributed under the License is distributedon an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
See the License for the specific languagegoverning permissions and
limitations under the License.
-->
<!--Note: A "Server" is not itselfa "Container", so you may not
define subcomponents such as"Valves" at this level.
Documentation at /docs/config/server.html
-->
<Serverport="8005" shutdown="SHUTDOWN">
<ListenerclassName="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at/docs/config/listeners.html
<ListenerclassName="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at/docs/apr.html -->
<ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on" />
<!--Initialize Jasper prior to webapps areloaded. Documentation at /docs/jasper-howto.html -->
<ListenerclassName="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use ofparticular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<ListenerclassName="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<ListenerclassName="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<!-- Global JNDI resources
Documentation at/docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that canalso be used by
UserDatabaseRealm to authenticateusers
-->
<Resource name="UserDatabase"auth="Container"
type="org.apache.catalina.UserDatabase"
description="User databasethat can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
<!-- A "Service" is a collectionof one or more "Connectors" that share
a single "Container"Note: A "Service" is notitself a "Container",
so you may not define subcomponents suchas "Valves" at this level.
Documentation at/docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a sharedexecutor, you can define one or more named thread pools-->
<!--
<Executorname="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150"minSpareThreads="4"/>
-->
<!-- A "Connector" representsan 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 onport 8080
-->
<Connector port="8080"protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
<!-- A "Connector" using theshared thread pool-->
<!--
<Connectorexecutor="tomcatThreadPool"
port="8080"protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
-->
<!-- Define a SSL HTTP/1.1 Connector onport 8443
This connector uses the BIOimplementation that requires the JSSE
style configuration. When using theAPR/native implementation, the
OpenSSL style configuration isrequired as described in the APR/native
documentation -->
<!--
<Connector port="8443"protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150"SSLEnabled="true" scheme="https" secure="true"
clientAuth="false"sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port8009 -->
<Connector port="8009"protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entrypoint (within Catalina) that processes
every request. The Engine implementation for Tomcat standalone
analyzes the HTTP headers includedwith the request, and passes them
on to the appropriate Host (virtualhost).
Documentation at/docs/config/engine.html -->
<!-- You should set jvmRoute to supportload-balancing via AJP ie :
<Engine name="Catalina"defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a lookat documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (referencedocumentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to preventattempts to guess user passwords
via a brute-force attack -->
<RealmclassName="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses theUserDatabase configured in the global JNDI
resources under the key"UserDatabase". Any edits
that are performed against thisUserDatabase are immediately
available for use by theRealm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>