{"id":57078,"date":"2025-08-15T07:29:57","date_gmt":"2025-08-14T23:29:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57078.html"},"modified":"2025-08-15T07:29:57","modified_gmt":"2025-08-14T23:29:57","slug":"%e4%bc%81%e4%b8%9a%e7%ba%a7web%e5%ba%94%e7%94%a8%e6%9c%8d%e5%8a%a1%e5%99%a8tomcat-7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57078.html","title":{"rendered":"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT"},"content":{"rendered":"<h2>Tomcat\u4ecb\u7ecd<\/h2>\n<p><span style=\"color:#333333\">Tomcat \u670d\u52a1\u5668\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684<\/span><span style=\"color:#333333\">Web <\/span><span style=\"color:#333333\">\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5c5e\u4e8e\u8f7b\u91cf\u7ea7\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5728\u4e2d\u5c0f\u578b\u7cfb\u7edf\u548c\u5e76\u53d1\u8bbf\u95ee\u7528\u6237\u4e0d\u662f\u5f88\u591a\u7684\u573a\u5408\u4e0b\u88ab\u666e\u904d\u4f7f\u7528&#xff0c;Tomcat <\/span><span style=\"color:#333333\">\u5177\u6709\u5904\u7406<\/span><span style=\"color:#333333\">HTML<\/span><span style=\"color:#333333\">\u9875\u9762\u7684\u529f\u80fd&#xff0c;\u5b83\u8fd8\u662f\u4e00\u4e2a<\/span><span style=\"color:#333333\">Servlet<\/span><span style=\"color:#333333\">\u548cJSP\u5bb9\u5668<\/span><\/p>\n<p><span style=\"color:#333333\">\u8d77\u59cb\u4e8eSUN \u516c\u53f8\u7684\u4e00\u4e2a<\/span><span style=\"color:#333333\">Servlet<\/span><span style=\"color:#333333\">\u7684\u53c2\u8003\u5b9e\u73b0\u9879\u76ee<\/span><span style=\"color:#333333\"> Java Web Server<\/span><span style=\"color:#333333\">&#xff0c;\u5f00\u53d1\u8005\u662f<\/span><span style=\"color:#333333\"> James Duncan Davidson<\/span><span style=\"color:#333333\">&#xff0c;<\/span><\/p>\n<p><span style=\"color:#333333\">\u57281999<\/span><span style=\"color:#333333\">\u5e74&#xff0c;\u5c06\u9879\u76ee\u8d21\u732e\u7ed9\u4e86<\/span><span style=\"color:#333333\">apache<\/span><span style=\"color:#333333\">\u8f6f\u4ef6\u57fa\u91d1\u4f1a&#xff08;<\/span><span style=\"color:#333333\">ASF<\/span><span style=\"color:#333333\">&#xff09;&#xff0c;\u548c<\/span><span style=\"color:#333333\">ASF<\/span><span style=\"color:#333333\">\u73b0\u6709\u7684\u9879\u76ee<\/span><span style=\"color:#333333\"> JServ <\/span><span style=\"color:#333333\">\u5408\u5e76&#xff0c;\u5e76\u5f00\u6e90\u6210\u4e3a\u9876\u7ea7\u9879\u76ee <\/span><\/p>\n<p><span style=\"color:#333333\">Tomcat <\/span><span style=\"color:#333333\">\u4ec5\u4ec5\u5b9e\u73b0\u4e86<\/span><span style=\"color:#333333\">Java EE<\/span><span style=\"color:#333333\">\u89c4\u8303\u4e2d\u4e0e<\/span><span style=\"color:#333333\">Servlet<\/span><span style=\"color:#333333\">\u3001<\/span><span style=\"color:#333333\">JSP<\/span><span style=\"color:#333333\">\u76f8\u5173\u7684\u7c7b\u5e93&#xff0c;\u662f<\/span><span style=\"color:#333333\">JavaEE<\/span><span style=\"color:#333333\">\u4e0d\u5b8c\u6574\u5b9e\u73b0\u3002 <\/span><\/p>\n<p><span style=\"color:#333333\">1999<\/span><span style=\"color:#333333\">\u5e74\u53d1\u5e03\u521d\u59cb\u7248\u672c\u662f<\/span><span style=\"color:#333333\">Tomcat 3.0<\/span><span style=\"color:#333333\">&#xff0c;\u5b9e\u73b0\u4e86<\/span><span style=\"color:#333333\">Servlet 2.2 <\/span><span style=\"color:#333333\">\u548c<\/span><span style=\"color:#333333\"> JSP 1.1<\/span><span style=\"color:#333333\">\u89c4\u8303\u3002 <\/span><\/p>\n<p><span style=\"color:#333333\">Tomcat 4.x<\/span><span style=\"color:#333333\">\u53d1\u5e03\u65f6&#xff0c;\u5185\u5efa\u4e86<\/span><span style=\"color:#333333\">Catalina<\/span><span style=\"color:#333333\">&#xff08;<\/span><span style=\"color:#333333\">Servlet<\/span><span style=\"color:#333333\">\u5bb9\u5668&#xff09;\u548c<\/span><span style=\"color:#333333\"> Jasper<\/span><span style=\"color:#333333\">&#xff08;<\/span><span style=\"color:#333333\">JSP engine<\/span><span style=\"color:#333333\">&#xff09;\u7b49 <\/span><\/p>\n<p><span style=\"color:#333333\">\u5f53\u524d<\/span><span style=\"color:#333333\"> Tomcat <\/span><span style=\"color:#333333\">\u7684\u6b63\u5f0f\u7248\u672c\u5df2\u7ecf\u66f4\u65b0\u5230<\/span><span style=\"color:#333333\"> 9.0.x <\/span><span style=\"color:#333333\">\u7248\u672c&#xff0c;\u4f46\u5f53\u524d\u4f01\u4e1a\u4e2d\u4e3b\u6d41\u7248\u672c\u4e3a<\/span><span style=\"color:#333333\"> 8.x <\/span><span style=\"color:#333333\">\u548c 7.x<\/span><\/p>\n<p><span style=\"color:#333333\">\u5b98\u7f51:<\/span><span style=\"color:#4183c4\">http:\/\/tomcat.apache.org\/<\/span><\/p>\n<p><span style=\"color:#333333\">\u5b98\u7f51\u6587\u6863: <\/span><span style=\"color:#4183c4\">https:\/\/tomcat.apache.org\/tomcat-8.5-doc\/index.html<\/span><\/p>\n<p><span style=\"color:#333333\">\u5e2e\u52a9\u6587\u6863:<\/span><span style=\"color:#4183c4\">https:\/\/cwiki.apache.org\/confluence\/display\/tomcat\/ <\/span><\/p>\n<p><span style=\"color:#4183c4\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0https:\/\/cwiki.apache.org\/confluence\/display\/tomcat\/FAQ<\/span><\/p>\n<h4>\u5b89\u88c5tomcat<\/h4>\n<h5>\u5b89\u88c5Java\u73af\u5883<\/h5>\n<p>[root&#064;tomcata ~]# dnf install java-1.8.0-openjdk.x86_64 -y<\/p>\n<p>\u67e5\u770bJava\u7248\u672c&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# java -version<br \/>\nopenjdk version &#034;1.8.0_462&#034;<br \/>\nOpenJDK Runtime Environment (build 1.8.0_462-b08)<br \/>\nOpenJDK 64-Bit Server VM (build 25.462-b08, mixed mode)<\/p>\n<p>\u67e5\u770bjava\u73af\u5883\u76ee\u5f55&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# which java<br \/>\n\/usr\/bin\/java<br \/>\n[root&#064;tomcata ~]# ll \/usr\/bin\/java<br \/>\nlrwxrwxrwx. 1 root root 22 8\u6708 11 21:12 \/usr\/bin\/java -&gt; \/etc\/alternatives\/j<br \/>\nava<\/p>\n<p>Java\u8fd0\u884c\u73af\u5883&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# cd \/etc\/alternatives\/jre<br \/>\n[root&#064;tomcata jre]# ls<br \/>\nASSEMBLY_EXCEPTION bin lib LICENSE THIRD_PARTY_README<\/p>\n<h5>\u5b89\u88c5\u5e76\u542f\u52a8tomcat<\/h5>\n<p>\u89e3\u538b\u5e76\u751f\u6210tomcat\u7a0b\u5e8f\u76ee\u5f55&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# tar zxf apache-tomcat-9.0.107.tar.gz -C \/usr\/local\/<br \/>\n[root&#064;tomcata ~]# cd \/usr\/local\/<br \/>\n[root&#064;tomcata local]# ls<br \/>\napache-tomcat-9.0.107 etc include lib64 sbin src<br \/>\nbin games lib libexec share<br \/>\n[root&#064;tomcata local]# mv apache-tomcat-9.0.107\/ tomcat<br \/>\n[root&#064;tomcata local]# ls<br \/>\nbin etc games include lib lib64 libexec sbin share src tomcat<br \/>\n[root&#064;tomcata local]#<\/p>\n<p>\u7528\u7f51\u7edc\u590d\u5236\u5230\u7b2c\u4e8c\u53f0\u4e0a<\/p>\n<p>[root&#064;tomcata local]# cd tomcat\/<br \/>\n[root&#064;tomcata tomcat]# cd bin\/<br \/>\n[root&#064;tomcata bin]# .\/startup.sh<\/p>\n<p>\u542f\u52a8tomcat&#xff1a;<\/p>\n<p>[root&#064;tomcata local]# cd tomcat\/<br \/>\n[root&#064;tomcata tomcat]# cd bin\/<br \/>\n[root&#064;tomcata bin]# .\/startup.sh<\/p>\n<p>tomcat\u7684\u6587\u4ef6\u7ed3\u6784\u548c\u7ec4\u6210<\/p>\n<p>\u76ee\u5f55\u7ed3\u6784<\/p>\n<p>\u76ee\u5f55 \u8bf4\u660e<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nbin \u670d\u52a1\u542f\u52a8\u3001\u505c\u6b62\u7b49\u76f8\u5173\u7a0b\u5e8f\u548c\u6587\u4ef6<br \/>\nconf \u914d\u7f6e\u6587\u4ef6<br \/>\nlib \u5e93\u76ee\u5f55<br \/>\nlogs \u65e5\u5fd7\u76ee\u5f55<br \/>\nwebapps \u5e94\u7528\u7a0b\u5e8f&#xff0c;\u5e94\u7528\u90e8\u7f72\u76ee\u5f55&#xff0c;\u76f8\u5f53\u4e8enginx\u7684\u9ed8\u8ba4\u53d1\u5e03\u76ee\u5f55<br \/>\nwork jsp \u7f16\u8bd1\u540e\u7684\u7ed3\u679c\u6587\u4ef6&#xff0c;\u5efa\u8bae\u63d0\u524d\u9884\u70ed\u8bbf\u95ee<\/p>\n<h5>\u67e5\u770b\u7aef\u53e3<\/h5>\n<p>[root&#064;tomcata ~]# netstat -antlupe | grep java<br \/>\ntcp6 0 0 :::8080 :::* LISTEN<br \/>\n0 61384 30180\/java<br \/>\ntcp6 0 0 127.0.0.1:8005 :::* LISTEN<br \/>\n0 62627 30180\/java<\/p>\n<h5><\/h5>\n<h5>\u8bbf\u95eetomcat<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"630\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814232955-689e7173bdd14.jpg\" width=\"1180\" \/><\/p>\n<h4>\u751f\u6210tomcat\u542f\u52a8\u6587\u4ef6<\/h4>\n<p>\u751f\u6210\u4e3b\u914d\u7f6e\u6587\u4ef6&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# vim \/usr\/local\/tomcat\/conf\/tomcat.conf<\/p>\n<p>JAVA_HOME&#061;\/etc\/alternatives\/jre<br \/>\n~<\/p>\n<p>\u751f\u6210\u542f\u52a8\u6587\u4ef6&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# vim \/lib\/systemd\/system\/tomcat.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Tomcat<br \/>\n#After&#061;syslog.target network.target remote-fs.target nss-lookup.target<br \/>\nAfter&#061;syslog.target network.target<\/p>\n<p>[Service]<br \/>\nType&#061;forking<br \/>\nEnvironmentFile&#061;\/usr\/local\/tomcat\/conf\/tomcat.conf<br \/>\nExecStart&#061;\/usr\/local\/tomcat\/bin\/startup.sh<br \/>\nExecStop&#061;\/usr\/local\/tomcat\/bin\/shutdown.sh<br \/>\nPrivateTmp&#061;true<br \/>\nUser&#061;tomcat<br \/>\nGroup&#061;tomcat<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Tomcat<br \/>\n#After&#061;syslog.target network.target remote-fs.target nss-lookup.target<br \/>\nAfter&#061;syslog.target network.target<\/p>\n<p>[Service]<br \/>\nType&#061;forking<br \/>\nEnvironmentFile&#061;\/usr\/local\/tomcat\/conf\/tomcat.conf<br \/>\nExecStart&#061;\/usr\/local\/tomcat\/bin\/startup.sh<br \/>\nExecStop&#061;\/usr\/local\/tomcat\/bin\/shutdown.sh<br \/>\nPrivateTmp&#061;true<br \/>\nUser&#061;tomcat<br \/>\nGroup&#061;tomcat<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u751f\u6210tomcat\u7528\u6237\u5e76\u8bbe\u5b9a\u8f6f\u4ef6\u5b89\u88c5\u76ee\u5f55\u6743\u9650&#xff1a;<\/p>\n<p>[root&#064;tomcatb ~]# useradd -s \/sbin\/nologin -M tomcat<br \/>\n[root&#064;tomcatb ~]# chown tomcat.tomcat \/usr\/local\/tomcat\/ -R<\/p>\n<p>\u7528\u542f\u52a8\u811a\u672c\u5f00\u542f\u670d\u52a1&#xff1a;<\/p>\n<p>[root&#064;tomcat-]# systemctl enable &#8211;now tomcat<\/p>\n<p>[root&#064;tomcatb ~]# systemctl start tomcat<\/p>\n<h3>\u5b9e\u73b0tomcat\u4e2d\u7684\u8d1f\u8f7d\u5747\u8861<\/h3>\n<p>\u524d\u7aef\u4e3b\u673a\u914d\u7f6enginx&#xff1a;<\/p>\n<p>[root&#064;nginx ~]# systemctl enable &#8211;now nginx.service<\/p>\n<p>vim \/etc\/nginx\/conf.d\/vhosts.conf<\/p>\n<p>upstream tomcat {<br \/>\nhash $$cookie_JSESSIONID;<br \/>\nserver 192.168.88.12:8080;<br \/>\nserver 192.168.88.13:8080;<br \/>\n}<br \/>\nserver{<br \/>\nlisten 80;<br \/>\nserver_name www.zk.org;<br \/>\nlocation ~\\\\.jsp$ {<br \/>\nproxy_pass http:\/\/tomcat;<br \/>\n}<br \/>\n}<\/p>\n<p>Memcached<br \/>\nMemcached \u53ea\u652f\u6301\u80fd\u5e8f\u5217\u5316\u7684\u6570\u636e\u7c7b\u578b&#xff0c;\u4e0d\u652f\u6301\u6301\u4e45\u5316&#xff0c;\u57fa\u4e8eKey-Value\u7684\u5185\u5b58\u7f13\u5b58\u7cfb\u7edfmemcached \u867d\u7136\u6ca1\u6709\u50cfredis\u6240\u5177\u5907\u7684\u6570\u636e\u6301\u4e45\u5316\u529f\u80fd&#xff0c;\u6bd4\u5982RDB\u548cAOF\u90fd\u6ca1\u6709&#xff0c;\u4f46\u662f\u53ef\u4ee5\u901a\u8fc7\u505a\u96c6\u7fa4\u540c\u6b65\u7684\u65b9\u5f0f&#xff0c; \u8ba9\u5404memcached\u670d\u52a1\u5668\u7684\u6570\u636e\u8fdb\u884c\u540c\u6b65&#xff0c;\u4ece\u800c\u5b9e\u73b0\u6570\u636e\u7684\u4e00\u81f4\u6027&#xff0c;\u5373\u4fdd\u8bc1\u5404memcached\u7684\u6570\u636e\u662f\u4e00\u6837 \u7684&#xff0c;\u5373\u4f7f\u6709\u4efb\u4f55\u4e00\u53f0 memcached \u53d1\u751f\u6545\u969c&#xff0c;\u53ea\u8981\u96c6\u7fa4\u4e2d\u6709\u4e00\u53f0 memcached \u53ef\u7528\u5c31\u4e0d\u4f1a\u51fa\u73b0\u6570\u636e\u4e22 \u5931&#xff0c;\u5f53\u5176\u4ed6memcached \u91cd\u65b0\u52a0\u5165\u5230\u96c6\u7fa4\u7684\u65f6\u5019,\u53ef\u4ee5\u81ea\u52a8\u4ece\u6709\u6570\u636e\u7684memcached \u5f53\u4e2d\u81ea\u52a8\u83b7\u53d6\u6570\u636e\u5e76 \u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n<h4>memcached\u7684\u5b89\u88c5\u4e0e\u542f\u52a8<\/h4>\n<p>[root&#064;tomcat8 ~]# dnf install memcached -y<\/p>\n<p>[root&#064;tomcatA ~]# vim \/etc\/sysconfig\/memcached<\/p>\n<p>PORT&#061;&#034;11211&#034;<br \/>\nUSER&#061;&#034;memcached&#034;<br \/>\nMAXCONN&#061;&#034;1024&#034;<br \/>\nCACHESIZE&#061;&#034;64&#034;<br \/>\nOPTIONS&#061;&#034;-1 0.0.0.1,:1&#034;<\/p>\n<p>[root&#064;tomcata ~]# systemctl enable &#8211;now memcached<br \/>\nCreated symlink<br \/>\n\/etc\/systemd\/system\/multi-user.target.wants\/memcached.service<br \/>\n\u2192 \/usr\/lib\/systemd\/system\/memcached.service.<br \/>\n[root&#064;tomcata ~]# netstat -antlupe | grep memcache<\/p>\n<h5>memcached \u64cd\u4f5c\u547d\u4ee4<\/h5>\n<p>\u4e94\u79cd\u57fa\u672c memcached \u547d\u4ee4\u6267\u884c\u6700\u7b80\u5355\u7684\u64cd\u4f5c\u3002\u8fd9\u4e9b\u547d\u4ee4\u548c\u64cd\u4f5c\u5305\u62ec&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0set\u00a0 \u00a0 \u00a0 \u00a0\u00a0add\u00a0 \u00a0 \u00a0 \u00a0 \u00a0replace\u00a0 \u00a0 \u00a0 \u00a0 \u00a0get\u00a0 \u00a0 \u00a0 \u00a0 delete<\/p>\n<p>#\u524d\u4e09\u4e2a\u547d\u4ee4\u662f\u7528\u4e8e\u64cd\u4f5c\u5b58\u50a8\u5728 memcached \u4e2d\u7684\u952e\u503c\u5bf9\u7684\u6807\u51c6\u4fee\u6539\u547d\u4ee4,\u90fd\u4f7f\u7528\u5982\u4e0b\u6240\u793a\u7684\u8bed\u6cd5&#xff1a;<br \/>\ncommand &lt;key&gt; &lt;flags&gt; &lt;expiration time&gt; &lt;bytes&gt;<br \/>\n&lt;value&gt;<\/p>\n<p>#\u53c2\u6570\u8bf4\u660e\u5982\u4e0b&#xff1a;<br \/>\ncommand set\/add\/replace<br \/>\nkey key \u7528\u4e8e\u67e5\u627e\u7f13\u5b58\u503c<br \/>\nflags \u53ef\u4ee5\u5305\u62ec\u952e\u503c\u5bf9\u7684\u6574\u578b\u53c2\u6570&#xff0c;\u5ba2\u6237\u673a\u4f7f\u7528\u5b83\u5b58\u50a8\u5173\u4e8e\u952e\u503c\u5bf9\u7684\u989d\u5916\u4fe1\u606f<br \/>\nexpiration time \u5728\u7f13\u5b58\u4e2d\u4fdd\u5b58\u952e\u503c\u5bf9\u7684\u65f6\u95f4\u957f\u5ea6&#xff08;\u4ee5\u79d2\u4e3a\u5355\u4f4d&#xff0c;0 \u8868\u793a\u6c38\u8fdc&#xff09;<br \/>\nbytes \u5728\u7f13\u5b58\u4e2d\u5b58\u50a8\u7684\u5b57\u8282\u6570<br \/>\nvalue \u5b58\u50a8\u7684\u503c&#xff08;\u59cb\u7ec8\u4f4d\u4e8e\u7b2c\u4e8c\u884c&#xff09;<\/p>\n<p>#\u589e\u52a0key&#xff0c;\u8fc7\u671f\u65f6\u95f4\u4e3a\u79d2&#xff0c;bytes\u4e3a\u5b58\u50a8\u6570\u636e\u7684\u5b57\u8282\u6570<br \/>\nadd key flags exptime bytes<\/p>\n<p>[root&#064;tomcatb ~]# dnf install telnet -y<\/p>\n<p>[root&#064;tomcat ~]# telnet localhost 11211<br \/>\nTrying ::1&#8230;<br \/>\nConnected to localhost.<br \/>\nEscape character is &#039;^]&#039;.<br \/>\n#\u589e\u52a0<br \/>\nadd leekey 0 60 4 #0 \u662f\u5426\u538b\u7f29 60 \u8fc7\u671f\u65f6\u95f4 4 \u5b57\u957f<br \/>\ntest<br \/>\nSTORED<\/p>\n<p>add leekey1 0 60 3<br \/>\nlee<br \/>\nSTORED<\/p>\n<p>#\u67e5\u770b<br \/>\nget leekey<br \/>\nVALUE leekey 0 4<br \/>\ntest<\/p>\n<p>get leekey1<br \/>\nVALUE leekey1 0 3<br \/>\nlee<\/p>\n<p>#\u6539<br \/>\nset leekey 0 60 5<br \/>\ntest1<br \/>\nSTORED<br \/>\nget leekey<br \/>\nVALUE leekey 0 5<br \/>\ntest1<br \/>\nEND<br \/>\nadd leekey1 0 60 4<br \/>\ntest<\/p>\n<p>#\u5220\u9664<br \/>\ndelete leekey<br \/>\nDELETED<br \/>\nget leekey<br \/>\nEND<br \/>\nget leekey1<br \/>\nVALUE leekey1 0 3<br \/>\nlee<\/p>\n<p>#\u6e05\u7a7a<br \/>\nflush_all<br \/>\nOK<br \/>\nget leekey1<br \/>\nEND<\/p>\n<h3>\u793a\u4f8bsession \u5171\u4eab\u670d\u52a1\u5668<\/h3>\n<p>msm&#xff08;memcached session manager&#xff09;\u63d0\u4f9b\u5c06Tomcat\u7684session\u4fdd\u6301\u5230memcached\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u53ef\u7528\u3002 \u9879\u76ee\u65e9\u671f\u6258\u7ba1\u5728google code,\u76ee\u524d\u5728Github github\u7f51\u7ad9\u94fe\u63a5: https:\/\/github.com\/magro\/memcached-session-manager<\/p>\n<p>\u5b89\u88c5<\/p>\n<p>\u53c2\u8003\u94fe\u63a5: https:\/\/github.com\/magro\/memcached-session-manager\/wiki\/SetupAndConfiguration<\/p>\n<p>\u5c06spymemcached.jar\u3001memcached-session-manage\u3001kyro\u76f8\u5173\u7684jar\u6587\u4ef6\u90fd\u653e\u5230Tomcat\u7684lib\u76ee\u5f55 \u4e2d&#xff0c;\u8fd9\u4e2a\u76ee\u5f55\u662f $CATALINA_HOME\/lib\/ &#xff0c;\u5bf9\u5e94\u672c\u6b21\u5b89\u88c5\u5c31\u662f\/usr\/local\/tomcat\/lib\/\u3002<\/p>\n<p>\/usr\/local\/tomcat\/lib\/\u4e2d\u52a0\u5165\u8fd9\u4e9b&#x1f447;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"558\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814232956-689e71741abad.png\" width=\"548\" \/><\/p>\n<p>t1\u548cm1\u90e8\u7f72\u53ef\u4ee5\u5728\u4e00\u53f0\u4e3b\u673a\u4e0a&#xff0c;t2\u548cm2\u90e8\u7f72\u4e5f\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u3002<\/p>\n<p>\u5f53\u65b0\u7528\u6237\u53d1\u8bf7\u6c42\u5230Tomcat1\u65f6, Tomcat1\u751f\u6210session\u8fd4\u56de\u7ed9\u7528\u6237\u7684\u540c\u65f6,\u4e5f\u4f1a\u540c\u65f6\u53d1\u7ed9memcached2\u5907\u4efd\u3002\u5373Tomcat1 session\u4e3a\u4e3bsession&#xff0c;memcached2 session\u4e3a\u5907\u7528session&#xff0c;\u4f7f\u7528memcached\u76f8\u5f53\u4e8e \u5907\u4efd\u4e86\u4e00\u4efdSession<\/p>\n<p>\u5982\u679cTomcat1\u53d1\u73b0memcached2 \u5931\u8d25,\u65e0\u6cd5\u5907\u4efdSession\u5230memcached2,\u5219\u5c06Sessoin\u5907\u4efd\u5b58\u653e\u5728 memcached1\u4e2d<\/p>\n<p>\u4e24\u540e\u7aef\u670d\u52a1\u5668\u914d\u7f6e&#xff1a;<\/p>\n<p>[root&#064;tomcata ~]# vim \/usr\/local\/tomcat\/conf\/context.xml<\/p>\n<p>limitations under the License.<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211; The contents of this file will be loaded for each web application &#8211;&gt;<br \/>\n&lt;Context&gt;<br \/>\n&lt;!&#8211; Default set of monitored resources. If one of these changes, the<br \/>\n&#8211;&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211; web application will be reloaded.<br \/>\n&lt;WatchedResource&gt;WEB-INF\/web.xml&lt;\/WatchedResource&gt;<br \/>\n&lt;WatchedResource&gt;WEB-INF\/tomcat-web.xml&lt;\/WatchedResource&gt;<br \/>\n&lt;WatchedResource&gt;$${catalina.base}\/conf\/web.xml&lt;\/WatchedResource&gt;<br \/>\n&lt;!&#8211; Uncomment this to disable session persistence across Tomcat restarts<br \/>\n-&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Manager pathname&#061;&#034;&#034; \/&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;Manager className&#061;&#034;de.javakaffee.web.msm.MemcachedBackupSessionManager<br \/>\nmemcachedNodes&#061;&#034;n1:172.25.254.10:11211,n2:172.25.254.20:11211&#034;<br \/>\nfailoverNodes&#061;&#034;n1&#034;<br \/>\nrequestUriIgnorePattern&#061;&#034;.*\\\\.(ico|png|gif|jpg|css|js)$$&#034;<br \/>\ntranscoderFactoryClass&#061;&#034;de.javakaffee.web.msm.serializer.kryo.KryoTransc<br \/>\noderFactory&#034;<br \/>\n\/&gt;<br \/>\n&lt;\/Context&gt;<br \/>\n~<br \/>\n~<br \/>\n~<\/p>\n<p>[root&#064;tomcata ~]# dnf install memcached -y<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb898\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf25\u6b21\u3002Tomcat \u670d\u52a1\u5668\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684Web\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5c5e\u4e8e\u8f7b\u91cf\u7ea7\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5728\u4e2d\u5c0f\u578b\u7cfb\u7edf\u548c\u5e76\u53d1\u8bbf\u95ee\u7528\u6237\u4e0d\u662f\u5f88\u591a\u7684\u573a\u5408\u4e0b\u88ab\u666e\u904d\u4f7f\u7528\uff0cTomcat\u5177\u6709\u5904\u7406HTML\u9875\u9762\u7684\u529f\u80fd\uff0c\u5b83\u8fd8\u662f\u4e00\u4e2aServlet\u548cJSP\u5bb9\u5668\u8d77\u59cb\u4e8eSUN \u516c\u53f8\u7684\u4e00\u4e2aServlet\u7684\u53c2\u8003\u5b9e\u73b0\u9879\u76ee\uff0c\u5f00\u53d1\u8005\u662f\u57281999\u5e74\uff0c\u5c06\u9879\u76ee\u8d21\u732e\u7ed9\u4e86apache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\uff08ASF\uff09\uff0c\u548cASF\u73b0\u6709\u7684\u9879\u76eeJServ\u5408\u5e76\uff0c\u5e76\u5f00\u6e90\u6210\u4e3a\u9876\u7ea7\u9879\u76eeTomcat\u4ec5\u4ec5\u5b9e\u73b0\u4e86Java EE\u89c4\u8303\u4e2d\u4e0eServletJSP\u3002<\/p>\n","protected":false},"author":2,"featured_media":57076,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[223],"topic":[],"class_list":["post-57078","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-tomcat"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/57078.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb898\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf25\u6b21\u3002Tomcat \u670d\u52a1\u5668\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684Web\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5c5e\u4e8e\u8f7b\u91cf\u7ea7\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5728\u4e2d\u5c0f\u578b\u7cfb\u7edf\u548c\u5e76\u53d1\u8bbf\u95ee\u7528\u6237\u4e0d\u662f\u5f88\u591a\u7684\u573a\u5408\u4e0b\u88ab\u666e\u904d\u4f7f\u7528\uff0cTomcat\u5177\u6709\u5904\u7406HTML\u9875\u9762\u7684\u529f\u80fd\uff0c\u5b83\u8fd8\u662f\u4e00\u4e2aServlet\u548cJSP\u5bb9\u5668\u8d77\u59cb\u4e8eSUN \u516c\u53f8\u7684\u4e00\u4e2aServlet\u7684\u53c2\u8003\u5b9e\u73b0\u9879\u76ee\uff0c\u5f00\u53d1\u8005\u662f\u57281999\u5e74\uff0c\u5c06\u9879\u76ee\u8d21\u732e\u7ed9\u4e86apache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\uff08ASF\uff09\uff0c\u548cASF\u73b0\u6709\u7684\u9879\u76eeJServ\u5408\u5e76\uff0c\u5e76\u5f00\u6e90\u6210\u4e3a\u9876\u7ea7\u9879\u76eeTomcat\u4ec5\u4ec5\u5b9e\u73b0\u4e86Java EE\u89c4\u8303\u4e2d\u4e0eServletJSP\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57078.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T23:29:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814232955-689e7173bdd14.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57078.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57078.html\",\"name\":\"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T23:29:57+00:00\",\"dateModified\":\"2025-08-14T23:29:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57078.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57078.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57078.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/57078.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb898\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf25\u6b21\u3002Tomcat \u670d\u52a1\u5668\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684Web\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5c5e\u4e8e\u8f7b\u91cf\u7ea7\u5e94\u7528\u670d\u52a1\u5668\uff0c\u5728\u4e2d\u5c0f\u578b\u7cfb\u7edf\u548c\u5e76\u53d1\u8bbf\u95ee\u7528\u6237\u4e0d\u662f\u5f88\u591a\u7684\u573a\u5408\u4e0b\u88ab\u666e\u904d\u4f7f\u7528\uff0cTomcat\u5177\u6709\u5904\u7406HTML\u9875\u9762\u7684\u529f\u80fd\uff0c\u5b83\u8fd8\u662f\u4e00\u4e2aServlet\u548cJSP\u5bb9\u5668\u8d77\u59cb\u4e8eSUN \u516c\u53f8\u7684\u4e00\u4e2aServlet\u7684\u53c2\u8003\u5b9e\u73b0\u9879\u76ee\uff0c\u5f00\u53d1\u8005\u662f\u57281999\u5e74\uff0c\u5c06\u9879\u76ee\u8d21\u732e\u7ed9\u4e86apache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\uff08ASF\uff09\uff0c\u548cASF\u73b0\u6709\u7684\u9879\u76eeJServ\u5408\u5e76\uff0c\u5e76\u5f00\u6e90\u6210\u4e3a\u9876\u7ea7\u9879\u76eeTomcat\u4ec5\u4ec5\u5b9e\u73b0\u4e86Java EE\u89c4\u8303\u4e2d\u4e0eServletJSP\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/57078.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T23:29:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814232955-689e7173bdd14.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57078.html","url":"https:\/\/www.wsisp.com\/helps\/57078.html","name":"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T23:29:57+00:00","dateModified":"2025-08-14T23:29:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57078.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57078.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57078.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f01\u4e1a\u7ea7WEB\u5e94\u7528\u670d\u52a1\u5668TOMCAT"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=57078"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57078\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/57076"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57078"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}