{"id":39627,"date":"2025-05-24T15:56:40","date_gmt":"2025-05-24T07:56:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/39627.html"},"modified":"2025-05-24T15:56:40","modified_gmt":"2025-05-24T07:56:40","slug":"%e5%88%86%e5%b8%83%e5%bc%8f%e5%be%ae%e6%9c%8d%e5%8a%a1%e7%b3%bb%e7%bb%9f%e6%9e%b6%e6%9e%84%e7%ac%ac133%e9%9b%86%ef%bc%9a%e8%bf%90%e7%bb%b4%e6%9c%8d%e5%8a%a1%e5%99%a86%e5%b9%b4%e7%bb%8f%e9%aa%8c","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/39627.html","title":{"rendered":"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf"},"content":{"rendered":"<p style=\"text-align: left\">\u52a0\u7fa4\u8054\u7cfb\u4f5c\u8005vx&#xff1a;xiaoda0423<\/p>\n<p style=\"text-align: left\">\u4ed3\u5e93\u5730\u5740&#xff1a;https:\/\/webvueblog.github.io\/JavaPlusDoc\/<\/p>\n<p style=\"text-align: left\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"leBo0AMrfZ\"><p><a href=\"https:\/\/1024bat.cn\/\">Home<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"\u300a Home \u300b\u2014Jeskson\" src=\"https:\/\/1024bat.cn\/embed\/#?secret=ZTqQSM7yWh#?secret=leBo0AMrfZ\" data-secret=\"leBo0AMrfZ\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p style=\"text-align: left\">https:\/\/github.com\/webVueBlog\/fastapi_plus<\/p>\n<p style=\"text-align: left\">2025-05-24agpqbdgn3kl.png <\/p>\n<h3>\u2705 \u4e00\u3001\u5e38\u7528 Linux \u547d\u4ee4\u5206\u7c7b&#xff08;\u91cd\u70b9\u5e38\u89c1&#xff09;&#xff1a;<\/h3>\n<h4>&#x1f539; \u7cfb\u7edf\u8d44\u6e90\u76d1\u63a7<\/h4>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u4f5c\u7528<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>top<\/td>\n<td>\n<p>\u5b9e\u65f6\u67e5\u770b CPU\u3001\u5185\u5b58\u3001\u8fdb\u7a0b\u5360\u7528\u7b49<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>htop<\/td>\n<td>top<\/p>\n<p>\u00a0\u7684\u589e\u5f3a\u7248&#xff0c;\u56fe\u5f62\u5316\u663e\u793a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ps<\/td>\n<td>\n<p>\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u8fdb\u7a0b\u72b6\u6001<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>uptime<\/td>\n<td>\n<p>\u67e5\u770b\u7cfb\u7edf\u8fd0\u884c\u65f6\u957f\u4e0e\u8d1f\u8f7d\u60c5\u51b5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>vmstat<\/td>\n<td>\n<p>\u67e5\u770b\u5185\u5b58\u3001CPU\u3001IO \u7b49\u7cfb\u7edf\u6027\u80fd<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>iostat<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8 IO \u4f7f\u7528\u7387&#xff08;\u6765\u81ea\u00a0sysstat\u00a0\u5305&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>free<\/td>\n<td>\n<p>\u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>sar<\/td>\n<td>\n<p>\u6536\u96c6\u7cfb\u7edf\u6027\u80fd\u5386\u53f2&#xff08;\u9700\u5b89\u88c5\u00a0sysstat&#xff09;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#x1f539; \u7f51\u7edc\u76f8\u5173<\/h4>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u4f5c\u7528<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>netstat<\/td>\n<td>\n<p>\u67e5\u770b\u7f51\u7edc\u8fde\u63a5\u3001\u7aef\u53e3\u76d1\u542c\u7b49&#xff08;\u5efa\u8bae\u7528\u00a0ss\u00a0\u66ff\u4ee3&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ss<\/td>\n<td>\n<p>\u66f4\u5feb\u66f4\u51c6\u786e\u7684\u66ff\u4ee3\u00a0netstat<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ping<\/td>\n<td>\n<p>\u6d4b\u8bd5\u7f51\u7edc\u8fde\u901a\u6027<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>traceroute<\/td>\n<td>\n<p>\u8def\u7531\u8ffd\u8e2a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>dig\/nslookup<\/td>\n<td>\n<p>\u57df\u540d\u89e3\u6790\u5de5\u5177<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>curl\/wget<\/td>\n<td>\n<p>\u7f51\u7edc\u8bf7\u6c42\u6d4b\u8bd5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>tcpdump<\/td>\n<td>\n<p>\u6293\u5305\u5de5\u5177<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>iftop<\/td>\n<td>\n<p>\u5b9e\u65f6\u7f51\u7edc\u5e26\u5bbd\u76d1\u63a7<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#x1f539; \u78c1\u76d8\u4e0e\u6587\u4ef6\u7cfb\u7edf<\/h4>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u4f5c\u7528<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>df<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8\u6302\u8f7d\u4e0e\u5269\u4f59\u7a7a\u95f4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>du<\/td>\n<td>\n<p>\u67e5\u770b\u76ee\u5f55\/\u6587\u4ef6\u5360\u7528\u5927\u5c0f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>lsblk<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8\u6302\u8f7d\u7ed3\u6784<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>mount\/umount<\/td>\n<td>\n<p>\u6302\u8f7d\/\u5378\u8f7d\u78c1\u76d8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#x1f539; \u6587\u4ef6\u4e0e\u7cfb\u7edf\u64cd\u4f5c<\/h4>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u4f5c\u7528<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>ls<\/p>\n<p>,\u00a0cd,\u00a0cat,\u00a0cp,\u00a0mv,\u00a0rm<\/p>\n<\/td>\n<td>\n<p>\u6587\u4ef6\u64cd\u4f5c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>find<\/p>\n<p>,\u00a0grep,\u00a0awk,\u00a0sed<\/p>\n<\/td>\n<td>\n<p>\u67e5\u627e\u4e0e\u6587\u672c\u5904\u7406<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>chmod<\/p>\n<p>,\u00a0chown<\/p>\n<\/td>\n<td>\n<p>\u4fee\u6539\u6743\u9650\u4e0e\u6240\u6709\u8005<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>tar<\/p>\n<p>,\u00a0zip,\u00a0unzip<\/p>\n<\/td>\n<td>\n<p>\u538b\u7f29\u89e3\u538b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>systemctl<\/p>\n<p>,\u00a0service<\/p>\n<\/td>\n<td>\n<p>\u670d\u52a1\u7ba1\u7406<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>journalctl<\/td>\n<td>\n<p>\u67e5\u770b\u7cfb\u7edf\u65e5\u5fd7<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>crontab<\/td>\n<td>\n<p>\u5b9a\u65f6\u4efb\u52a1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>kill<\/p>\n<p>,\u00a0killall,\u00a0xargs<\/p>\n<\/td>\n<td>\n<p>\u6740\u8fdb\u7a0b<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u2705 \u4e8c\u3001\u4f60\u63d0\u5230\u7684\u547d\u4ee4\u8be6\u89e3<\/h3>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u7528\u9014\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>top<\/td>\n<td>\n<p>\u5b9e\u65f6\u67e5\u770b CPU\u3001\u5185\u5b58\u5360\u7528\u3001\u5404\u8fdb\u7a0b\u8fd0\u884c\u72b6\u6001&#xff0c;\u5e38\u7528\u4e8e\u6392\u67e5\u7cfb\u7edf\u8d1f\u8f7d\u9ad8\u7684\u95ee\u9898<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ps aux<\/td>\n<td>\n<p>\u5feb\u7167\u65b9\u5f0f\u67e5\u770b\u6240\u6709\u8fdb\u7a0b\u72b6\u6001&#xff0c;\u53ef\u7ed3\u5408\u00a0grep\u00a0\u627e\u5173\u952e\u8fdb\u7a0b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>netstat -tulnp<\/td>\n<td>\n<p>\u67e5\u770b\u76d1\u542c\u7aef\u53e3\u4e0e\u7ed1\u5b9a\u670d\u52a1&#xff08;\u88ab\u00a0ss\u00a0\u53d6\u4ee3&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>df -h<\/td>\n<td>\n<p>\u67e5\u770b\u5404\u6302\u8f7d\u5206\u533a\u7684\u5269\u4f59\u7a7a\u95f4\u3001\u4f7f\u7528\u7387&#xff0c;\u5224\u65ad\u78c1\u76d8\u662f\u5426\u6ee1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>du -sh *<\/td>\n<td>\n<p>\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u5404\u5b50\u76ee\u5f55\/\u6587\u4ef6\u5927\u5c0f&#xff0c;\u5b9a\u4f4d\u201c\u8c01\u5360\u6ee1\u4e86\u78c1\u76d8\u201d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>iostat -x 1<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8\u8bfb\u5199\u901f\u7387\u3001IO \u7b49\u5f85\u60c5\u51b5&#xff0c;\u5206\u6790 IO \u74f6\u9888\u95ee\u9898&#xff08;\u9700\u5b89\u88c5\u00a0sysstat&#xff09;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u2705 \u4e00\u3001Linux \u8fd0\u7ef4\u6392\u67e5\u547d\u4ee4\u901f\u67e5\u8868&#xff08;\u5206\u7c7b &#043; \u573a\u666f&#xff09;<\/h3>\n<table>\n<tr>\n<p>\u5206\u7c7b<\/p>\n<p>\u547d\u4ee4\u793a\u4f8b<\/p>\n<p>\u4f7f\u7528\u573a\u666f\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>&#x1f527;\u00a0CPU\/\u5185\u5b58\u6392\u67e5<\/p>\n<\/td>\n<td>top<\/p>\n<p>,\u00a0htop,\u00a0ps aux &#8211;sort&#061;-%cpu<\/p>\n<\/td>\n<td>\n<p>\u67e5\u770b\u9ad8\u8d1f\u8f7d\u8fdb\u7a0b\u3001\u5185\u5b58\u6cc4\u6f0f\u3001\u8fdb\u7a0b\u5f02\u5e38<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f527;\u00a0\u78c1\u76d8\u6392\u67e5<\/p>\n<\/td>\n<td>df -h<\/p>\n<p>,\u00a0du -sh *,\u00a0lsof,\u00a0ncdu<\/p>\n<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8\u662f\u5426\u6ee1\u3001\u54ea\u4e9b\u6587\u4ef6\u5360\u7528\u6700\u5927\u7a7a\u95f4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f527;\u00a0IO \u6392\u67e5<\/p>\n<\/td>\n<td>iostat -x 1<\/p>\n<p>,\u00a0iotop,\u00a0vmstat 1<\/p>\n<\/td>\n<td>\n<p>\u5224\u65ad\u78c1\u76d8 IO \u662f\u5426\u74f6\u9888\u3001IO \u7b49\u5f85\u9ad8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f527;\u00a0\u7f51\u7edc\u6392\u67e5<\/p>\n<\/td>\n<td>netstat -tulnp<\/p>\n<p>,\u00a0ss -lntp,\u00a0lsof -i:\u7aef\u53e3<\/p>\n<\/td>\n<td>\n<p>\u67e5\u770b\u7aef\u53e3\u76d1\u542c\u60c5\u51b5\u3001\u7f51\u7edc\u8fde\u63a5\u72b6\u6001<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f310;\u00a0\u8fde\u901a\u6027\u6d4b\u8bd5<\/p>\n<\/td>\n<td>ping<\/p>\n<p>,\u00a0traceroute,\u00a0curl,\u00a0dig,\u00a0telnet<\/p>\n<\/td>\n<td>\n<p>\u7f51\u7edc\u662f\u5426\u901a&#xff0c;DNS \u89e3\u6790\u662f\u5426\u6b63\u5e38<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f4c2;\u00a0\u6587\u4ef6\u5b9a\u4f4d<\/p>\n<\/td>\n<td>find . -type f -name &#034;*.log&#034;<\/p>\n<p>, &#096;du -ah<\/p>\n<\/td>\n<td>\n<p>sort -rh&#096;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f50d;\u00a0\u65e5\u5fd7\u67e5\u770b<\/p>\n<\/td>\n<td>tail -f \/var\/log\/messages<\/p>\n<p>,\u00a0journalctl -xe<\/p>\n<\/td>\n<td>\n<p>\u5b9e\u65f6\u67e5\u770b\u7cfb\u7edf\/\u670d\u52a1\u65e5\u5fd7&#xff0c;\u67e5\u542f\u52a8\u5931\u8d25<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f510;\u00a0\u6743\u9650\u6392\u67e5<\/p>\n<\/td>\n<td>ls -l<\/p>\n<p>,\u00a0chmod,\u00a0chown<\/p>\n<\/td>\n<td>\n<p>\u6587\u4ef6\/\u76ee\u5f55\u6743\u9650\u9519\u8bef\u5bfc\u81f4\u65e0\u6cd5\u8bbf\u95ee<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u2699\ufe0f\u00a0\u8fdb\u7a0b\u63a7\u5236<\/p>\n<\/td>\n<td>ps<\/p>\n<p>,\u00a0kill,\u00a0killall,\u00a0xargs<\/p>\n<\/td>\n<td>\n<p>\u67e5\u627e\u5e76\u7ec8\u6b62\u5f02\u5e38\u8fdb\u7a0b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f4c6;\u00a0\u5b9a\u65f6\u4efb\u52a1<\/p>\n<\/td>\n<td>crontab -l<\/p>\n<p>,\u00a0systemctl list-timers<\/p>\n<\/td>\n<td>\n<p>\u5b9a\u65f6\u811a\u672c\u672a\u89e6\u53d1\u6216\u914d\u7f6e\u9519\u8bef<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>CPU \u98d9\u9ad8\u6392\u67e5<\/h4>\n<p style=\"text-align: left\">\u6709\u4e00\u6b21\u7ebf\u4e0a\u7cfb\u7edf CPU \u98d9\u5230 100%&#xff0c;\u6211\u4f7f\u7528\u00a0top\u00a0\u67e5\u770b\u662f\u67d0\u4e2a Java \u8fdb\u7a0b\u5360\u6ee1 CPU&#xff0c;\u518d\u7ed3\u5408\u00a0ps -ef\u00a0\u786e\u8ba4 PID&#xff0c;\u4e4b\u540e\u7528\u00a0jstack\u00a0dump \u6808\u5206\u6790\u662f\u67d0\u4e2a\u7ebf\u7a0b\u6b7b\u5faa\u73af\u3002\u4fee\u590d\u540e CPU \u964d\u56de\u6b63\u5e38\u3002<\/p>\n<h4>\u78c1\u76d8\u6253\u6ee1\u5bfc\u81f4\u670d\u52a1\u6302\u6389<\/h4>\n<p style=\"text-align: left\">\u67d0\u6b21\u670d\u52a1\u7a81\u7136\u6302\u6389&#xff0c;df -h\u00a0\u4e00\u770b\u00a0\/var\u00a0\u5206\u533a 100%&#xff0c;du -sh *\u00a0\u9010\u7ea7\u5b9a\u4f4d&#xff0c;\u53d1\u73b0\u662f\u65e5\u5fd7\u6587\u4ef6\u6253\u6ee1\u4e86\u3002\u7528\u00a0logrotate\u00a0\u52a0\u4e86\u538b\u7f29\u4e0e\u6e05\u7406\u7b56\u7565&#xff0c;\u907f\u514d\u518d\u6b21\u53d1\u751f\u3002<\/p>\n<h4>\u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\u6392\u67e5<\/h4>\n<p style=\"text-align: left\">\u5e94\u7528\u8fde\u4e0d\u4e0a MySQL&#xff0c;\u5148\u7528\u00a0ping\u00a0\u786e\u8ba4\u7f51\u7edc\u901a&#xff0c;\u518d\u00a0telnet host 3306\u00a0\u53d1\u73b0\u7aef\u53e3\u4e0d\u901a&#xff0c;\u7528\u00a0ss -lntp\u00a0\u67e5\u670d\u52a1\u672a\u76d1\u542c&#xff0c;\u539f\u6765\u662f\u6570\u636e\u5e93\u672a\u542f\u52a8&#xff0c;systemctl start mysql\u00a0\u540e\u6062\u590d\u6b63\u5e38\u3002<\/p>\n<h4>Redis \u591a\u5b9e\u4f8b\u7aef\u53e3\u51b2\u7a81<\/h4>\n<p style=\"text-align: left\">\u591a Redis \u5b9e\u4f8b\u542f\u52a8\u5931\u8d25&#xff0c;netstat -tulnp\u00a0\u663e\u793a\u7aef\u53e3\u5df2\u88ab\u5360\u7528&#xff0c;ps aux | grep redis\u00a0\u67e5\u51fa\u662f\u8001\u8fdb\u7a0b\u672a\u5173\u95ed&#xff0c;kill\u00a0\u540e\u518d\u91cd\u542f\u6210\u529f\u3002<\/p>\n<h4>\u78c1\u76d8 IO \u6027\u80fd\u74f6\u9888<\/h4>\n<p style=\"text-align: left\">\u67d0\u670d\u52a1\u54cd\u5e94\u6162\u4f46 CPU \u5360\u7528\u4f4e&#xff0c;\u7528\u00a0iostat -x 1\u00a0\u67e5\u770b\u53d1\u73b0\u78c1\u76d8\u00a0util\u00a0\u957f\u65f6\u95f4\u63a5\u8fd1 100%&#xff0c;\u6392\u67e5\u662f\u9891\u7e41\u5199\u5165\u65e5\u5fd7\u5bfc\u81f4 IO \u62e5\u585e&#xff0c;\u4f18\u5316\u540e\u65e5\u5fd7\u6309\u7ea7\u522b\u5199\u5165&#xff0c;\u54cd\u5e94\u6062\u590d\u3002<\/p>\n<table>\n<tr>\n<p>\u547d\u4ee4<\/p>\n<p>\u9762\u8bd5\u4e2d\u7b80\u6d01\u63cf\u8ff0<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>top<\/td>\n<td>\n<p>\u5b9e\u65f6\u76d1\u63a7\u8fdb\u7a0b CPU\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ps aux<\/td>\n<td>\n<p>\u67e5\u770b\u6240\u6709\u8fdb\u7a0b\u7684\u9759\u6001\u5feb\u7167<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>netstat<\/p>\n<p>\/ss<\/p>\n<\/td>\n<td>\n<p>\u67e5\u770b\u7aef\u53e3\u76d1\u542c\u4e0e\u7f51\u7edc\u8fde\u63a5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>df -h<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8\u5206\u533a\u4f7f\u7528\u60c5\u51b5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>du -sh *<\/td>\n<td>\n<p>\u67e5\u770b\u76ee\u5f55\u5927\u5c0f&#xff0c;\u6392\u67e5\u5927\u6587\u4ef6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>iostat<\/td>\n<td>\n<p>\u67e5\u770b\u78c1\u76d8 IO \u4f7f\u7528\u4e0e\u74f6\u9888<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>tail -f<\/td>\n<td>\n<p>\u5b9e\u65f6\u67e5\u770b\u65e5\u5fd7\u8f93\u51fa<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>ping<\/p>\n<p>,\u00a0curl<\/p>\n<\/td>\n<td>\n<p>\u68c0\u67e5\u7f51\u7edc\u8fde\u901a\u6027\u4e0e\u670d\u52a1\u662f\u5426\u5728\u7ebf<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>kill -9<\/td>\n<td>\n<p>\u5f3a\u5236\u7ed3\u675f\u8fdb\u7a0b<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e00\u952e\u5b89\u88c5\u5de5\u5177\u5efa\u8bae&#xff08;\u8fd0\u7ef4\u5fc5\u5907&#xff09;<\/h3>\n<p> # IO \u548c\u7f51\u7edc\u5de5\u5177\u5408\u96c6&#xff08;Debian\/Ubuntu&#xff09;<br \/>\nsudo apt install sysstat iotop iftop net-tools lsof<\/p>\n<p># CentOS\/RHEL<br \/>\nsudo yum install sysstat iotop iftop net-tools lsof <\/p>\n<table>\n<tr>\n<p>\u6392\u67e5\u573a\u666f<\/p>\n<p>\u4f7f\u7528\u547d\u4ee4<\/p>\n<p>\u76ee\u7684<\/p>\n<p>\u5b9e\u9645\u4f5c\u7528 \/ \u7ed3\u679c<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>Java \u8fdb\u7a0b CPU \u98d9\u5347<\/p>\n<\/td>\n<td>topps aux &#8211;sort&#061;-%cpujstack PID<\/td>\n<td>\n<p>\u627e\u51fa\u9ad8 CPU \u5360\u7528\u8fdb\u7a0b&#xff0c;\u5e76\u7528 jstack \u6293\u7ebf\u7a0b\u5806\u6808<\/p>\n<\/td>\n<td>\n<p>\u786e\u8ba4\u662f\u67d0\u7ebf\u7a0b\u6b7b\u5faa\u73af\u5bfc\u81f4 CPU \u5360\u6ee1&#xff0c;\u5206\u6790\u5b9a\u4f4d\u4e1a\u52a1\u903b\u8f91\u95ee\u9898<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u78c1\u76d8\u5199\u5165\u5f02\u5e38<\/p>\n<\/td>\n<td>df -h<\/td>\n<td>\n<p>\u67e5\u770b\u5206\u533a\u662f\u5426\u5df2\u6ee1<\/p>\n<\/td>\n<td>\/var<\/p>\n<p>\u00a0\u5206\u533a 100%&#xff0c;\u670d\u52a1\u65e5\u5fd7\u65e0\u6cd5\u5199\u5165&#xff0c;\u5bfc\u81f4\u63a5\u53e3\u62a5\u9519<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5927\u6587\u4ef6\u5b9a\u4f4d<\/p>\n<\/td>\n<td>du -sh *<\/p>\n<p>\u00a0&#096;du -sh .\/*<\/p>\n<\/td>\n<td>\n<p>sort -rh<\/p>\n<\/td>\n<td>\n<p>head&#096;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u78c1\u76d8 IO \u6027\u80fd\u74f6\u9888<\/p>\n<\/td>\n<td>iostat -x 1<\/td>\n<td>\n<p>\u67e5\u770b IO \u5229\u7528\u7387\u3001\u7b49\u5f85\u65f6\u95f4<\/p>\n<\/td>\n<td>util<\/p>\n<p>\u00a0\u957f\u671f 90%&#043;&#xff0c;await\u00a0\u65f6\u95f4\u9ad8&#xff0c;\u786e\u8ba4\u5199\u5165\u74f6\u9888\u5728\u78c1\u76d8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7aef\u53e3\u51b2\u7a81 \/ Redis \u672a\u76d1\u542c<\/p>\n<\/td>\n<td>netstat -tulnpss -lntp<\/td>\n<td>\n<p>\u67e5\u770b\u7aef\u53e3\u5360\u7528\u60c5\u51b5<\/p>\n<\/td>\n<td>\n<p>\u53d1\u73b0 Redis \u914d\u7f6e\u76d1\u542c\u7aef\u53e3\u672a\u542f\u52a8\u6216\u7aef\u53e3\u88ab\u5176\u4ed6\u8fdb\u7a0b\u5360\u7528<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8fdb\u7a0b\u662f\u5426\u5b58\u5728 \/ \u591a\u5f00<\/p>\n<\/td>\n<td>\n<p>&#096;ps aux<\/p>\n<\/td>\n<td>\n<p>grep redis&lt;br&gt;pgrep -f redis&#096;<\/p>\n<\/td>\n<td>\n<p>\u786e\u8ba4\u8fdb\u7a0b\u662f\u5426\u5df2\u8fd0\u884c\u3001\u662f\u5426\u91cd\u590d\u542f\u52a8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: left\">\u6709\u6b21\u7ebf\u4e0a\u7cfb\u7edf\u54cd\u5e94\u53d8\u6162&#xff0c;\u6211\u7528\u00a0top\u00a0\u67e5\u5230 Java \u8fdb\u7a0b CPU 99%&#xff0c;\u7ed3\u5408\u00a0jstack\u00a0\u6293\u53d6\u7ebf\u7a0b\u6808&#xff0c;\u786e\u8ba4\u67d0\u6b7b\u5faa\u73af\u903b\u8f91\u5bfc\u81f4\u5360\u7528&#xff1b;\u4e5f\u9047\u5230\u78c1\u76d8\u5f02\u5e38&#xff0c;df\u00a0\u53d1\u73b0\u00a0\/var\u00a0\u5206\u533a\u6ee1\u4e86&#xff0c;\u7528\u00a0du\u00a0\u5feb\u901f\u627e\u5230\u662f\u65e5\u5fd7\u7206\u91cf&#xff1b;\u53e6\u5916\u8fd8\u7528\u00a0iostat\u00a0\u5b9a\u4f4d IO \u7b49\u5f85\u9ad8&#xff0c;\u7ed3\u5408\u65e5\u5fd7\u6539\u5199\u7b56\u7565\u7f13\u89e3\u4e86\u74f6\u9888\u3002<\/p>\n<p style=\"text-align: left\">\u5728 MongoDB \u4e2d&#xff0c;\u6211\u4eec\u4e0d\u4f1a\u8bf4\u201c\u5e93\u201d\u548c\u201c\u8868\u201d&#xff0c;\u800c\u662f\u4f7f\u7528\u4ee5\u4e0b\u672f\u8bed&#xff1a;<\/p>\n<table>\n<tr>\n<p>\u901a\u7528\u6570\u636e\u5e93\u672f\u8bed<\/p>\n<p>MongoDB \u4e2d\u7684\u672f\u8bed<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u6570\u636e\u5e93&#xff08;Database&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u6570\u636e\u5e93&#xff08;Database&#xff09; \u2705<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8868&#xff08;Table&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u96c6\u5408&#xff08;Collection&#xff09; \u2705<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u884c&#xff08;Row&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u6587\u6863&#xff08;Document&#xff09; \u2705<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5217&#xff08;Column&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u5b57\u6bb5&#xff08;Field&#xff09; \u2705<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u2705 MongoDB \u7684\u57fa\u672c\u7ed3\u6784&#xff1a;<\/h3>\n<p> MongoDB Server<br \/>\n\u00a0\u2514\u2500\u2500 Database&#xff08;\u6570\u636e\u5e93&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u2514\u2500\u2500 Collection&#xff08;\u96c6\u5408&#xff0c;\u76f8\u5f53\u4e8e\u8868&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u2514\u2500\u2500 Document&#xff08;\u6587\u6863&#xff0c;\u76f8\u5f53\u4e8e\u884c&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2514\u2500\u2500 Field&#xff08;\u5b57\u6bb5&#xff0c;\u76f8\u5f53\u4e8e\u5217&#xff09; <\/p>\n<hr \/>\n<h3>\u2705 \u4e3e\u4f8b\u8bf4\u660e<\/h3>\n<h4>\u521b\u5efa\u6570\u636e\u5e93\u548c\u96c6\u5408&#xff08;\u76f8\u5f53\u4e8e\u201c\u5efa\u5e93\u5efa\u8868\u201d&#xff09;&#xff1a;<\/h4>\n<p> use mydb \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u9009\u62e9\u6216\u521b\u5efa\u6570\u636e\u5e93<\/p>\n<p>db.createCollection(&#034;users&#034;) \u00a0\/\/ \u521b\u5efa\u96c6\u5408&#xff0c;\u76f8\u5f53\u4e8e\u521b\u5efa\u8868 <\/p>\n<hr \/>\n<h4>\u63d2\u5165\u6587\u6863&#xff08;\u76f8\u5f53\u4e8e\u63d2\u5165\u4e00\u884c&#xff09;&#xff1a;<\/h4>\n<p> db.users.insertOne({<br \/>\n\u00a0 name:\u00a0&#034;\u5f20\u4e09&#034;,<br \/>\n\u00a0 age: 28,<br \/>\n\u00a0 email:\u00a0&#034;zhangsan&#064;example.com&#034;<br \/>\n}) <\/p>\n<hr \/>\n<h4>\u67e5\u8be2\u6587\u6863&#xff1a;<\/h4>\n<p> db.users.find({ age: {\u00a0$gt: 25 } }) <\/p>\n<hr \/>\n<h3>\u2705 MongoDB \u7279\u70b9 vs \u5173\u7cfb\u578b\u6570\u636e\u5e93<\/h3>\n<table>\n<tr>\n<p>MongoDB&#xff08;\u6587\u6863\u578b&#xff09;<\/p>\n<p>MySQL \/ PostgreSQL&#xff08;\u5173\u7cfb\u578b&#xff09;<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u65e0\u56fa\u5b9a\u8868\u7ed3\u6784<\/p>\n<\/td>\n<td>\n<p>\u8868\u7ed3\u6784\u9700\u63d0\u524d\u5b9a\u4e49\u5b57\u6bb5\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u652f\u6301\u5d4c\u5957\u6587\u6863\u3001\u6570\u7ec4\u5b57\u6bb5<\/p>\n<\/td>\n<td>\n<p>\u4e0d\u652f\u6301\u5d4c\u5957\u5bf9\u8c61<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7075\u6d3b\u5199\u5165&#xff0c;\u5b57\u6bb5\u53ef\u4e0d\u540c<\/p>\n<\/td>\n<td>\n<p>\u6bcf\u884c\u5b57\u6bb5\u4e00\u81f4&#xff0c;\u5f3a\u7c7b\u578b\u7ea6\u675f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u4f7f\u7528 JSON\/BSON \u5b58\u50a8\u6587\u6863<\/p>\n<\/td>\n<td>\n<p>\u4f7f\u7528\u884c\u5217\u5f0f\u5b58\u50a8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p style=\"text-align: left\">\u5982\u679c\u4f60\u60f3\u67e5\u770b Mongo \u5f53\u524d\u6240\u6709\u5e93\/\u8868&#xff08;\u96c6\u5408&#xff09;&#xff1a;<\/p>\n<h4>\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93&#xff1a;<\/h4>\n<p> show dbs <\/p>\n<h4>\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u6240\u6709\u96c6\u5408&#xff08;\u8868&#xff09;&#xff1a;<\/h4>\n<p> show collections <\/p>\n<hr \/>\n<p style=\"text-align: left\">\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 MongoDB \u793a\u4f8b\u9879\u76ee\u7ed3\u6784&#xff0c;\u6a21\u62df\u5e38\u89c1\u7684\u00a0\u7528\u6237&#xff08;users&#xff09;&#043; \u8ba2\u5355&#xff08;orders&#xff09;\u00a0\u6a21\u578b&#xff0c;\u9002\u5408\u5b9e\u9645\u5f00\u53d1\u7528\u4f5c\u9879\u76ee\u521d\u59cb\u5316&#xff1a;<\/p>\n<hr \/>\n<h3>\u2705 \u9879\u76ee\u7ed3\u6784\u8bf4\u660e<\/h3>\n<ul>\n<li>\n<p style=\"text-align: left\">\u6570\u636e\u5e93&#xff1a;demo_app<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u96c6\u5408&#xff1a;<\/p>\n<\/li>\n<li>\n<ul>\n<li>\n<p style=\"text-align: left\">users&#xff1a;\u7528\u6237\u4fe1\u606f<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">orders&#xff1a;\u7528\u6237\u8ba2\u5355&#xff08;\u5305\u542b\u7528\u6237 ID \u4f5c\u4e3a\u5916\u952e&#xff09;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u2705 \u521d\u59cb\u5316\u811a\u672c&#xff08;Mongo Shell \u8bed\u6cd5&#xff09;<\/h3>\n<p style=\"text-align: left\">\u4f60\u53ef\u4ee5\u590d\u5236\u7c98\u8d34\u5230 Mongo Shell \/\u00a0mongosh\u00a0\u4e2d\u8fd0\u884c&#xff1a;<\/p>\n<p> \/\/ 1. \u5207\u6362\u6216\u521b\u5efa\u6570\u636e\u5e93<br \/>\nuse demo_app<\/p>\n<p>\/\/ 2. \u521b\u5efa users \u96c6\u5408\u5e76\u63d2\u5165\u793a\u4f8b\u6587\u6863<br \/>\ndb.createCollection(&#034;users&#034;)<\/p>\n<p>db.users.insertMany([<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0 _id: ObjectId(),<br \/>\n\u00a0 \u00a0 username:\u00a0&#034;alice&#034;,<br \/>\n\u00a0 \u00a0 email:\u00a0&#034;alice&#064;example.com&#034;,<br \/>\n\u00a0 \u00a0 phone:\u00a0&#034;1234567890&#034;,<br \/>\n\u00a0 \u00a0 createdAt: new Date()<br \/>\n\u00a0 },<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0 _id: ObjectId(),<br \/>\n\u00a0 \u00a0 username:\u00a0&#034;bob&#034;,<br \/>\n\u00a0 \u00a0 email:\u00a0&#034;bob&#064;example.com&#034;,<br \/>\n\u00a0 \u00a0 phone:\u00a0&#034;9876543210&#034;,<br \/>\n\u00a0 \u00a0 createdAt: new Date()<br \/>\n\u00a0 }<br \/>\n])<\/p>\n<p>\/\/ 3. \u521b\u5efa orders \u96c6\u5408\u5e76\u63d2\u5165\u793a\u4f8b\u6587\u6863<br \/>\ndb.createCollection(&#034;orders&#034;)<\/p>\n<p>db.orders.insertMany([<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0 _id: ObjectId(),<br \/>\n\u00a0 \u00a0 userId: db.users.findOne({username:\u00a0&#034;alice&#034;})._id,<br \/>\n\u00a0 \u00a0 item:\u00a0&#034;iPhone 15&#034;,<br \/>\n\u00a0 \u00a0 price: 7999,<br \/>\n\u00a0 \u00a0 status:\u00a0&#034;PAID&#034;,<br \/>\n\u00a0 \u00a0 createdAt: new Date()<br \/>\n\u00a0 },<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0 _id: ObjectId(),<br \/>\n\u00a0 \u00a0 userId: db.users.findOne({username:\u00a0&#034;bob&#034;})._id,<br \/>\n\u00a0 \u00a0 item:\u00a0&#034;MacBook Air&#034;,<br \/>\n\u00a0 \u00a0 price: 9999,<br \/>\n\u00a0 \u00a0 status:\u00a0&#034;SHIPPED&#034;,<br \/>\n\u00a0 \u00a0 createdAt: new Date()<br \/>\n\u00a0 }<br \/>\n])<\/p>\n<p>\/\/ 4. \u5efa\u7acb\u7d22\u5f15&#xff08;\u5982\u7528\u6237\u90ae\u7bb1\u552f\u4e00&#xff09;<br \/>\ndb.users.createIndex({ email: 1 }, { unique:\u00a0true\u00a0})<br \/>\ndb.orders.createIndex({ userId: 1 }) <\/p>\n<hr \/>\n<h3>\u2705 \u67e5\u8be2\u793a\u4f8b<\/h3>\n<h4>\u67e5\u627e\u67d0\u7528\u6237\u7684\u8ba2\u5355&#xff1a;<\/h4>\n<p> const user &#061; db.users.findOne({ username:\u00a0&#034;alice&#034;\u00a0})<br \/>\ndb.orders.find({ userId: user._id }) <\/p>\n<h4>\u67e5\u8be2\u6240\u6709\u8ba2\u5355\u5e76\u5e26\u4e0a\u7528\u6237\u4fe1\u606f&#xff08;\u5173\u8054\u67e5\u8be2&#xff09;&#xff1a;<\/h4>\n<p> db.orders.aggregate([<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0\u00a0$lookup: {<br \/>\n\u00a0 \u00a0 \u00a0 from:\u00a0&#034;users&#034;,<br \/>\n\u00a0 \u00a0 \u00a0 localField:\u00a0&#034;userId&#034;,<br \/>\n\u00a0 \u00a0 \u00a0 foreignField:\u00a0&#034;_id&#034;,<br \/>\n\u00a0 \u00a0 \u00a0 as:\u00a0&#034;userInfo&#034;<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 },<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0\u00a0$unwind:\u00a0&#034;$userInfo&#034;<br \/>\n\u00a0 },<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0\u00a0$project: {<br \/>\n\u00a0 \u00a0 \u00a0 item: 1,<br \/>\n\u00a0 \u00a0 \u00a0 price: 1,<br \/>\n\u00a0 \u00a0 \u00a0 status: 1,<br \/>\n\u00a0 \u00a0 \u00a0\u00a0&#034;userInfo.username&#034;: 1,<br \/>\n\u00a0 \u00a0 \u00a0\u00a0&#034;userInfo.email&#034;: 1<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 }<br \/>\n]) <\/p>\n<hr \/>\n<p style=\"text-align: left\">\u5982\u679c MongoDB \u4e2d\u7684\u8ba2\u5355\u96c6\u5408&#xff08;orders&#xff09;\u8d85\u8fc7 1000 \u4e07\u6761\u6570\u636e&#xff0c;\u60f3\u8981\u7ef4\u6301\u67e5\u8be2\u6027\u80fd\u548c\u7cfb\u7edf\u53ef\u6269\u5c55\u6027&#xff0c;\u5fc5\u987b\u4ece\u591a\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u4f18\u5316&#xff1a;<\/p>\n<hr \/>\n<h3>\u2705 \u4e00\u3001\u7d22\u5f15\u4f18\u5316&#xff08;\u6700\u5173\u952e&#xff09;<\/h3>\n<h4>1\ufe0f\u20e3 \u5efa\u7acb\u9ad8\u547d\u4e2d\u7387\u7684\u7ec4\u5408\u7d22\u5f15<\/h4>\n<p style=\"text-align: left\">\u4f8b\u5982\u5e38\u89c1\u67e5\u8be2\u6761\u4ef6&#xff1a;<\/p>\n<p> db.orders.find({ userId: xxx, status:\u00a0&#034;PAID&#034;\u00a0}) <\/p>\n<p style=\"text-align: left\">\u5e94\u5efa\u7acb&#xff1a;<\/p>\n<p> db.orders.createIndex({ userId: 1, status: 1 }) <\/p>\n<h4>2\ufe0f\u20e3 \u5e38\u7528\u5b57\u6bb5\u5982\u00a0createdAt\u00a0\u7528\u4e8e\u5206\u9875\/\u8303\u56f4\u67e5\u8be2&#xff1a;<\/h4>\n<p> db.orders.find({ createdAt: {\u00a0$gte: ISODate(&#039;2024-01-01&#039;) } }).sort({ createdAt: -1 }).limit(50) <\/p>\n<p style=\"text-align: left\">\u5e94\u5efa\u7acb&#xff1a;<\/p>\n<p> db.orders.createIndex({ createdAt: -1 }) <\/p>\n<h4>3\ufe0f\u20e3 \u67e5\u8be2\u6162\u65f6&#xff0c;\u7528\u00a0explain()\u00a0\u5206\u6790\u7d22\u5f15\u547d\u4e2d&#xff1a;<\/h4>\n<p> db.orders.find({ userId: xxx }).explain(&#034;executionStats&#034;) <\/p>\n<hr \/>\n<h3>\u2705 \u4e8c\u3001\u5206\u9875\u4f18\u5316&#xff08;\u907f\u514d\u6df1\u5ea6 skip&#xff09;<\/h3>\n<p style=\"text-align: left\">\u4e0d\u8981\u4f7f\u7528\u00a0skip\u00a0\u6df1\u5206\u9875&#xff0c;\u6027\u80fd\u4f1a\u6307\u6570\u4e0b\u964d\u3002<\/p>\n<h4>\u274c \u4e0d\u63a8\u8350&#xff1a;<\/h4>\n<p> db.orders.find().skip(1000000).limit(10) <\/p>\n<h4>\u2705 \u63a8\u8350&#xff1a;<\/h4>\n<p style=\"text-align: left\">\u4f7f\u7528\u00a0createdAt\u00a0\u6216\u00a0_id\u00a0\u505a\u6e38\u6807\u5206\u9875&#xff08;\u57fa\u4e8e\u201c\u4e0a\u6b21\u6700\u540e\u4e00\u6761\u201d&#xff09;&#xff1a;<\/p>\n<p> db.orders.find({ createdAt: {\u00a0$lt: \u4e0a\u4e00\u9875\u6700\u540e\u65f6\u95f4 } }).sort({ createdAt: -1 }).limit(10) <\/p>\n<hr \/>\n<h3>\u2705 \u4e09\u3001\u51b7\u70ed\u5206\u79bb \/ \u5206\u8868\u7b56\u7565<\/h3>\n<h4>&#x1f539; 1&#xff09;\u51b7\u70ed\u6570\u636e\u62c6\u5206<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u6700\u8fd1 6 \u4e2a\u6708\u7684\u6570\u636e\u4fdd\u7559\u5728\u4e3b\u00a0orders\u00a0\u8868\u4e2d<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u5386\u53f2\u8ba2\u5355\u5f52\u6863\u5230\u00a0orders_history\u00a0\u8868&#xff08;\u6216\u53e6\u4e00\u4e2a\u5e93&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p style=\"text-align: left\">\u4f7f\u7528\u811a\u672c\u5b9a\u671f\u5f52\u6863&#xff1a;<\/p>\n<p> db.orders.aggregate([<br \/>\n\u00a0 {\u00a0$match: { createdAt: {\u00a0$lt: ISODate(&#039;2024-01-01&#039;) } } },<br \/>\n\u00a0 {\u00a0$merge: { into:\u00a0&#034;orders_history&#034;\u00a0} }<br \/>\n]) <\/p>\n<p style=\"text-align: left\">\u7136\u540e\u5728\u00a0orders\u00a0\u4e2d\u5220\u9664\u8001\u6570\u636e\u3002<\/p>\n<hr \/>\n<h4>&#x1f539; 2&#xff09;\u6309\u65f6\u95f4\/\u7528\u6237 ID \u5206\u8868<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">orders_2024,\u00a0orders_2023<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">orders_user_0,\u00a0orders_user_1&#xff08;\u6309 userId hash&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p style=\"text-align: left\">\u7f3a\u70b9&#xff1a;\u5e94\u7528\u5c42\u9700\u8981\u52a8\u6001\u8def\u7531\u67e5\u8be2\u903b\u8f91\u3002<\/p>\n<hr \/>\n<h3>\u2705 \u56db\u3001\u538b\u7f29\u4e0e\u6570\u636e\u7cbe\u7b80<\/h3>\n<h4>&#x1f538; 1&#xff09;\u5b57\u6bb5\u538b\u7f29&#xff08;\u7cbe\u7b80\u6587\u6863\u7ed3\u6784&#xff09;<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u907f\u514d\u5197\u4f59\u5d4c\u5957\u5b57\u6bb5<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u5b57\u6bb5\u540d\u7528\u77ed\u540d&#xff08;\u5982\u00a0uid\u00a0\u66ff\u4ee3\u00a0userId&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f538; 2&#xff09;\u5173\u95ed\u4e0d\u5fc5\u8981\u5b57\u6bb5\u7d22\u5f15<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u4e0d\u67e5\u8be2\u7684\u5b57\u6bb5\u4e0d\u8981\u5efa\u7d22\u5f15&#xff08;\u6d6a\u8d39\u5199\u5165\u6027\u80fd &#043; \u7a7a\u95f4&#xff09;<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u2705 \u4e94\u3001\u5199\u5165\u4f18\u5316<\/h3>\n<h4>\u6279\u91cf\u5199\u5165&#xff1a;<\/h4>\n<p> db.orders.insertMany([&#8230;]) <\/p>\n<h4>\u5408\u7406\u8bbe\u7f6e\u00a0_id<\/h4>\n<p style=\"text-align: left\">\u4f7f\u7528\u81ea\u5b9a\u4e49\u987a\u5e8f\u751f\u6210\u00a0_id&#xff0c;\u53ef\u907f\u514d\u9ed8\u8ba4 ObjectId \u5e26\u6765\u7684\u5206\u5e03\u5199\u5165\u653e\u5927\u95ee\u9898&#xff08;\u4f46\u901a\u5e38\u5f71\u54cd\u4e0d\u5927&#xff09;\u3002<\/p>\n<hr \/>\n<h3>\u2705 \u516d\u3001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5de5\u5177<\/h3>\n<ul>\n<li>\n<p style=\"text-align: left\">db.orders.stats()\u00a0\u67e5\u770b\u96c6\u5408\u5927\u5c0f<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">db.orders.totalIndexSize()\u00a0\u67e5\u770b\u7d22\u5f15\u7a7a\u95f4<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">mongotop,\u00a0mongostat,\u00a0Atlas Profiler\u00a0\u5b9e\u65f6\u76d1\u63a7<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">explain()\u00a0\u5b9a\u4f4d\u6162\u67e5\u8be2<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u2705 \u4e03\u3001\u67b6\u6784\u5c42\u6269\u5c55&#xff08;\u6781\u7aef\u9ad8\u5e76\u53d1&#xff09;<\/h3>\n<p style=\"text-align: left\">\u5982\u679c\u6570\u636e\u91cf\u548c\u5e76\u53d1\u518d\u63d0\u5347&#xff0c;\u53ef\u8003\u8651&#xff1a;<\/p>\n<ul>\n<li>\n<p style=\"text-align: left\">MongoDB \u5206\u7247\u96c6\u7fa4&#xff08;Sharding&#xff09;<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u70ed\u6570\u636e\u4f7f\u7528 Redis \u7f13\u5b58<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u5386\u53f2\u6570\u636e\u5f52\u6863\u5230 ElasticSearch \u7528\u4e8e\u68c0\u7d22<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u2705 \u6700\u7ec8\u5efa\u8bae\u5c0f\u7ed3<\/h3>\n<table>\n<tr>\n<p>\u4f18\u5316\u65b9\u5411<\/p>\n<p>\u5efa\u8bae<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u7d22\u5f15<\/p>\n<\/td>\n<td>\n<p>\u7ec4\u5408\u7d22\u5f15 &#043; \u521b\u5efa\u65f6\u95f4\u7d22\u5f15<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5206\u9875<\/p>\n<\/td>\n<td>\n<p>\u6e38\u6807\u5206\u9875\u4ee3\u66ff skip<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5206\u8868<\/p>\n<\/td>\n<td>\n<p>\u70ed\/\u51b7\u6570\u636e\u5206\u79bb\u6216\u6309\u65f6\u95f4\u5206\u8868<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7ed3\u6784\u4f18\u5316<\/p>\n<\/td>\n<td>\n<p>\u5b57\u6bb5\u7cbe\u7b80\u3001\u53bb\u5197\u4f59\u3001\u6587\u6863\u5927\u5c0f\u63a7\u5236<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u67e5\u8be2\u4f18\u5316<\/p>\n<\/td>\n<td>\n<p>\u4f7f\u7528 explain \u5206\u6790\u7d22\u5f15\u4f7f\u7528\u60c5\u51b5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u6269\u5c55\u65b9\u6848<\/p>\n<\/td>\n<td>\n<p>\u6570\u636e\u5206\u7247 &#043; Redis \u7f13\u5b58 &#043; ES \u68c0\u7d22<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p style=\"text-align: left\">\u4f60\u63d0\u5230\u7684\u4e09\u79cd\u67b6\u6784\u4f18\u5316\u7b56\u7565\u662f\u6784\u5efa\u9ad8\u5e76\u53d1 &#043; \u5927\u6570\u636e\u91cf\u7cfb\u7edf\u7684\u6838\u5fc3\u65b9\u5f0f&#xff0c;\u9002\u7528\u4e8e\u8ba2\u5355\u7c7b\u7cfb\u7edf\u3001\u65e5\u5fd7\u7cfb\u7edf\u3001\u4ea4\u6613\u7cfb\u7edf\u7b49\u573a\u666f\u3002\u4e0b\u9762\u662f\u5bf9&#xff1a;<\/p>\n<ul>\n<li>\n<p style=\"text-align: left\">MongoDB \u5206\u7247\u96c6\u7fa4&#xff08;Sharding&#xff09;<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">Redis \u7f13\u5b58\u70ed\u6570\u636e<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">ElasticSearch \u5f52\u6863\u5386\u53f2\u6570\u636e<\/p>\n<\/li>\n<\/ul>\n<p style=\"text-align: left\">\u4e09\u8005\u7684\u00a0\u4f5c\u7528\u3001\u539f\u7406\u3001\u5b9e\u73b0\u65b9\u5f0f\u00a0\u7684\u8be6\u89e3&#xff1a;<\/p>\n<hr \/>\n<h3>\u2705 \u4e00\u3001MongoDB \u5206\u7247\u96c6\u7fa4&#xff08;Sharding&#xff09;<\/h3>\n<h4>&#x1f4cc; \u4f5c\u7528&#xff1a;<\/h4>\n<p style=\"text-align: left\">\u5c06\u00a0\u6d77\u91cf\u6570\u636e\u6c34\u5e73\u62c6\u5206\u00a0\u5230\u591a\u4e2a\u5206\u7247\u8282\u70b9&#xff08;shard&#xff09;\u4e0a&#xff0c;\u5b9e\u73b0\u00a0\u8bfb\u5199\u8d1f\u8f7d\u5747\u8861 &#043; \u65e0\u9650\u6269\u5c55\u5bb9\u91cf\u3002<\/p>\n<h4>&#x1f9e0; \u539f\u7406&#xff1a;<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u6309\u7167\u00a0shard key\u00a0\u5c06\u6570\u636e\u5206\u53d1\u5230\u4e0d\u540c\u5206\u7247<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u67e5\u8be2\u7531 Mongos&#xff08;\u8def\u7531\u5668&#xff09;\u6839\u636e key \u5b9a\u5411\u5230\u6b63\u786e shard<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f4e6; \u67b6\u6784\u7ec4\u6210&#xff1a;<\/h4>\n<p> \u5ba2\u6237\u7aef<br \/>\n\u00a0 \u00a0\u2502<br \/>\n\u00a0\u250c\u2500\u25bc\u2500\u2510<br \/>\n\u00a0\u2502mongos \u8def\u7531\u5668\u2502\u2190 \u591a\u4e2a&#xff0c;\u53ef\u6a2a\u5411\u6269\u5c55<br \/>\n\u00a0\u2514\u2500\u25b2\u2500\u2518<br \/>\n\u00a0 \u00a0\u2502<br \/>\n\u00a0\u250c\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u00a0\u2502 \u00a0 \u00a0 Config Servers \u00a0 \u00a0 \u2502 \u2190 \u914d\u7f6e\u5143\u6570\u636e&#xff0c;3 \u4e2a\u6216\u4ee5\u4e0a<br \/>\n\u00a0\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n\u00a0 \u00a0\u2502<br \/>\n\u00a0\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u00a0\u2502 \u00a0 \u00a0Shard1 \u00a0 \u00a0\u2502 \u00a0 \u00a0 Shard2 \u00a0 \u2502 \u00a0&#8230; \u53ef\u6269\u5c55<br \/>\n\u00a0\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 <\/p>\n<h4>&#x1f527; \u793a\u4f8b\u914d\u7f6e\u6b65\u9aa4&#xff08;\u7b80\u7565&#xff09;&#xff1a;<\/h4>\n<li>\n<p style=\"text-align: left\">\u914d\u7f6e\u5206\u7247\u96c6\u7fa4&#xff1a;mongod &#8211;shardsvr<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u914d\u7f6e router&#xff1a;mongos &#8211;configdb<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u6dfb\u52a0\u5206\u7247&#xff1a;<\/p>\n<\/li>\n<p> sh.addShard(&#034;shard1\/host1:27017&#034;)<br \/>\nsh.addShard(&#034;shard2\/host2:27017&#034;) <\/p>\n<li>\n<p style=\"text-align: left\">\u542f\u7528\u5206\u7247&#xff1a;<\/p>\n<\/li>\n<p> sh.enableSharding(&#034;demo_app&#034;)<br \/>\nsh.shardCollection(&#034;demo_app.orders&#034;, { userId: 1 }) \/\/ \u6216 createdAt <\/p>\n<hr \/>\n<h3>\u2705 \u4e8c\u3001Redis \u7f13\u5b58\u70ed\u6570\u636e&#xff08;\u8bfb\u591a\u5199\u5c11&#xff09;<\/h3>\n<h4>&#x1f4cc; \u4f5c\u7528&#xff1a;<\/h4>\n<p style=\"text-align: left\">\u5c06\u9ad8\u9891\u8bfb\u7684\u6570\u636e&#xff08;\u5982\u7528\u6237\u6700\u65b0\u8ba2\u5355\u3001\u8ba2\u5355\u72b6\u6001&#xff09;\u7f13\u5b58\u5230 Redis&#xff0c;\u907f\u514d MongoDB \u9891\u7e41\u67e5\u8be2\u3002<\/p>\n<h4>&#x1f9e0; \u9002\u5408\u6570\u636e&#xff1a;<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u6700\u8fd1 24 \u5c0f\u65f6\u7684\u8ba2\u5355\u72b6\u6001<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u7528\u6237\u5e38\u8bbf\u95ee\u7684\u8ba2\u5355\u8be6\u60c5<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u67e5\u8be2\u7ed3\u679c\u7f13\u5b58&#xff08;\u9632\u6b62\u91cd\u590d\u5206\u9875&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f6e0;\ufe0f \u7f13\u5b58\u7b56\u7565\u5efa\u8bae&#xff1a;<\/h4>\n<table>\n<tr>\n<p>\u9879\u76ee<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>Key \u8bbe\u8ba1<\/p>\n<\/td>\n<td>order:{orderId}<\/p>\n<p>\u00a0\u6216\u00a0user:{id}:orders<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5931\u6548\u7b56\u7565<\/p>\n<\/td>\n<td>\n<p>\u70ed\u70b9\u6570\u636e\u8bbe\u5b9a 1h&#xff5e;12h TTL \u6216 LRU<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u4e00\u81f4\u6027\u7b56\u7565<\/p>\n<\/td>\n<td>\n<p>\u5199\u5165 Mongo \u540e\u7acb\u5373\u5199\u5165 Redis&#xff0c;\u6216\u5ef6\u8fdf\u4e00\u81f4\u6027\u540c\u6b65<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u4f7f\u7528\u65b9\u5f0f<\/p>\n<\/td>\n<td>\n<p>\u5148\u67e5 Redis&#xff0c;\u65e0\u6570\u636e\u518d\u67e5 Mongo<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> \/\/ \u4f2a\u4ee3\u7801<br \/>\nlet\u00a0data &#061; redis.get(&#096;order:${orderId}&#096;)<br \/>\nif\u00a0(!data) {<br \/>\n\u00a0 data &#061; db.orders.findOne({ _id: orderId })<br \/>\n\u00a0 redis.set(&#096;order:${orderId}&#096;, JSON.stringify(data),\u00a0&#034;EX&#034;, 3600)<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u4e09\u3001ElasticSearch \u5f52\u6863\u5386\u53f2\u6570\u636e&#xff08;\u5168\u6587\u68c0\u7d22 &#043; \u805a\u5408&#xff09;<\/h3>\n<h4>&#x1f4cc; \u4f5c\u7528&#xff1a;<\/h4>\n<p style=\"text-align: left\">\u5c06\u00a0\u8001\u8ba2\u5355\u6570\u636e&#xff08;\u5982 6 \u4e2a\u6708\u524d&#xff09;\u00a0\u5bfc\u5165\u5230 ES&#xff0c;\u652f\u6301\u5feb\u901f\u641c\u7d22\u3001\u5206\u9875\u3001\u590d\u6742\u7edf\u8ba1\u5206\u6790&#xff0c;\u800c\u4e0d\u5f71\u54cd Mongo \u7684\u8bfb\u5199\u538b\u529b\u3002<\/p>\n<h4>&#x1f9e0; \u4e3a\u4ec0\u4e48\u7528 ES&#xff1a;<\/h4>\n<ul>\n<li>\n<p style=\"text-align: left\">\u5feb\u901f\u5168\u6587\u641c\u7d22&#xff08;\u652f\u6301\u6a21\u7cca\u5339\u914d&#xff09;<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u652f\u6301\u590d\u6742\u805a\u5408\u67e5\u8be2&#xff08;\u5982\u8ba2\u5355\u91d1\u989d\u7edf\u8ba1&#xff09;<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u81ea\u5e26\u5012\u6392\u7d22\u5f15&#xff0c;\u9002\u5408\u6d77\u91cf\u6570\u636e<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f527; \u5b9e\u73b0\u65b9\u5f0f&#xff1a;<\/h4>\n<li>\n<p style=\"text-align: left\">\u4f7f\u7528\u540c\u6b65\u5de5\u5177\u5bfc\u5165\u6570\u636e&#xff0c;\u5982&#xff1a;<\/p>\n<\/li>\n<ul>\n<li>\n<p style=\"text-align: left\">mongo-connector&#xff08;\u5df2\u8fc7\u65f6&#xff09;<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">\u81ea\u5efa\u540c\u6b65\u7a0b\u5e8f<\/p>\n<\/li>\n<li>\n<p style=\"text-align: left\">Logstash &#043; MongoDB input plugin<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p style=\"text-align: left\">\u793a\u4f8b\u6570\u636e\u7ed3\u6784&#xff1a;<\/p>\n<\/li>\n<li>{<br \/>\n\u00a0\u00a0&#034;orderId&#034;:\u00a0&#034;abc123&#034;,<br \/>\n\u00a0\u00a0&#034;userId&#034;:\u00a0&#034;u001&#034;,<br \/>\n\u00a0\u00a0&#034;item&#034;:\u00a0&#034;MacBook Air&#034;,<br \/>\n\u00a0\u00a0&#034;status&#034;:\u00a0&#034;PAID&#034;,<br \/>\n\u00a0\u00a0&#034;createdAt&#034;:\u00a0&#034;2023-05-01T12:00:00&#034;<br \/>\n} <\/p>\n<li>\n<p style=\"text-align: left\">\u67e5\u8be2\u793a\u4f8b&#xff08;DSL&#xff09;&#xff1a;<\/p>\n<\/li>\n<p> {<br \/>\n\u00a0\u00a0&#034;query&#034;: {<br \/>\n\u00a0 \u00a0\u00a0&#034;bool&#034;: {<br \/>\n\u00a0 \u00a0 \u00a0\u00a0&#034;must&#034;: [<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 {\u00a0&#034;match&#034;: {\u00a0&#034;status&#034;:\u00a0&#034;PAID&#034;\u00a0} },<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 {\u00a0&#034;range&#034;: {\u00a0&#034;createdAt&#034;: {\u00a0&#034;lt&#034;:\u00a0&#034;2024-01-01&#034;\u00a0} } }<br \/>\n\u00a0 \u00a0 \u00a0 ]<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 }<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u67b6\u6784\u534f\u540c\u4f7f\u7528\u5efa\u8bae&#xff08;\u751f\u4ea7\u5b9e\u8df5&#xff09;<\/h3>\n<table>\n<tr>\n<p>\u573a\u666f<\/p>\n<p>\u4f7f\u7528\u65b9\u6848<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u5b9e\u65f6\u5199\u5165\u3001\u8bfb\u5199\u5206\u5e03\u5f0f\u6269\u5c55<\/p>\n<\/td>\n<td>\n<p>MongoDB \u5206\u7247\u96c6\u7fa4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u9ad8\u9891\u8bbf\u95ee\u8ba2\u5355\u72b6\u6001\u6216\u6700\u8fd1\u5217\u8868<\/p>\n<\/td>\n<td>\n<p>Redis \u7f13\u5b58<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5386\u53f2\u8ba2\u5355\u6a21\u7cca\u641c\u7d22\u3001\u7edf\u8ba1\u5206\u6790<\/p>\n<\/td>\n<td>\n<p>ElasticSearch \u5b58\u6863&#043;\u67e5\u8be2<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u2705 \u4e00\u5f20\u56fe\u603b\u7ed3&#xff1a;<\/h3>\n<p> &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0\u524d\u7aef \/ \u63a5\u53e3 \u00a0 \u00a0 \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#043;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;\u25bc&#8212;&#8212;&#8211;&#043; \u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;\u25bc&#8212;&#8212;&#8211;&#043;<br \/>\n\u00a0 \u00a0 \u00a0| \u00a0 \u00a0Redis \u7f13\u5b58 \u00a0 \u00a0| \u00a0 \u00a0 \u00a0| \u00a0 \u00a0 MongoDB \u00a0 \u00a0 \u00a0|<br \/>\n\u00a0 \u00a0 \u00a0| \u70ed\u70b9\u8ba2\u5355\/\u72b6\u6001 \u00a0 \u00a0| \u00a0 \u00a0 \u00a0| \u00a0 \u5206\u7247\u8ba2\u5355\u4e3b\u5e93 \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043; \u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;\u25bc&#8212;&#8212;&#8211;&#043; \u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8211;\u25bc&#8212;&#8212;&#8211;&#043;<br \/>\n\u00a0 \u00a0 \u00a0| \u00a0 \u00a0ElasticSearch | \u00a0 \u00a0 \u00a0| \u00a0 Mongo Archive |<br \/>\n\u00a0 \u00a0 \u00a0| \u5386\u53f2\u8ba2\u5355\u68c0\u7d22\/\u7edf\u8ba1 | \u00a0 \u00a0 \u00a0| \u5386\u53f2\u6570\u636e\u51b7\u5b58\u50a8 \u00a0|<br \/>\n\u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043; \u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043; <\/p>\n<hr \/>\n<p style=\"text-align: left\">\u4f60\u60f3\u8981\u7684 Java \u5b9e\u73b0\u65b9\u6848&#xff0c;\u5176\u76ee\u6807\u662f&#xff1a;<\/p>\n<p style=\"text-align: left\">\u6784\u5efa\u4e00\u4e2a\u7cfb\u7edf&#xff1a;\u4f7f\u7528 MongoDB \u5206\u7247\u96c6\u7fa4\u4fdd\u5b58\u8ba2\u5355\u6570\u636e&#xff0c;Redis \u7f13\u5b58\u70ed\u6570\u636e&#xff0c;Elasticsearch \u5b58\u50a8\u5386\u53f2\u6570\u636e&#xff0c;\u5e76\u901a\u8fc7 Java \u670d\u52a1\u8bfb\u5199\u534f\u8c03\u3002<\/p>\n<hr \/>\n<h3>\u2705 \u76ee\u5f55\u7ed3\u6784\u6982\u89c8<\/h3>\n<p style=\"text-align: left\">\u6211\u4eec\u5c06\u4ece\u4ee5\u4e0b 3 \u4e2a\u6838\u5fc3\u70b9\u5b9e\u73b0&#xff1a;<\/p>\n<table>\n<tr>\n<p>\u76ee\u6807\u6a21\u5757<\/p>\n<p>\u6280\u672f\u65b9\u6848<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>&#x1f539; MongoDB \u5206\u7247\u8bfb\u5199<\/p>\n<\/td>\n<td>\n<p>\u4f7f\u7528\u00a0MongoTemplate\u00a0\u6216\u00a0Spring Data Mongo<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f539; Redis \u7f13\u5b58\u52a0\u901f<\/p>\n<\/td>\n<td>\n<p>\u4f7f\u7528\u00a0Spring Cache\u00a0\u6216\u00a0Redisson<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>&#x1f539; ElasticSearch \u67e5\u8be2<\/p>\n<\/td>\n<td>\n<p>\u4f7f\u7528\u00a0Spring Data Elasticsearch\u00a0\u6216\u00a0RestHighLevelClient<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u2705 \u4e00\u3001MongoDB \u5206\u7247\u96c6\u7fa4\u8fde\u63a5\u4e0e\u64cd\u4f5c<\/h3>\n<h4>&#x1f4e6; Maven \u4f9d\u8d56&#xff08;MongoDB&#xff09;&#xff1a;<\/h4>\n<p> &lt;dependency&gt;<br \/>\n\u00a0 &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n\u00a0 &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<h4>\u2699\ufe0f application.yml \u914d\u7f6e\u8fde\u63a5&#xff08;\u53ef\u5e26\u526f\u672c\u96c6&#xff09;<\/h4>\n<p> spring:<br \/>\n\u00a0 data:<br \/>\n\u00a0 \u00a0 mongodb:<br \/>\n\u00a0 \u00a0 \u00a0 uri: mongodb:\/\/shard1:27017,shard2:27017,shard3:27017\/demo_app?replicaSet&#061;rs0 <\/p>\n<h4>\u2705 \u4f7f\u7528\u00a0MongoTemplate\u00a0\u64cd\u4f5c&#xff1a;<\/h4>\n<p> &#064;Service<br \/>\npublic class OrderService {<\/p>\n<p>\u00a0 \u00a0 &#064;Autowired<br \/>\n\u00a0 \u00a0 private MongoTemplate mongoTemplate;<\/p>\n<p>\u00a0 \u00a0 public void saveOrder(Order order) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 mongoTemplate.save(order,\u00a0&#034;orders&#034;);<br \/>\n\u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 public List&lt;Order&gt; findOrdersByUser(String userId) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Query query &#061; new Query(Criteria.where(&#034;userId&#034;).is(userId));<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0return\u00a0mongoTemplate.find(query, Order.class,\u00a0&#034;orders&#034;);<br \/>\n\u00a0 \u00a0 }<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u4e8c\u3001Redis \u7f13\u5b58\u70ed\u70b9\u8ba2\u5355\u6570\u636e<\/h3>\n<h4>&#x1f4e6; Maven \u4f9d\u8d56&#xff1a;<\/h4>\n<p> &lt;dependency&gt;<br \/>\n\u00a0 &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n\u00a0 &lt;artifactId&gt;spring-boot-starter-data-redis&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<h4>\u2699\ufe0f application.yml \u914d\u7f6e&#xff1a;<\/h4>\n<p> spring:<br \/>\n\u00a0 redis:<br \/>\n\u00a0 \u00a0 host: localhost<br \/>\n\u00a0 \u00a0 port: 6379 <\/p>\n<h4>\u2705 \u4f7f\u7528 RedisTemplate&#xff1a;<\/h4>\n<p> &#064;Autowired<br \/>\nprivate StringRedisTemplate redisTemplate;<\/p>\n<p>public Order getOrderWithCache(String orderId) {<br \/>\n\u00a0 \u00a0 String cacheKey &#061;\u00a0&#034;order:&#034;\u00a0&#043; orderId;<br \/>\n\u00a0 \u00a0 String cached &#061; redisTemplate.opsForValue().get(cacheKey);<br \/>\n\u00a0 \u00a0\u00a0if\u00a0(cached !&#061; null) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0return\u00a0JSON.parseObject(cached, Order.class);<br \/>\n\u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 \/\/ \u67e5\u8be2 MongoDB<br \/>\n\u00a0 \u00a0 Order order &#061; mongoTemplate.findById(orderId, Order.class);<br \/>\n\u00a0 \u00a0\u00a0if\u00a0(order !&#061; null) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 redisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(order), Duration.ofHours(1));<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0\u00a0return\u00a0order;<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u4e09\u3001Elasticsearch \u67e5\u8be2\u5386\u53f2\u8ba2\u5355<\/h3>\n<h4>&#x1f4e6; Maven \u4f9d\u8d56&#xff08;Spring Boot 3 \u63a8\u8350\u7528\u65b0\u5ba2\u6237\u7aef&#xff09;&#xff1a;<\/h4>\n<p> &lt;dependency&gt;<br \/>\n\u00a0 &lt;groupId&gt;co.elastic.clients&lt;\/groupId&gt;<br \/>\n\u00a0 &lt;artifactId&gt;elasticsearch-java&lt;\/artifactId&gt;<br \/>\n\u00a0 &lt;version&gt;8.11.3&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<h4>\u2705 \u521d\u59cb\u5316 ES \u5ba2\u6237\u7aef&#xff1a;<\/h4>\n<p> &#064;Configuration<br \/>\npublic class EsConfig {<br \/>\n\u00a0 \u00a0 &#064;Bean<br \/>\n\u00a0 \u00a0 public ElasticsearchClient\u00a0elasticsearchClient() {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 RestClient restClient &#061; RestClient.builder(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 new HttpHost(&#034;localhost&#034;, 9200)).build();<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 ElasticsearchTransport transport &#061; new RestClientTransport(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 restClient, new JacksonJsonpMapper());<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0return\u00a0new ElasticsearchClient(transport);<br \/>\n\u00a0 \u00a0 }<br \/>\n} <\/p>\n<h4>\u2705 \u67e5\u8be2\u5386\u53f2\u8ba2\u5355&#xff08;createdAt &lt; \u67d0\u65f6\u95f4&#xff09;&#xff1a;<\/h4>\n<p> public List&lt;Order&gt; searchOldOrders(String userId) throws IOException {<br \/>\n\u00a0 \u00a0 LocalDateTime sixMonthsAgo &#061; LocalDateTime.now().minusMonths(6);<br \/>\n\u00a0 \u00a0 ElasticsearchClient client &#061; elasticsearchClient;<\/p>\n<p>\u00a0 \u00a0 SearchResponse&lt;Order&gt; response &#061; client.search(s -&gt; s<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 .index(&#034;orders&#034;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 .query(q -&gt; q<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .bool(b -&gt; b<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .must(m -&gt; m.term(t -&gt; t.field(&#034;userId&#034;).value(userId)))<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .must(m -&gt; m.range(r -&gt; r.field(&#034;createdAt&#034;).lt(JsonData.of(sixMonthsAgo.toString()))))<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 ), Order.class);<\/p>\n<p>\u00a0 \u00a0\u00a0return\u00a0response.hits().hits().stream().map(Hit::source).toList();<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u56db\u3001\u8c03\u5ea6\u5f52\u6863&#xff1a;Mongo \u2192 ElasticSearch<\/h3>\n<p style=\"text-align: left\">\u4f60\u53ef\u4ee5\u5728\u5b9a\u65f6\u4efb\u52a1\u4e2d&#xff0c;\u5b9a\u671f\u5c06 Mongo \u4e2d\u7684\u8001\u8ba2\u5355\u8fc1\u79fb\u5230 ES&#xff1a;<\/p>\n<p> &#064;Scheduled(cron &#061;\u00a0&#034;0 0 2 * * ?&#034;)<br \/>\npublic void\u00a0archiveOldOrdersToES() {<br \/>\n\u00a0 \u00a0 Query query &#061; new Query(Criteria.where(&#034;createdAt&#034;).lt(LocalDateTime.now().minusMonths(6)));<br \/>\n\u00a0 \u00a0 List&lt;Order&gt; oldOrders &#061; mongoTemplate.find(query, Order.class,\u00a0&#034;orders&#034;);<\/p>\n<p>\u00a0 \u00a0 oldOrders.forEach(order -&gt; {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 try {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 elasticsearchClient.index(i -&gt; i<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .index(&#034;orders&#034;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .id(order.getId())<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .document(order));<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 } catch (Exception e) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 log.error(&#034;\u5f52\u6863\u5931\u8d25&#xff1a;{}&#034;, e.getMessage());<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 });<br \/>\n} <\/p>\n<hr \/>\n<h3>\u2705 \u4e94\u3001\u6574\u4f53\u67b6\u6784\u56de\u987e<\/h3>\n<p> &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u00a0 Java SpringBoot \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0 |<br \/>\n\u00a0 \u00a0 \u00a0Redis (\u7f13\u5b58) \u00a0| \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0 | \u00a0MongoDB (\u5206\u7247\u4e3b\u5e93)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u70ed\u70b9\u8ba2\u5355 \u00a0| \u00a0 \u00a0 | \u00a0 \u00a0 \u00a0 | \u00a0\u5b9e\u65f6\u8bfb\u5199<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u25bc \u00a0 \u00a0 \u25bc \u00a0 \u00a0 \u00a0 \u25bc<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Elasticsearch \u00a0 \u00a0 \u00a0 &#xff08;\u5f52\u6863&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a06\u6708\u524d\u8001\u8ba2\u5355\u641c\u7d22\u3001\u7edf\u8ba1\u5206\u6790 <\/p>\n<hr \/>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u6784\u5efa\u4e00\u4e2a\u7cfb\u7edf\uff1a\u4f7f\u7528 MongoDB \u5206\u7247\u96c6\u7fa4\u4fdd\u5b58\u8ba2\u5355\u6570\u636e\uff0cRedis \u7f13\u5b58\u70ed\u6570\u636e\uff0cElasticsearch \u5b58\u50a8\u5386\u53f2\u6570\u636e\uff0c\u5e76\u901a\u8fc7 Java \u670d\u52a1\u8bfb\u5199\u534f\u8c03\u3002\u957f\u65f6\u95f4\u63a5\u8fd1 100%\uff0c\u6392\u67e5\u662f\u9891\u7e41\u5199\u5165\u65e5\u5fd7\u5bfc\u81f4 IO \u62e5\u585e\uff0c\u4f18\u5316\u540e\u65e5\u5fd7\u6309\u7ea7\u522b\u5199\u5165\uff0c\u54cd\u5e94\u6062\u590d\u3002\u5bfc\u5165\u5230 ES\uff0c\u652f\u6301\u5feb\u901f\u641c\u7d22\u3001\u5206\u9875\u3001\u590d\u6742\u7edf\u8ba1\u5206\u6790\uff0c\u800c\u4e0d\u5f71\u54cd Mongo \u7684\u8bfb\u5199\u538b\u529b\u3002\uff08\u5982\u7528\u6237\u6700\u65b0\u8ba2\u5355\u3001\u8ba2\u5355\u72b6\u6001\uff09\u7f13\u5b58\u5230 Redis\uff0c\u907f\u514d MongoDB \u9891\u7e41\u67e5\u8be2\u3002\u7684\u6838\u5fc3\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u8ba2\u5355\u7c7b\u7cfb\u7edf\u3001\u65e5\u5fd7\u7cfb\u7edf\u3001\u4ea4\u6613\u7cfb\u7edf\u7b49\u573a\u666f\u3002dump \u6808\u5206\u6790\u662f\u67d0\u4e2a\u7ebf\u7a0b\u6b7b\u5faa\u73af\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[664,1348,43,442,44],"topic":[],"class_list":["post-39627","post","type-post","status-publish","format-standard","hentry","category-server","tag-664","tag-1348","tag-43","tag-442","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \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\/39627.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u6784\u5efa\u4e00\u4e2a\u7cfb\u7edf\uff1a\u4f7f\u7528 MongoDB \u5206\u7247\u96c6\u7fa4\u4fdd\u5b58\u8ba2\u5355\u6570\u636e\uff0cRedis \u7f13\u5b58\u70ed\u6570\u636e\uff0cElasticsearch \u5b58\u50a8\u5386\u53f2\u6570\u636e\uff0c\u5e76\u901a\u8fc7 Java \u670d\u52a1\u8bfb\u5199\u534f\u8c03\u3002\u957f\u65f6\u95f4\u63a5\u8fd1 100%\uff0c\u6392\u67e5\u662f\u9891\u7e41\u5199\u5165\u65e5\u5fd7\u5bfc\u81f4 IO \u62e5\u585e\uff0c\u4f18\u5316\u540e\u65e5\u5fd7\u6309\u7ea7\u522b\u5199\u5165\uff0c\u54cd\u5e94\u6062\u590d\u3002\u5bfc\u5165\u5230 ES\uff0c\u652f\u6301\u5feb\u901f\u641c\u7d22\u3001\u5206\u9875\u3001\u590d\u6742\u7edf\u8ba1\u5206\u6790\uff0c\u800c\u4e0d\u5f71\u54cd Mongo \u7684\u8bfb\u5199\u538b\u529b\u3002\uff08\u5982\u7528\u6237\u6700\u65b0\u8ba2\u5355\u3001\u8ba2\u5355\u72b6\u6001\uff09\u7f13\u5b58\u5230 Redis\uff0c\u907f\u514d MongoDB \u9891\u7e41\u67e5\u8be2\u3002\u7684\u6838\u5fc3\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u8ba2\u5355\u7c7b\u7cfb\u7edf\u3001\u65e5\u5fd7\u7cfb\u7edf\u3001\u4ea4\u6613\u7cfb\u7edf\u7b49\u573a\u666f\u3002dump \u6808\u5206\u6790\u662f\u67d0\u4e2a\u7ebf\u7a0b\u6b7b\u5faa\u73af\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/39627.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-24T07:56:40+00:00\" \/>\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=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39627.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/39627.html\",\"name\":\"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-24T07:56:40+00:00\",\"dateModified\":\"2025-05-24T07:56:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/39627.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/39627.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39627.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf\"}]},{\"@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":"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \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\/39627.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u6784\u5efa\u4e00\u4e2a\u7cfb\u7edf\uff1a\u4f7f\u7528 MongoDB \u5206\u7247\u96c6\u7fa4\u4fdd\u5b58\u8ba2\u5355\u6570\u636e\uff0cRedis \u7f13\u5b58\u70ed\u6570\u636e\uff0cElasticsearch \u5b58\u50a8\u5386\u53f2\u6570\u636e\uff0c\u5e76\u901a\u8fc7 Java \u670d\u52a1\u8bfb\u5199\u534f\u8c03\u3002\u957f\u65f6\u95f4\u63a5\u8fd1 100%\uff0c\u6392\u67e5\u662f\u9891\u7e41\u5199\u5165\u65e5\u5fd7\u5bfc\u81f4 IO \u62e5\u585e\uff0c\u4f18\u5316\u540e\u65e5\u5fd7\u6309\u7ea7\u522b\u5199\u5165\uff0c\u54cd\u5e94\u6062\u590d\u3002\u5bfc\u5165\u5230 ES\uff0c\u652f\u6301\u5feb\u901f\u641c\u7d22\u3001\u5206\u9875\u3001\u590d\u6742\u7edf\u8ba1\u5206\u6790\uff0c\u800c\u4e0d\u5f71\u54cd Mongo \u7684\u8bfb\u5199\u538b\u529b\u3002\uff08\u5982\u7528\u6237\u6700\u65b0\u8ba2\u5355\u3001\u8ba2\u5355\u72b6\u6001\uff09\u7f13\u5b58\u5230 Redis\uff0c\u907f\u514d MongoDB \u9891\u7e41\u67e5\u8be2\u3002\u7684\u6838\u5fc3\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u8ba2\u5355\u7c7b\u7cfb\u7edf\u3001\u65e5\u5fd7\u7cfb\u7edf\u3001\u4ea4\u6613\u7cfb\u7edf\u7b49\u573a\u666f\u3002dump \u6808\u5206\u6790\u662f\u67d0\u4e2a\u7ebf\u7a0b\u6b7b\u5faa\u73af\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/39627.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-24T07:56:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/39627.html","url":"https:\/\/www.wsisp.com\/helps\/39627.html","name":"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-24T07:56:40+00:00","dateModified":"2025-05-24T07:56:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/39627.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/39627.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/39627.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5206\u5e03\u5f0f\u5fae\u670d\u52a1\u7cfb\u7edf\u67b6\u6784\u7b2c133\u96c6\uff1a\u8fd0\u7ef4\u670d\u52a1\u56686\u5e74\u7ecf\u9a8c\uff0c\u9ad8\u5e76\u53d1\uff0c\u5927\u6570\u636e\u91cf\u7cfb\u7edf"}]},{"@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\/39627","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=39627"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39627\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=39627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=39627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=39627"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=39627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}