{"id":54261,"date":"2025-08-13T00:20:34","date_gmt":"2025-08-12T16:20:34","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54261.html"},"modified":"2025-08-13T00:20:34","modified_gmt":"2025-08-12T16:20:34","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%e5%85%a5%e9%97%a8%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54261.html","title":{"rendered":"\u4f01\u4e1a\u7ea7web\u5e94\u7528\u670d\u52a1\u5668TOMCAT\u5165\u95e8\u8be6\u89e3"},"content":{"rendered":"<h2>\u4e00. web<\/h2>\n<h3>1.1 \u4e3a\u4ec0\u4e48\u201c\u7f51\u9875\u91cc\u7684\u5e94\u7528\u201d\u2248\u201cTomcat \u91cc\u7684\u5e94\u7528\u201d&#xff1f;<\/h3>\n<li>\n<p>\u6d4f\u89c8\u5668\u53ea\u8ba4\u8bc6 HTTP\u3002<br \/>\n\u4f60\u5728\u5730\u5740\u680f\u6572 http:\/\/xxx.com\/login&#xff0c;\u6d4f\u89c8\u5668\u53d1\u51fa\u53bb\u7684\u5c31\u662f\u4e00\u6bb5\u7eaf\u6587\u672c HTTP \u62a5\u6587\u3002<\/p>\n<\/li>\n<li>\n<p>Tomcat \u5929\u751f\u5403 HTTP\u3002<br \/>\n\u5b83\u5b9e\u73b0\u4e86 JavaEE \u91cc\u7684 Servlet \u89c4\u8303&#xff1a;\u628a HTTP \u8bf7\u6c42\u5c01\u88c5\u6210 HttpServletRequest \u2192 \u4ea4\u7ed9\u7a0b\u5e8f\u5458\u5199\u7684 LoginServlet \u2192 \u751f\u6210 HTML \u2192 \u518d\u6309 HTTP \u683c\u5f0f\u8fd4\u56de\u3002<br \/>\n\u4e8e\u662f\u201c\u6d4f\u89c8\u5668 \u2194 HTTP \u2194 Tomcat \u2194 \u4f60\u7684\u4e1a\u52a1\u4ee3\u7801\u201d\u8fd9\u4e00\u6761\u8def\u5c31\u6253\u901a\u4e86\u3002<\/p>\n<\/li>\n<li>\n<p>\u56e0\u6b64&#xff0c;\u53ea\u8981\u6700\u7ec8\u662f\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7684&#xff0c;\u51e0\u4e4e\u90fd\u53ef\u4ee5\u8bf4\u201c\u7531 Tomcat&#xff08;\u6216\u540c\u7c7b Web \u670d\u52a1\u5668&#xff09;\u5b9e\u73b0\u201d\u3002<\/p>\n<\/li>\n<hr \/>\n<h3>1.2 B\/S \u4e0e C\/S \u7684\u201c\u7a7a\u95f4\u4e4b\u4e89\u201d<\/h3>\n<table>\n<tr>\u7ef4\u5ea6C\/SB\/S<\/tr>\n<tbody>\n<tr>\n<td>\u5ba2\u6237\u7aef<\/td>\n<td>\u5fc5\u987b\u5b89\u88c5\u4e13\u95e8\u8f6f\u4ef6&#xff08;QQ\u3001Steam\u3001\u94f6\u884c U \u76fe&#xff09;<\/td>\n<td>\u53ea\u7528\u6d4f\u89c8\u5668<\/td>\n<\/tr>\n<tr>\n<td>\u5347\u7ea7<\/td>\n<td>\u6bcf\u53f0\u7535\u8111\u90fd\u8981\u91cd\u65b0\u88c5\u5305<\/td>\n<td>\u6539\u670d\u52a1\u5668\u5c31\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u78c1\u76d8\u5360\u7528<\/td>\n<td>\u5ba2\u6237\u7aef\u51e0\u767e MB \u8d77\u6b65<\/td>\n<td>0 MB&#xff08;\u6d4f\u89c8\u5668\u4e0d\u7b97&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc\u534f\u8bae<\/td>\n<td>\u968f\u610f&#xff08;TCP\/UDP\u3001\u81ea\u5b9a\u4e49&#xff09;<\/td>\n<td>\u53ea\u7528 HTTP\/HTTPS<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u8868\u573a\u666f<\/td>\n<td>\u6e38\u620f\u3001\u5b9e\u65f6\u4ea4\u6613<\/td>\n<td>\u8bba\u575b\u3001OA\u3001\u535a\u5ba2\u3001\u540e\u53f0\u7ba1\u7406<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ed3\u8bba&#xff1a;<br \/>\n\u201c\u8282\u7701\u78c1\u76d8\u7a7a\u95f4\u201d\u53ea\u662f B\/S \u6700\u76f4\u89c2\u7684\u4f18\u52bf&#xff0c;\u771f\u6b63\u8ba9\u5b83\u7edf\u6cbb\u4e16\u754c\u7684\u662f \u96f6\u5b89\u88c5\u3001\u96f6\u7ef4\u62a4\u3001\u8de8\u5e73\u53f0\u3002<\/p>\n<hr \/>\n<h3>1.3\u3001\u4e09\u5927\u6838\u5fc3\u6280\u672f\u5230\u5e95\u5404\u5e72\u4ec0\u4e48&#xff1f;<\/h3>\n<li>\n<p>HTML&#xff08;\u9aa8\u67b6&#xff09;<br \/>\n\u7eaf\u6587\u672c\u7684\u6807\u7b7e\u79ef\u6728&#xff1a;&lt;form&gt;\u3001&lt;input&gt;\u3001&lt;table&gt;\u2026\u2026\u544a\u8bc9\u6d4f\u89c8\u5668\u201c\u8fd9\u91cc\u6709\u4e2a\u767b\u5f55\u6846&#xff0c;\u90a3\u91cc\u653e\u4e2a\u6309\u94ae\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>CSS&#xff08;\u76ae\u80a4&#xff09;<br \/>\n\u540c\u4e00\u6bb5 HTML&#xff0c;\u53ef\u4ee5\u6362\u4e0d\u540c CSS \u7acb\u523b\u53d8\u6210\u201c\u6781\u7b80\u98ce\u201d\u6216\u201c\u8d5b\u535a\u670b\u514b\u201d\u3002<br \/>\n\u4f8b&#xff1a;<\/p>\n<p>css<\/p>\n<p>\u590d\u5236<\/p>\n<p>input[type&#061;text] {<br \/>\n    border-radius: 8px;<br \/>\n    box-shadow: 0 0 10px #00f;<br \/>\n}\n<\/li>\n<li>\n<p>JavaScript&#xff08;\u808c\u8089&#xff09;<br \/>\n\u8ba9\u9875\u9762\u201c\u52a8\u8d77\u6765\u201d&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8868\u5355\u5b9e\u65f6\u6821\u9a8c&#xff08;\u5931\u7126\u5c31\u63d0\u793a\u201c\u5bc6\u7801\u592a\u77ed\u201d&#xff09;<\/p>\n<\/li>\n<li>\n<p>Ajax \u5f02\u6b65\u62c9\u6570\u636e&#xff08;\u4e0b\u9762\u7ec6\u8bb2&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u52a8\u753b\u3001\u6e38\u620f\u3001\u53ef\u89c6\u5316\u2026\u2026<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<p>\u6d4f\u89c8\u5668\u62ff\u5230 .html \u2192 \u8fb9\u89e3\u6790\u8fb9\u5411\u670d\u52a1\u5668\u8981 .css\u3001.js \u2192 \u6e32\u67d3\u5f15\u64ce\u628a\u4e09\u8005\u62fc\u6210\u4f60\u770b\u5230\u7684\u50cf\u7d20\u3002<\/p>\n<hr \/>\n<h3>1.4\u3001\u540c\u6b65\u4ea4\u4e92&#xff1a;\u6574\u9875\u5237\u65b0\u4e4b\u75db<\/h3>\n<p>\u7ecf\u5178\u573a\u666f&#xff1a;\u6ce8\u518c\u9875\u9762<br \/>\n\u6d41\u7a0b&#xff1a;<\/p>\n<li>\n<p>\u586b 8 \u4e2a\u5b57\u6bb5 \u2192 \u70b9\u3010\u63d0\u4ea4\u3011<\/p>\n<\/li>\n<li>\n<p>\u6d4f\u89c8\u5668\u6574\u9875 POST \u7ed9\u670d\u52a1\u5668<\/p>\n<\/li>\n<li>\n<p>\u670d\u52a1\u5668\u53d1\u73b0\u201c\u4e24\u6b21\u5bc6\u7801\u4e0d\u4e00\u81f4\u201d<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u4e00\u4e2a\u5168\u65b0 HTML \u9875\u9762<\/p>\n<\/li>\n<li>\n<p>\u6d4f\u89c8\u5668\u91cd\u65b0\u6e32\u67d3 \u2192 \u524d 7 \u4e2a\u5b57\u6bb5\u5168\u6e05\u7a7a<br \/>\n\u8fd9\u5c31\u662f\u201c\u540c\u6b65\u201d\u2014\u2014\u4e00\u6b21 HTTP \u8bf7\u6c42\u5bf9\u5e94\u4e00\u6b21\u5b8c\u6574\u9875\u9762\u5237\u65b0\u3002<\/p>\n<\/li>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5e26\u5bbd\u6d6a\u8d39&#xff08;CSS\/JS\/\u56fe\u7247\u5168\u90e8\u91cd\u4f20&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u4f53\u9a8c\u5dee&#xff08;\u7528\u6237\u60f3\u9a82\u4eba&#xff09;<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>1.5\u3001\u5f02\u6b65\u4ea4\u4e92&#xff1a;Ajax \u7684\u9b54\u6cd5<\/h3>\n<li>\n<p>\u5173\u952e\u6280\u672f&#xff1a;XMLHttpRequest&#xff08;\u6d4f\u89c8\u5668\u5185\u7f6e API&#xff09;\u3002<br \/>\n\u6d4f\u89c8\u5668\u6084\u6084\u518d\u5f00\u4e00\u6761 HTTP \u8fde\u63a5&#xff0c;\u53ea\u62ff\u56de \u9700\u8981\u7684\u90a3\u4e00\u5c0f\u5757\u6570\u636e&#xff08;JSON\/HTML \u7247\u6bb5&#xff09;&#xff0c;\u7136\u540e\u7528 JS \u628a\u9875\u9762\u5c40\u90e8\u66f4\u65b0\u3002<br \/>\n\u7528\u6237\u65e0\u611f\u5237\u65b0\u3002<\/p>\n<\/li>\n<li>\n<p>\u6d41\u7a0b\u5bf9\u6bd4&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u540c\u6b65&#xff1a;\u586b\u8868\u5355 \u2192 \u63d0\u4ea4 \u2192 \u7b49\u5f85 \u2192 \u6574\u9875\u5237\u65b0<\/p>\n<\/li>\n<li>\n<p>\u5f02\u6b65&#xff1a;\u8f93\u5b8c\u90ae\u7bb1 \u2192 JS \u7acb\u5373\u53d1\u8bf7\u6c42 \/checkEmail?email&#061;xxx \u2192 \u8fd4\u56de {&#034;ok&#034;:false,&#034;msg&#034;:&#034;\u5df2\u6ce8\u518c&#034;} \u2192 \u9875\u9762\u53ea\u628a\u63d0\u793a\u5b57\u53d8\u7ea2&#xff0c;\u5176\u4ed6\u4e0d\u52a8<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5173\u952e\u8bcd&#xff1a;<\/p>\n<ul>\n<li>\n<p>Ajax&#xff08;Asynchronous JavaScript And XML&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u73b0\u5728\u591a\u7528 JSON \u4ee3\u66ff XML<\/p>\n<\/li>\n<li>\n<p>\u884d\u751f&#xff1a;Fetch API\u3001Axios\u3001jQuery.ajax()<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h3>1.6\u3001\u4ece\u201c\u4ee3\u7801\u201d\u5230\u201c\u7f51\u9875\u201d\u7684\u5b8c\u6574\u94fe\u8def<\/h3>\n<li>\n<p>\u4f60\u5728 IDEA \u5199 LoginServlet.java&#xff0c;\u7ee7\u627f HttpServlet&#xff0c;\u5904\u7406 POST \/login\u3002<\/p>\n<\/li>\n<li>\n<p>mvn package \u6253\u6210 war \u2192 \u6254\u5230 Tomcat \u7684 webapps\u3002<\/p>\n<\/li>\n<li>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee http:\/\/\u57df\u540d\/login.html\u3002<\/p>\n<\/li>\n<li>\n<p>Tomcat \u628a login.html \u5410\u7ed9\u6d4f\u89c8\u5668&#xff08;HTML&#043;CSS&#043;JS&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u7528\u6237\u586b\u5b8c\u8d26\u53f7\u5bc6\u7801&#xff0c;JS \u7528 Ajax POST \/login\u3002<\/p>\n<\/li>\n<li>\n<p>LoginServlet \u67e5\u8be2\u6570\u636e\u5e93 \u2192 \u8fd4\u56de JSON {status:0,token:xxx}\u3002<\/p>\n<\/li>\n<li>\n<p>JS \u628a token \u5b58 localStorage&#xff0c;\u9875\u9762\u8df3\u8f6c\u5230 \/index.html&#xff0c;\u5168\u7a0b\u65e0\u6574\u9875\u5237\u65b0\u3002<\/p>\n<\/li>\n<h3>\u4e8c\u00a0tomcat<\/h3>\n<p>#\u5b89\u88c5java\u73af\u5883<br \/>\n[root&#064;tomcat ~]# yum install java-1.8.0-openjdk.x86_64 -y<br \/>\n #\u67e5\u770bjava\u7248\u672c<br \/>\n[root&#064;tomcatA ~]# java -version<br \/>\n openjdk version &#034;1.8.0_402&#034;<br \/>\n OpenJDK Runtime Environment (build 1.8.0_402-b06)<br \/>\n OpenJDK 64-Bit Server VM (build 25.402-b06, mixed mode)<br \/>\n #\u67e5\u770bjava\u7684\u73af\u5883\u76ee\u5f55<br \/>\n[root&#064;tomcatA ~]# which  java<br \/>\n \/usr\/bin\/java<br \/>\n [root&#064;tomcatA ~]# ll \/usr\/bin\/java<br \/>\n lrwxrwxrwx 1 root root 22 Jul 30 10:41 \/usr\/bin\/java -&gt; \/etc\/alternatives\/java<br \/>\n #java\u7684\u8fd0\u884c\u73af\u5883<br \/>\n[root&#064;tomcatA ~]# cd \/etc\/alternatives\/jre<br \/>\n [root&#064;tomcatA jre]# ls<br \/>\n ASSEMBLY_EXCEPTION  bin  lib  LICENSE  THIRD_PARTY_README<\/p>\n<p>#\u89e3\u538b\u5e76\u751f\u6210tomcat\u7684\u7a0b\u5e8f\u76ee\u5f55<br \/>\n[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 \/>\n apache-tomcat-9.0.107  bin  etc  games  include  lib  lib64  libexec  sbin  share<br \/>\nsrc<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 #\u542f\u52a8tomcat<br \/>\n [root&#064;tomcatA local]# cd tomcat\/<br \/>\n [root&#064;tomcatA tomcat]# cd bin\/<br \/>\n [root&#064;tomcatA bin]# ls<br \/>\n bootstrap.jar<br \/>\ncommons-daemon-native.tar.gz  makebase.sh<br \/>\njuli.jar<br \/>\n catalina.bat<br \/>\nnative.tar.gz<br \/>\n catalina.sh<br \/>\nconfigtest.bat<br \/>\nconfigtest.sh<br \/>\nwrapper.bat<br \/>\n catalina-tasks.xml  daemon.sh<br \/>\nwrapper.sh<br \/>\n ciphers.bat<br \/>\nciphers.sh<br \/>\ndigest.bat<br \/>\ndigest.sh<br \/>\ncommons-daemon.jar  makebase.bat<br \/>\ntomcat<br \/>\nsetclasspath.bat  tomcat<br \/>\nsetclasspath.sh<br \/>\nshutdown.bat<br \/>\nshutdown.sh<br \/>\nstartup.bat<br \/>\nstartup.sh<br \/>\n [root&#064;tomcatA bin]# .\/startup.sh<br \/>\n Using CATALINA_BASE:   \/usr\/local\/tomcat<br \/>\n Using CATALINA_HOME:   \/usr\/local\/tomcat<br \/>\n Using CATALINA_TMPDIR: \/usr\/local\/tomcat\/temp<br \/>\n Using JRE_HOME:<br \/>\n\/usr<br \/>\n tool<br \/>\ntool<br \/>\nversion.bat<br \/>\n version.sh<br \/>\n Using CLASSPATH:<br \/>\n\/usr\/local\/tomcat\/bin\/bootstrap.jar:\/usr\/local\/tomcat\/bin\/tomcat-juli.jar<br \/>\n Using CATALINA_OPTS:<br \/>\n Tomcat started.<\/p>\n<p>[root&#064;tomcat ~]# netstat -antlupe | grep java \u00a0 \u00a0 \u00a0<\/p>\n<p>\u5b89\u88c5JAVA\u73af\u5883<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"714\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162030-689b69ce2da24.png\" width=\"1163\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"502\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162030-689b69ceadd02.png\" width=\"1089\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"138\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cf32e33.png\" width=\"212\" \/><\/p>\n<p>java\u7248\u672c\u67e5\u770b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"135\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cf3edfe.png\" width=\"833\" \/><\/p>\n<p>\u67e5\u770bjava\u771f\u6b63\u7684\u73af\u5883\u76ee\u5f55<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"57\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cf55202.png\" width=\"449\" \/><\/p>\n<p>jre\u771f\u6b63\u7684\u8fd0\u884c\u73af\u5883<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"86\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cf6923e.png\" width=\"1124\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"208\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cf85773.png\" width=\"968\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cfa2ff9.png\" width=\"843\" \/><\/p>\n<p>\u8981\u628ajava\u7684\u8fd0\u884c\u73af\u5883\u6307\u5b9a\u7ed9Tomcat<\/p>\n<p>\u5b89\u88c5tomcat&#xff1a;<\/p>\n<p>\u89e3\u538b\u5e76\u91cd\u547d\u540d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"164\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cfb4e73.png\" width=\"1075\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"163\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162031-689b69cfd404e.png\" width=\"1084\" \/><\/p>\n<p>\u8fdb\u5165\u76ee\u5f55\u5e76\u542f\u52a8\u5b83<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"137\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162032-689b69d00c51c.png\" width=\"1016\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"265\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162032-689b69d029804.png\" width=\"1147\" \/><\/p>\n<p>\u542f\u52a8\u6210\u529f\u540e\u67e5\u770b\u7aef\u53e3<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"142\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162032-689b69d06c46c.png\" width=\"1118\" \/><\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"626\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162032-689b69d0a0654.png\" width=\"1301\" \/><\/p>\n<p>\u5728\u53e6\u4e00\u53f0\u4e3b\u673a\u4e0a\u4e5f\u8981\u505a<\/p>\n<p>\u7b80\u5355\u4e00\u70b9\u5c31\u76f4\u63a5\u590d\u5236\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"28\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d120349.png\" width=\"587\" \/><\/p>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"30\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d130a5c.png\" width=\"877\" \/><\/p>\n<h4>\u7f16\u5199\u542f\u52a8\u7a0b\u5e8f<\/h4>\n<\/p>\n<p>\u521b\u5efa\u4e13\u7528\u7cfb\u7edf\u7528\u6237<\/p>\n<p>useradd -r -s \/sbin\/nologin -M tomcat<\/p>\n<hr \/>\n<p>\u7edf\u4e00\u76ee\u5f55\u6743\u9650<\/p>\n<p>chown -R tomcat:tomcat \/usr\/local\/tomcat<\/p>\n<hr \/>\n<p>\u5199\u5165\u73af\u5883\u53d8\u91cf&#xff08;Tomcat \u4e13\u7528&#xff09;<\/p>\n<hr \/>\n<p>\u6587\u4ef6&#xff1a;\/usr\/local\/tomcat\/conf\/tomcat.conf<br \/>\n\u5185\u5bb9\u53ea\u6709\u4e00\u884c&#xff1a;<\/p>\n<p>JAVA_HOME&#061;\/etc\/alternatives\/jre<\/p>\n<hr \/>\n<p>\u751f\u6210 systemd \u5355\u5143\u6587\u4ef6<\/p>\n<hr \/>\n<p>\u6587\u4ef6&#xff1a;\/lib\/systemd\/system\/tomcat.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Apache Tomcat<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<hr \/>\n<p>\u542f\u52a8\u5e76\u8bbe\u4e3a\u5f00\u673a\u81ea\u542f<\/p>\n<p>systemctl daemon-reload<br \/>\nsystemctl enable &#8211;now tomcat   # \u7acb\u5373\u542f\u52a8 &#043; \u5f00\u673a\u81ea\u542f<br \/>\nsystemctl status tomcat         # \u67e5\u770b\u8fd0\u884c\u72b6\u6001<\/p>\n<hr \/>\n<p>\u4e00\u952e\u9a8c\u8bc1<\/p>\n<p>ss -lntp | grep java            # \u5e94\u770b\u5230 8080 \u7aef\u53e3<br \/>\ncurl -I http:\/\/localhost:8080   # \u8fd4\u56de 200 OK<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"448\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d14132c.png\" width=\"1056\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"435\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d1927a4.png\" width=\"1013\" \/><\/p>\n<p>\u5185\u5bb9\u4e2d\u5236\u5b9a\u7528\u6237\u4e86&#xff0c;\u6240\u4ee5\u8fd9\u91cc\u8981\u5efa\u7acb\u7528\u6237<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"39\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d1ba393.png\" width=\"801\" \/><\/p>\n<p>\u8981\u7ed9tomcat\u6307\u5b9ajava\u7684\u8fd0\u884c\u73af\u5883<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"35\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162033-689b69d1cb0d8.png\" width=\"837\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"44\" src=\"2025-08-13uvuohev1mxv.png\" width=\"510\" \/><\/p>\n<p>\u62a5\u9519\u60c5\u51b5&#xff1a;<\/p>\n<p>\u6b64\u65f6\u662f\u6ca1\u6709\u8fd0\u884c\u8fd9\u4e2a\u6587\u4ef6\u7684\u6743\u9650<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"67\" src=\"2025-08-130rtxcpbojsv.png\" width=\"877\" \/><\/p>\n<p>\u67e5\u770b\u6743\u9650<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"55\" src=\"2025-08-13ugb0jyall5c.png\" width=\"821\" \/><\/p>\n<p>\u52a0\u6743\u9650<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"40\" src=\"2025-08-13lsbf0corx4t.png\" width=\"698\" \/><\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"85\" src=\"2025-08-13l4xergfw0vq.png\" width=\"1143\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"146\" src=\"2025-08-13fti404tjb0w.png\" width=\"1087\" \/><\/p>\n<h3 style=\"background-color:transparent\">2.2\u00a0\u7ed3\u5408\u53cd\u5411\u4ee3\u7406\u5b9e\u73b0tomcat\u90e8\u7f72<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"565\" src=\"2025-08-13j04d0f40bjg.png\" width=\"933\" \/><\/h3>\n<li>\n<p>\u6d4f\u89c8\u5668\u91cc\u770b\u5230\u7684\u201c\u7f51\u9875\u5e94\u7528\u201d\u2248 Nginx &#043; Tomcat \u8fd9\u5bf9\u9ec4\u91d1\u642d\u6863\u5728\u5e72\u6d3b&#xff0c;\u800c Nginx \u8d1f\u8d23\u53cd\u5411\u4ee3\u7406 \/ \u8d1f\u8f7d\u5747\u8861&#xff0c;Tomcat \u8d1f\u8d23\u8dd1 Java \u4ee3\u7801\u3002<br \/>\n\u4e3a\u4e86\u4e0d\u4e22\u767b\u5f55\u6001&#xff0c;\u8fd8\u8981\u89e3\u51b3 Session \u4e00\u81f4\u6027 \u95ee\u9898\u3002<\/p>\n<\/li>\n<hr \/>\n<li>\n<p>\u4ec0\u4e48\u662f\u201c\u53cd\u5411\u4ee3\u7406\u201d&#xff1f;<\/p>\n<\/li>\n<hr \/>\n<ul>\n<li>\n<p>\u6b63\u53cd\u5411\u533a\u522b\u4e00\u53e5\u8bdd&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6b63\u5411\u4ee3\u7406&#xff1a;\u5e2e \u5ba2\u6237\u7aef \u53bb\u8bbf\u95ee\u5916\u7f51&#xff08;\u7ffb\u5899&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u53cd\u5411\u4ee3\u7406&#xff1a;\u5e2e \u670d\u52a1\u7aef \u63a5\u6536\u5916\u7f51\u8bf7\u6c42&#xff08;\u7edf\u4e00\u5165\u53e3&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4e3a\u4ec0\u4e48\u8981\u53cd\u5411\u4ee3\u7406 Tomcat&#xff1f;<\/p>\n<li>\n<p>\u7aef\u53e3\u7edf\u4e00&#xff1a;\u6d4f\u89c8\u5668\u53ea\u8ba4 80\/443&#xff0c;Tomcat \u9ed8\u8ba4 8080\u3002<\/p>\n<\/li>\n<li>\n<p>\u52a8\u9759\u5206\u79bb&#xff1a;Nginx \u5904\u7406\u9759\u6001\u6587\u4ef6&#xff08;css\/js\/png&#xff09;\u901f\u5ea6\u662f Tomcat \u7684 10 \u500d\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b89\u5168&#xff1a;Tomcat \u4e0d\u518d\u76f4\u63a5\u66b4\u9732&#xff0c;\u53ef\u653e\u5728\u5185\u7f51\u3002<\/p>\n<\/li>\n<\/li>\n<li>\n<p>\u6307\u4ee4\u62c6\u89e3<\/p>\n<p>nginx<\/p>\n<p>\u590d\u5236<\/p>\n<p>location ~ \\\\.jsp$ {<br \/>\n    proxy_pass http:\/\/172.25.254.10:8080;   # \u628a\u8bf7\u6c42\u539f\u5c01\u4e0d\u52a8\u8f6c\u7ed9 Tomcat<br \/>\n    proxy_set_header Host $host;            # \u4fdd\u7559\u6d4f\u89c8\u5668\u91cc\u7684\u57df\u540d&#xff0c;\u5426\u5219 Tomcat \u91cd\u5b9a\u5411\u4f1a\u51fa\u9519<br \/>\n}<\/p>\n<p>\u6d4f\u89c8\u5668\u53d1\u7684\u662f Host: lee.timinglee.org&#xff0c;Tomcat \u4e5f\u6536\u5230\u540c\u6837\u7684 Host&#xff0c;\u5c31\u4e0d\u4f1a\u8df3\u9519\u5730\u5740\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<li>\n<p>\u4e3a\u4ec0\u4e48\u8981\u201c\u8d1f\u8f7d\u5747\u8861\u201d&#xff1f;<\/p>\n<\/li>\n<hr \/>\n<ul>\n<li>\n<p>\u5355\u53f0 Tomcat \u7684\u5e76\u53d1\u74f6\u9888&#xff1a;<br \/>\n\u7eaf Java \u4e1a\u52a1&#xff0c;QPS \u5927\u7ea6\u51e0\u767e~\u4e00\u4e24\u5343\u3002\u7528\u6237\u91cf\u4e00\u4e0a\u6765\u5c31\u5361\u6b7b\u3002<\/p>\n<\/li>\n<li>\n<p>\u601d\u8def&#xff1a;\u628a\u540c\u6837\u7684\u5e94\u7528\u590d\u5236\u5230\u591a\u53f0\u673a\u5668&#xff0c;\u628a\u538b\u529b \u5206\u644a&#xff0c;\u672f\u8bed\u53eb Load Balance\u3002<\/p>\n<\/li>\n<li>\n<p>Nginx \u7684 3 \u79cd\u5e38\u7528\u8c03\u5ea6\u7b97\u6cd5<\/p>\n<li>\n<p>\u8f6e\u8be2&#xff08;\u9ed8\u8ba4&#xff09;\u2014\u2014\u6bcf\u4eba\u4e00\u6b21&#xff0c;\u6700\u516c\u5e73\u3002<\/p>\n<\/li>\n<li>\n<p>ip_hash \u2014\u2014\u540c\u4e00 IP \u56fa\u5b9a\u5230\u4e00\u53f0&#xff0c;\u89e3\u51b3 \u4f1a\u8bdd\u4fdd\u6301&#xff08;\u540e\u9762\u7ec6\u8bf4\u5751&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>hash $cookie_JSESSIONID \u2014\u2014\u6309 SessionID \u9009\u673a\u5668&#xff0c;\u6bd4 ip_hash \u66f4\u7cbe\u51c6\u3002<\/p>\n<\/li>\n<\/li>\n<\/ul>\n<hr \/>\n<li>\n<p>HTTP \u7684\u65e0\u72b6\u6001 &amp; Session \u673a\u5236<\/p>\n<\/li>\n<hr \/>\n<ul>\n<li>\n<p>\u65e0\u72b6\u6001&#xff1a;HTTP \u534f\u8bae\u672c\u8eab\u4e0d\u5e26\u201c\u8bb0\u5fc6\u201d\u3002<br \/>\n\u7b2c\u4e00\u6b21\u8bf7\u6c42\u767b\u5f55\u6210\u529f&#xff0c;\u7b2c\u4e8c\u6b21\u5237\u65b0\u9875\u9762&#xff0c;Tomcat \u538b\u6839\u4e0d\u77e5\u9053\u4f60\u662f\u521a\u624d\u90a3\u4e2a\u4eba\u3002<\/p>\n<\/li>\n<li>\n<p>\u89e3\u51b3\u601d\u8def&#xff1a;<\/p>\n<li>\n<p>\u670d\u52a1\u5668\u7ed9\u6d4f\u89c8\u5668\u53d1\u4e00\u5f20\u201c\u8eab\u4efd\u8bc1\u201d\u2014\u2014 SessionID&#xff08;\u968f\u673a\u5b57\u7b26\u4e32&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u6d4f\u89c8\u5668\u4ee5\u540e\u6bcf\u6b21\u8bf7\u6c42\u90fd\u5728 Cookie \u91cc\u5e26\u4e0a JSESSIONID&#061;xxx\u3002<\/p>\n<\/li>\n<li>\n<p>Tomcat \u6536\u5230\u540e&#xff0c;\u4ece\u81ea\u5df1 \u5185\u5b58 \u91cc\u627e\u5bf9\u5e94\u7684 SessionMap&#xff0c;\u53d6\u51fa\u7528\u6237\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/li>\n<li>\n<p>\u751f\u547d\u5468\u671f<\/p>\n<ul>\n<li>\n<p>\u9ed8\u8ba4 30 min \u6ca1\u4ea4\u4e92\u5c31\u5931\u6548&#xff08;web.xml \u53ef\u8c03&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5173\u95ed\u6d4f\u89c8\u5668 Cookie \u6d88\u5931&#xff0c;\u518d\u5f00\u5c31\u91cd\u65b0\u9886\u8eab\u4efd\u8bc1\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<li>\n<p>\u8d1f\u8f7d\u5747\u8861\u540e\u51fa\u73b0\u7684\u65b0\u95ee\u9898&#xff1a;Session \u4e22\u5931<\/p>\n<\/li>\n<hr \/>\n<p>\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6d4f\u89c8\u5668\u7b2c\u4e00\u6b21\u8bf7\u6c42\u88ab\u5206\u5230 Tomcat-A&#xff0c;SessionID&#061;1001 \u5b58\u5728 A \u7684\u5185\u5b58\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u88ab\u5206\u5230 Tomcat-B&#xff0c;B \u5185\u5b58\u91cc\u6ca1 1001 \u2192 \u5f3a\u5236\u8df3\u56de\u767b\u5f55\u9875\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u5c31\u662f\u201c\u627e\u4e0d\u5230 SessionID\u201d\u7684\u6839\u672c\u539f\u56e0&#xff1a;HTTP \u65e0\u72b6\u6001 &#043; \u591a\u53f0\u673a\u5668\u5185\u5b58\u4e0d\u5171\u4eab\u3002<\/p>\n<hr \/>\n<li>\n<p>\u4e09\u79cd Session \u4e00\u81f4\u6027\u65b9\u6848\u5bf9\u6bd4<\/p>\n<\/li>\n<hr \/>\n<p>\u8868\u683c<\/p>\n<p>\u590d\u5236<\/p>\n<table>\n<tr>\u65b9\u6848\u539f\u7406\u4f18\u70b9\u7f3a\u70b9\u9002\u7528<\/tr>\n<tbody>\n<tr>\n<td>1. ip_hash<\/td>\n<td>Nginx \u6309\u5ba2\u6237\u7aef IP \u56fa\u5b9a\u5230\u540c\u4e00\u53f0\u673a\u5668<\/td>\n<td>\u96f6\u6539\u52a8<\/td>\n<td>NAT \u573a\u666f\u4e0b\u4e25\u91cd\u503e\u659c&#xff1b;\u5355\u70b9\u6545\u969c\u9700\u91cd\u65b0\u767b\u5f55<\/td>\n<td>\u5185\u90e8\u540e\u53f0\u3001\u7528\u6237\u91cf\u5c0f<\/td>\n<\/tr>\n<tr>\n<td>2. Tomcat Cluster<\/td>\n<td>\u591a\u53f0 Tomcat \u7ec4\u64ad\u540c\u6b65 Session<\/td>\n<td>\u5b98\u65b9\u539f\u751f<\/td>\n<td>\u7ec4\u64ad\u53d7\u7f51\u7edc\u9650\u5236&#xff1b;\u540c\u6b65\u98ce\u66b4<\/td>\n<td>\u5c0f\u89c4\u6a21\u5185\u7f51<\/td>\n<\/tr>\n<tr>\n<td>3. MSM&#043;Memcached<\/td>\n<td>Session \u5e8f\u5217\u5316\u540e\u5b58 Memcached&#xff0c;\u591a\u53f0 Tomcat \u5171\u4eab<\/td>\n<td>\u65e0\u72b6\u6001\u3001\u9ad8\u53ef\u7528\u3001\u6269\u5c55\u597d<\/td>\n<td>\u9700\u989d\u5916\u90e8\u7f72 Memcached&#xff1b;\u9996\u6b21\u914d\u7f6e\u7a0d\u590d\u6742<\/td>\n<td>\u751f\u4ea7\u6700\u5f3a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<li>\n<p>MSM&#043;Memcached \u5de5\u4f5c\u6d41\u7a0b&#xff08;\u56fe&#043;\u6587\u5b57&#xff09;<\/p>\n<\/li>\n<hr \/>\n<p>\u590d\u5236<\/p>\n<p>\u6d4f\u89c8\u5668<br \/>\n   \u2502<br \/>\n   \u2502 1. \u767b\u5f55\u8bf7\u6c42 \u2192 Nginx \u2192 Tomcat-A<br \/>\n   \u2502                     \u2502<br \/>\n   \u2502                     \u2514\u2500 2. \u521b\u5efa SessionID&#061;1001<br \/>\n   \u2502                          \u540c\u65f6 3. \u5e8f\u5217\u5316 Session \u5230 Memcached<br \/>\n   \u2502<br \/>\n   \u2502 4. \u7b2c\u4e8c\u6b21\u8bf7\u6c42 \u2192 Nginx \u2192 Tomcat-B<br \/>\n   \u2502                     \u2502<br \/>\n   \u2502                     \u2514\u2500 5. Tomcat-B \u53d1\u73b0 Cookie:JSESSIONID&#061;1001<br \/>\n                          6. \u53bb Memcached \u53d6 Session \u2192 \u7ee7\u7eed\u4e1a\u52a1<\/p>\n<ul>\n<li>\n<p>\u5982\u679c Tomcat-A \u6302\u4e86&#xff0c;Tomcat-B\/C\/D \u4efb\u4f55\u4e00\u53f0\u90fd\u80fd\u4ece Memcached \u62ff\u5230\u540c\u4e00\u4efd Session&#xff0c;\u7528\u6237\u65e0\u611f\u77e5\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<li>\n<p>\u914d\u7f6e\u5c0f\u7ed3&#xff08;\u56de\u987e&#xff09;<\/p>\n<\/li>\n<hr \/>\n<li>\n<p>\u53cd\u5411\u4ee3\u7406&#xff08;\u5355\u673a&#xff09;<\/p>\n<p>nginx<\/p>\n<p>\u590d\u5236<\/p>\n<p>location ~ \\\\.jsp$ {<br \/>\n    proxy_pass http:\/\/172.25.254.10:8080;<br \/>\n    proxy_set_header Host $host;<br \/>\n}\n<\/li>\n<li>\n<p>\u8d1f\u8f7d\u5747\u8861&#xff08;\u591a\u673a&#xff09;<\/p>\n<p>nginx<\/p>\n<p>\u590d\u5236<\/p>\n<p>upstream tomcat {<br \/>\n    hash $cookie_JSESSIONID;      # \u4f1a\u8bdd\u4fdd\u6301\u6700\u7a33<br \/>\n    server 172.25.254.10:8080;<br \/>\n    server 172.25.254.20:8080;<br \/>\n}\n<\/li>\n<li>\n<p>MSM \u5171\u4eab Session<\/p>\n<ul>\n<li>\n<p>\u628a\u76f8\u5173 jar \u6254\u8fdb $CATALINA_HOME\/lib<\/p>\n<\/li>\n<li>\n<p>context.xml \u6307\u5b9a Memcached \u8282\u70b9<\/p>\n<\/li>\n<li>\n<p>\u91cd\u542f Tomcat \u5373\u53ef\u751f\u6548\u5355\u673a<\/p>\n<\/li>\n<li>\n<p>\u73b0\u5728\u9700\u8981\u4e00\u4e2a\u6d4b\u8bd5\u9875\u9762<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"2025-08-13yin1szl2tor.png\" width=\"212\" \/><\/p>\n<p>\u6d4b\u8bd5\u9875\u9762\u4e0d\u80fd\u76f4\u63a5\u5728root\u91cc\u8981\u653e\u5230\u9ed8\u8ba4\u53d1\u5e03\u76ee\u5f55\u91cc<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"83\" src=\"2025-08-13qeh5fzgj2vb.png\" width=\"953\" \/><\/p>\n<p>\u76f4\u63a5\u4e0b\u8f7dnginx<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"558\" src=\"2025-08-13pmectuo4jwl.png\" width=\"1204\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"223\" src=\"2025-08-13pitdigujv52.png\" width=\"945\" \/><\/p>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u5199\u4e0b\u5b50\u914d\u7f6e\u547d\u4ee4 include\u00a0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"118\" src=\"2025-08-13ifgmxrhliya.png\" width=\"632\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"86\" src=\"2025-08-13xjtvzi2ervg.png\" width=\"1018\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"108\" src=\"2025-08-13qkcph5ad03q.png\" width=\"549\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"223\" src=\"2025-08-13jwnulnbsdih.png\" width=\"839\" \/><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<p>\u9519\u8bef\u60c5\u51b5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"47\" src=\"2025-08-13f0j2pntd251.png\" width=\"310\" \/><\/p>\n<p>\u8bbf\u95ee\u8d85\u65f6<\/p>\n<p>\u76f4\u63a5\u8bbf\u95ee\u6ca1\u95ee\u9898<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"186\" src=\"2025-08-13sbuhgwkgicx.png\" width=\"548\" \/><\/p>\n<p>\u57df\u540d\u89e3\u6790\u6709\u8bef&#xff0c;\u4e4b\u524d\u5b9e\u9a8c\u7684\u5f71\u54cd<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"146\" src=\"2025-08-13zrtp33dkxxd.png\" width=\"521\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"89\" src=\"2025-08-13h13mgcqxkzh.png\" width=\"891\" \/><\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"263\" src=\"2025-08-13dne11d5edxh.png\" width=\"644\" \/><\/p>\n<p>\u4e4b\u524d\u7684\u4fe1\u606f\u4e5f\u4f1a\u4fdd\u7559<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"293\" src=\"2025-08-13msyb0kuchwj.png\" width=\"561\" \/><\/p>\n<p>\u8fd9\u4e2a\u4ee3\u7801&#xff0c;nginx\u4e0d\u80fd\u5199&#xff0c;\u662ftomcat\u6765\u5199\u7684<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"201\" src=\"2025-08-131zty4jquybp.png\" width=\"542\" \/><\/p>\n<p>tomcat\u6302\u4e86&#xff0c;\u8fd9\u4e2a\u5b9e\u9a8c\u5c31\u4e0d\u80fd\u7528\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"175\" src=\"2025-08-134wjfizoo3qw.png\" width=\"671\" \/><\/p>\n<hr \/>\n<p>\u5355\u673a\u60c5\u51b5\u4e0b&#xff0c;tomcat\u6302\u4e86&#xff0c;\u5c31\u4e0d\u80fd\u7528\u4e86<\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u7528\u591a\u673a\u6765\u505a<\/p>\n<p style=\"background-color:transparent\">\u591a\u673a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"358\" src=\"2025-08-13qcjyyadgxtq.png\" width=\"1038\" \/><\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"251\" src=\"2025-08-13bdximjksh5y.png\" width=\"598\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"243\" src=\"2025-08-13bnpu2iwxcig.png\" width=\"549\" \/><\/p>\n<p style=\"background-color:transparent\">\u4f1a\u8bdd\u7ed1\u5b9a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"389\" src=\"2025-08-13dqrgz545rzq.png\" width=\"878\" \/><\/p>\n<p>\u7f3a\u70b9&#xff1a;\u5982\u679c\u540c\u4e00\u4e2a\u8def\u7531\u5668\u8fc7\u6765\u7684\u8def\u7531\u90fd\u4f1a\u8dd1\u5411\u4e00\u4e2a\u8def\u7531\u5668\u4e0a\u4e86<\/p>\n<p>cookie\u5ba2\u6237\u7aef\u751f\u6210\u7684\u4f1a\u8bdd\u00a0 \u00a0session\u670d\u52a1\u5668\u751f\u6210\u7684\u4f1a\u8bdd<\/p>\n<p>\u4f1a\u8bdd&#xff1a;\u4ee5\u7528\u6237\u7684\u8eab\u4efd\u4e0e\u670d\u52a1\u5668\u5bf9\u8bdd<\/p>\n<p>\u6b64\u65f6\u7684\u60c5\u51b5\u65f6&#xff0c;\u6765\u4e00\u4e2a\u670d\u52a1\u5668\u5c31\u91cd\u65b0\u5bf9\u8bdd<\/p>\n<p>\u6240\u4ee5\u89e3\u51b3\u529e\u6cd5\u662f\u751f\u6210sessionIP\u8981\u4e0ecookieIP\u4e00\u81f4&#xff0c;cookie\u503c\u53d8\u4e86&#xff0c;\u5c31\u8bbf\u95ee\u4e0d\u540c\u670d\u52a1\u5668<\/p>\n<p>\u5199cookie\u54c8\u5e0c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"60\" src=\"2025-08-13wnksan54hr4.png\" width=\"367\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"383\" src=\"2025-08-13aroqfoscfb2.png\" width=\"923\" \/><\/p>\n<p>\u5bf9\u952e\u503c\u8fdb\u884c\u54c8\u5e0c<\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"249\" src=\"2025-08-13ynrjluwyxhk.png\" width=\"602\" \/><\/p>\n<p>ID\u662f\u4e00\u6837\u7684\u5c31\u4f1a\u8bbf\u95ee\u540c\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a<\/p>\n<p>\u53ea\u6709\u6302\u4e86\u6d4f\u89c8\u5668\u624d\u4f1a\u6539\u53d8&#xff0c;\u6b64\u65f6ID\u4e5f\u53d8\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"130\" src=\"2025-08-131sias2luvxd.png\" width=\"331\" \/><\/p>\n<p>\u524d\u7aef\u8fd8\u5728\u505a\u6570\u636e\u5b58\u50a8&#xff0c;\u4f46\u662f\u540e\u7aef\u7684tomcat\u5374\u6302\u4e86&#xff0c;\u524d\u7aef\u662f\u4e0d\u77e5\u9053\u7684&#xff0c;\u8be5\u600e\u4e48\u529e&#xff1f;<\/p>\n<p>\u65e0\u8bba\u662f10\u8fd8\u662f20&#xff0c;\u4e4b\u524d\u7684\u6570\u636e\u8be5\u600e\u4e48\u4fdd\u5b58&#xff1f;<\/p>\n<h3>\u4e09\u3001Memcached<\/h3>\n<p>Memcached \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<p>Memcached \u501f\u52a9\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684 libevent \u5de5\u5177\u505a\u9ad8\u6548\u7684\u8bfb\u5199\u3002libevent\u662f\u4e2a\u7a0b\u5e8f\u5e93&#xff0c;\u5b83\u5c06Linux\u7684epoll\u3001 BSD\u7c7b\u64cd\u4f5c\u7cfb\u7edf\u7684kqueue\u7b49\u4e8b\u4ef6\u5904\u7406\u529f\u80fd\u5c01\u88c5\u6210\u7edf\u4e00\u7684\u63a5\u53e3\u3002\u5373\u4f7f\u5bf9\u670d\u52a1\u5668\u7684\u8fde\u63a5\u6570\u589e\u52a0&#xff0c;\u4e5f\u80fd\u53d1\u6325\u9ad8 \u6027\u80fd\u3002<\/p>\n<p>memcached\u4f7f\u7528\u8fd9\u4e2alibevent\u5e93&#xff0c;\u56e0\u6b64\u80fd\u5728Linux\u3001BSD\u3001Solaris\u7b49\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u53d1\u6325\u5176\u9ad8\u6027\u80fd Memcached \u652f\u6301\u6700\u5927\u7684\u5185\u5b58\u5b58\u50a8\u5bf9\u8c61\u4e3a1M&#xff0c;\u8d85\u8fc71M\u7684\u6570\u636e\u53ef\u4ee5\u4f7f\u7528\u5ba2\u6237\u7aef\u538b\u7f29\u6216\u62c6\u5206\u62a5\u5305\u653e\u5230\u591a\u4e2a key\u4e2d&#xff0c;\u6bd4\u8f83\u5927\u7684\u6570\u636e\u5728\u8fdb\u884c\u8bfb\u53d6\u7684\u65f6\u5019\u9700\u8981\u6d88\u8017\u7684\u65f6\u95f4\u6bd4\u8f83\u957f&#xff0c;<\/p>\n<p>memcached \u6700\u9002\u5408\u4fdd\u5b58\u7528\u6237\u7684 session\u5b9e\u73b0session\u5171\u4eab Memcached\u5b58\u50a8\u6570\u636e\u65f6, Memcached\u4f1a\u53bb\u7533\u8bf71MB\u7684\u5185\u5b58, \u628a\u8be5\u5757\u5185\u5b58\u79f0\u4e3a\u4e00\u4e2aslab, \u4e5f\u79f0\u4e3a\u4e00\u4e2apage Memcached \u652f\u6301\u591a\u79cd\u5f00\u53d1\u8bed\u8a00&#xff0c;\u5305\u62ec&#xff1a;JAVA,C,Python,PHP,C#,Ruby,Perl\u7b49<\/p>\n<p>Memcached \u5b98\u7f51&#xff1a; http:\/\/memcached.org\/<\/p>\n<p>\u5b83\u672c\u8eab\u4e0d\u652f\u6301\u6301\u4e45\u5316&#xff0c;\u53ea\u652f\u6301\u80fd\u5e8f\u5217\u5316\u7684\u6570\u636e\u7c7b\u578b<\/p>\n<p>\u6ca1\u6709\u5ba2\u6237\u7aef&#xff0c;\u662f\u4e2a\u952e\u503c<\/p>\n<p>[root&#064;tomcat ~]# yum install memcached -y<br \/>\n [root&#064;tomcat ~]# vim \/etc\/sysconfig\/memcached<br \/>\n PORT&#061;&#034;11211&#034;<br \/>\n USER&#061;&#034;memcached&#034;<br \/>\n MAXCONN&#061;&#034;1024&#034;<br \/>\n CACHESIZE&#061;&#034;64&#034;<br \/>\n OPTIONS&#061;&#034;-l 0.0.0.0,::1&#034;<br \/>\n 0<br \/>\n980<br \/>\n[root&#064;tomcat ~]# systemctl enable &#8211;now memcached<br \/>\n [root&#064;tomcat ~]# netstat -antlupe | grep memcache<br \/>\n tcp<br \/>\n0 0.0.0.0:11211<br \/>\n97815<br \/>\n34711\/memcached<\/p>\n<p>[root&#064;tomcat ~]# telnet localhost 11211<br \/>\n Trying ::1&#8230;<br \/>\n Connected to localhost.<br \/>\n Escape character is &#039;^]&#039;.<br \/>\n #\u589e\u52a0<br \/>\nadd leekey  0 60 4<br \/>\n#0 \u662f\u5426\u538b\u7f29  60 \u8fc7\u671f\u65f6\u95f4  4 \u5b57\u957f<br \/>\ntest<br \/>\n STORED<br \/>\n add leekey1 0 60 3<br \/>\n lee<br \/>\n STORED<br \/>\n #\u67e5\u770b<br \/>\nget  leekey<br \/>\n VALUE leekey 0 4<br \/>\n test<br \/>\n get leekey1<br \/>\n VALUE leekey1 0 3<br \/>\n lee<br \/>\n #\u6539<br \/>\nset leekey 0 60 5<br \/>\n test1<br \/>\n STORED<br \/>\n get leekey<br \/>\n VALUE leekey 0 5<br \/>\n test1<br \/>\n END<br \/>\n add leekey1 0 60 4<br \/>\n test<br \/>\n #\u5220\u9664<br \/>\ndelete leekey<br \/>\n DELETED<br \/>\n get leekey<br \/>\n END<br \/>\nget leekey1<br \/>\n VALUE leekey1 0 3<br \/>\n lee<br \/>\n #\u6e05\u7a7a<br \/>\nflush_all<br \/>\n OK<br \/>\n get leekey1<br \/>\n END<\/p>\n<p>\u5b9e\u9a8c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"732\" src=\"2025-08-13tglsl55yl0s.png\" width=\"1186\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"195\" src=\"2025-08-13dcz35paax55.png\" width=\"1191\" \/><\/p>\n<p>\u4fee\u6539\u63a5\u53e3&#xff0c;\u6253\u5f00\u5168\u90e8\u00a0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"39\" src=\"2025-08-13qvqvza2f5hd.png\" width=\"602\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"170\" src=\"2025-08-13zgkdxvbk1qs.png\" width=\"462\" \/><\/p>\n<p>\u518d\u6b21\u67e5\u770b\u7aef\u53e3\u4fe1\u606f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"188\" src=\"2025-08-13yh1fwtg5cpc.png\" width=\"1192\" \/><\/p>\n<p>\u8981\u628a\u63a5\u53e3\u90fd\u6253\u5f00<\/p>\n<p>\u6d4b\u8bd5&#xff08;\u957f\u8fde\u63a5\u5b9e\u9a8c\u4e5f\u7528\u8fc7&#xff09;&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"361\" src=\"2025-08-13oi1agvxhmvp.png\" width=\"1181\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"152\" src=\"2025-08-13xecnx1mdul5.png\" width=\"714\" \/><\/p>\n<p>\u8fd9\u91cc\u76842\u662f\u5b57\u957f\u00a0&#xff1a;\u89c4\u5b9a\u540e\u9762\u8f93\u5165\u7684\u5b57\u6570\u53ea\u80fd\u662f\u4e24\u4e2a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"320\" src=\"2025-08-13eri5tpdy3jq.png\" width=\"755\" \/><\/p>\n<p>\u67e5\u770b\u521a\u521a\u50a8\u5b58\u7684\u5185\u5bb9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"107\" src=\"2025-08-13tc0gae5bmy0.png\" width=\"305\" \/><\/p>\n<p>\u4fee\u6539\u50a8\u5b58\u7684\u5185\u5bb9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"218\" src=\"2025-08-1304y3aptqtxq.png\" width=\"343\" \/><\/p>\n<p>\u5220\u9664\u5e76\u9000\u51fa<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"193\" src=\"2025-08-13doqdfafsbkt.png\" width=\"609\" \/><\/p>\n<p>\u4f01\u4e1a\u4e00\u822c\u4e0d\u7528<\/p>\n<hr \/>\n<p>\u4f7f\u7528\u63d2\u4ef6&#xff0c;\u8ba9tomcat\u5f80memcached\u91cc\u5b58\u50a8&#xff0c;\u5b9e\u9645\u4e0a&#xff0c;\u4e24\u8005\u662f\u6ca1\u6709\u5173\u7cfb\u7684\u3002<\/p>\n<h3>\u56db\u3001msm<\/h3>\n<p>[root&#064;tomcat-1 ~]# vim \/usr\/local\/tomcat\/conf\/context.xml<br \/>\n &#064;&#064;&#064;&#064;\u5185\u5bb9\u7701\u7565&#064;&#064;&#064;&#064;<br \/>\n &lt;Manager className&#061;&#034;de.javakaffee.web.msm.MemcachedBackupSessionManager&#034;<br \/>\n memcachedNodes&#061;&#034;n1:172.25.254.10:11211,n2:172.25.254.20:11211&#034;<br \/>\n failoverNodes&#061;&#034;n1&#034;<br \/>\n requestUriIgnorePattern&#061;&#034;.*\\\\.(ico|png|gif|jpg|css|js)$&#034;<br \/>\n transcoderFactoryClass&#061;&#034;de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFacto<br \/>\n ry&#034;<br \/>\n \/&gt;<br \/>\n [root&#064;tomcat-2 tomcat]# vim \/usr\/local\/tomcat\/conf\/context.xml<br \/>\n &#064;&#064;&#064;&#064;\u5185\u5bb9\u7701\u7565&#064;&#064;&#064;&#064;<br \/>\n &lt;Manager className&#061;&#034;de.javakaffee.web.msm.MemcachedBackupSessionManager&#034;<br \/>\n memcachedNodes&#061;&#034;n1:172.25.254.10:11211,n2:172.25.254.20:11211&#034;<br \/>\n failoverNodes&#061;&#034;n2&#034;<br \/>\n requestUriIgnorePattern&#061;&#034;.*\\\\.(ico|png|gif|jpg|css|js)$&#034;<br \/>\n transcoderFactoryClass&#061;&#034;de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFacto<br \/>\n ry&#034;<br \/>\n \/&gt;<\/p>\n<p>\u4fee\u6539nginx\u914d\u7f6e<\/p>\n<p>[root&#064;Nginx ~]# vim \/usr\/local\/nginx\/conf.d\/vhosts.conf<br \/>\n upstream tomcat {<br \/>\n hash $cookie_JSESSIONID;<br \/>\n server 172.25.254.10:8080;<br \/>\n server 172.25.254.20:8080;<br \/>\n }<br \/>\n server {<br \/>\n listen 80;<br \/>\n server_name lee.timinglee.org;<br \/>\n root \/webdataw\/nginx\/timinglee.org\/lee;<br \/>\n access_log \/var\/log\/nginx\/access.log;<br \/>\n error_log  \/var\/log\/nginx\/error.log;<br \/>\n try_files $uri $uri.html $uri\/index.html \/error\/default.html;<br \/>\n }<br \/>\n location ~ \\\\.jsp$ {<br \/>\n proxy_pass http:\/\/tomcat;<br \/>\n }<\/p>\n<p>\u67e5\u770bmemcached\u7684\u7248\u672c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-133zncsbc13pf.png\" width=\"590\" \/><\/p>\n<p>\u8981\u53bb\u627e\u5408\u9002\u7248\u672c\u7684\u63d2\u4ef6<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"587\" src=\"2025-08-13vgcyhdwr42p.png\" width=\"878\" \/><\/p>\n<p style=\"background-color:transparent\">\u5b89\u88c5<\/p>\n<p>\u8981\u628a\u63d2\u4ef6\u653e\u8fdbtomcat\u5e93\u91cc<\/p>\n<p>\u67e5\u770btomcat\u7684\u63d2\u4ef6\u5b58\u50a8\u4f4d\u7f6e<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"395\" src=\"2025-08-13n0vxr5gkds2.png\" width=\"793\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"343\" src=\"2025-08-13p4gzsye0ptz.png\" width=\"876\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"345\" src=\"2025-08-13tprbae1wxtm.png\" width=\"907\" \/><\/p>\n<p>\u670d\u52a1\u91cd\u542f\u6210\u529f\u540eIP\u4f1a\u53d1\u751f\u53d8\u5316<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"187\" src=\"2025-08-13re0gboqhnrb.png\" width=\"924\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"550\" src=\"2025-08-134zevhckghua.png\" width=\"1245\" \/><\/p>\n<p>failoverNodes&#xff1a;\u5f53\u4e00\u4e2a\u670d\u52a1\u5668\u7684tomcat\u51fa\u6545\u969c\u65f6&#xff0c;\u53e6\u4e00\u53f0\u4f1a\u8981\u627e\u81ea\u5df1\u7684memcached\u7684&#xff0c;\u56e0\u4e3a\u81ea\u5df1\u7684\u91cc\u9762\u4e5f\u662f\u6709\u5bf9\u7aef\u7684\u6570\u636e\u7684<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"546\" src=\"2025-08-13l2r3mxhyz1t.png\" width=\"1277\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"37\" src=\"2025-08-13d2xrorhgsaz.png\" width=\"608\" \/><\/p>\n<p>\u91cd\u542f\u670d\u52a1<\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"288\" src=\"2025-08-13g4drfd0zyx4.png\" width=\"620\" \/><\/p>\n<p>20tomcat\u6302\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"47\" src=\"2025-08-13t3ht35nq2ir.png\" width=\"742\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"176\" src=\"2025-08-13bgiabicpmed.png\" width=\"384\" \/><\/p>\n<p>\u8fd9\u91cc\u4f1a\u6709\u4e4b\u524d\u6570\u636e\u7684\u539f\u56e0\u662f&#xff0c;20\u5f8010\u7684memcached\u91cc\u5b58\u7684\u6570\u636e&#xff0c;20\u6302\u4e86&#xff0c;10\u4f1a\u5728memcached\u91cc\u8bfb\u53d6\u6570\u636e<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"335\" src=\"2025-08-13zxdv1zhs4na.png\" width=\"692\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb989\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u6d4f\u89c8\u5668\u53ea\u8ba4\u8bc6 HTTP\u3002\u4f60\u5728\u5730\u5740\u680f\u6572\uff0c\u6d4f\u89c8\u5668\u53d1\u51fa\u53bb\u7684\u5c31\u662f\u4e00\u6bb5\u7eaf\u6587\u672c HTTP \u62a5\u6587\u3002Tomcat \u5929\u751f\u5403 HTTP\u3002\u5b83\u5b9e\u73b0\u4e86 JavaEE \u91cc\u7684 Servlet \u89c4\u8303\uff1a\u628a HTTP \u8bf7\u6c42\u5c01\u88c5\u6210\u2192 \u4ea4\u7ed9\u7a0b\u5e8f\u5458\u5199\u7684\u2192 \u751f\u6210 HTML \u2192 \u518d\u6309 HTTP \u683c\u5f0f\u8fd4\u56de\u3002\u4e8e\u662f\u201c\u6d4f\u89c8\u5668 \u2194 HTTP \u2194 Tomcat \u2194 \u4f60\u7684\u4e1a\u52a1\u4ee3\u7801\u201d\u8fd9\u4e00\u6761\u8def\u5c31\u6253\u901a\u4e86\u3002\u56e0\u6b64\uff0c\u53ea\u8981\u6700\u7ec8\u662f\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7684\uff0c\u51e0\u4e4e\u90fd\u53ef\u4ee5\u8bf4\u201c\u7531 Tomcat\uff08\u6216\u540c\u7c7b Web \u670d\u52a1\u5668\uff09\u5b9e\u73b0\u201d\u3002<\/p>\n","protected":false},"author":2,"featured_media":54241,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,223,87],"topic":[],"class_list":["post-54261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-tomcat","tag-87"],"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\u5165\u95e8\u8be6\u89e3 - \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\/54261.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\u5165\u95e8\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb989\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u6d4f\u89c8\u5668\u53ea\u8ba4\u8bc6 HTTP\u3002\u4f60\u5728\u5730\u5740\u680f\u6572\uff0c\u6d4f\u89c8\u5668\u53d1\u51fa\u53bb\u7684\u5c31\u662f\u4e00\u6bb5\u7eaf\u6587\u672c HTTP \u62a5\u6587\u3002Tomcat \u5929\u751f\u5403 HTTP\u3002\u5b83\u5b9e\u73b0\u4e86 JavaEE \u91cc\u7684 Servlet \u89c4\u8303\uff1a\u628a HTTP \u8bf7\u6c42\u5c01\u88c5\u6210\u2192 \u4ea4\u7ed9\u7a0b\u5e8f\u5458\u5199\u7684\u2192 \u751f\u6210 HTML \u2192 \u518d\u6309 HTTP \u683c\u5f0f\u8fd4\u56de\u3002\u4e8e\u662f\u201c\u6d4f\u89c8\u5668 \u2194 HTTP \u2194 Tomcat \u2194 \u4f60\u7684\u4e1a\u52a1\u4ee3\u7801\u201d\u8fd9\u4e00\u6761\u8def\u5c31\u6253\u901a\u4e86\u3002\u56e0\u6b64\uff0c\u53ea\u8981\u6700\u7ec8\u662f\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7684\uff0c\u51e0\u4e4e\u90fd\u53ef\u4ee5\u8bf4\u201c\u7531 Tomcat\uff08\u6216\u540c\u7c7b Web \u670d\u52a1\u5668\uff09\u5b9e\u73b0\u201d\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54261.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-12T16:20:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162030-689b69ce2da24.png\" \/>\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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54261.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54261.html\",\"name\":\"\u4f01\u4e1a\u7ea7web\u5e94\u7528\u670d\u52a1\u5668TOMCAT\u5165\u95e8\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T16:20:34+00:00\",\"dateModified\":\"2025-08-12T16:20:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54261.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54261.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54261.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\u5165\u95e8\u8be6\u89e3\"}]},{\"@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\u5165\u95e8\u8be6\u89e3 - \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\/54261.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f01\u4e1a\u7ea7web\u5e94\u7528\u670d\u52a1\u5668TOMCAT\u5165\u95e8\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb989\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u6d4f\u89c8\u5668\u53ea\u8ba4\u8bc6 HTTP\u3002\u4f60\u5728\u5730\u5740\u680f\u6572\uff0c\u6d4f\u89c8\u5668\u53d1\u51fa\u53bb\u7684\u5c31\u662f\u4e00\u6bb5\u7eaf\u6587\u672c HTTP \u62a5\u6587\u3002Tomcat \u5929\u751f\u5403 HTTP\u3002\u5b83\u5b9e\u73b0\u4e86 JavaEE \u91cc\u7684 Servlet \u89c4\u8303\uff1a\u628a HTTP \u8bf7\u6c42\u5c01\u88c5\u6210\u2192 \u4ea4\u7ed9\u7a0b\u5e8f\u5458\u5199\u7684\u2192 \u751f\u6210 HTML \u2192 \u518d\u6309 HTTP \u683c\u5f0f\u8fd4\u56de\u3002\u4e8e\u662f\u201c\u6d4f\u89c8\u5668 \u2194 HTTP \u2194 Tomcat \u2194 \u4f60\u7684\u4e1a\u52a1\u4ee3\u7801\u201d\u8fd9\u4e00\u6761\u8def\u5c31\u6253\u901a\u4e86\u3002\u56e0\u6b64\uff0c\u53ea\u8981\u6700\u7ec8\u662f\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7684\uff0c\u51e0\u4e4e\u90fd\u53ef\u4ee5\u8bf4\u201c\u7531 Tomcat\uff08\u6216\u540c\u7c7b Web \u670d\u52a1\u5668\uff09\u5b9e\u73b0\u201d\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54261.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T16:20:34+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812162030-689b69ce2da24.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54261.html","url":"https:\/\/www.wsisp.com\/helps\/54261.html","name":"\u4f01\u4e1a\u7ea7web\u5e94\u7528\u670d\u52a1\u5668TOMCAT\u5165\u95e8\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T16:20:34+00:00","dateModified":"2025-08-12T16:20:34+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54261.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54261.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54261.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\u5165\u95e8\u8be6\u89e3"}]},{"@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\/54261","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=54261"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54261\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/54241"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54261"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}