{"id":1513,"date":"2017-05-07T22:05:07","date_gmt":"2017-05-07T14:05:07","guid":{"rendered":"http:\/\/coderbee.net\/?p=1513"},"modified":"2017-06-17T13:59:16","modified_gmt":"2017-06-17T05:59:16","slug":"%e5%85%b3%e4%ba%8e-linux-swap-%e7%9a%84%e4%b8%80%e5%88%87","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/linux\/20170507\/1513","title":{"rendered":"\u5173\u4e8e Linux swap \u7684\u4e00\u5207"},"content":{"rendered":"<h2>\u4e00\u4e2a\u95ee\u9898<\/h2>\n<p>51\u653e\u5047\u524d\u7684\u65f6\u5019\uff0c\u4e00\u4e2a\u4ee5\u524d\u7684\u540c\u4e8b\u8bf4\u4ed6\u4eec\u7684\u7cfb\u7edf\u51fa\u73b0 \u7269\u7406\u7a7a\u95f2\u5185\u5b58\u4e3a 0\uff0c swap \u5206\u533a\u4f7f\u7528\u589e\u957f\uff0c\u589e\u957f\u5230 3G \u5de6\u53f3\u5c31\u4f1a\u5f15\u8d77\u5e94\u7528\u5f02\u5e38\u9000\u51fa\u3002\u4f46\u662f JVM \u76d1\u63a7\u770b\u5230\u5806\u8fd8\u662f\u6709\u5927\u91cf\u7a7a\u95f2\u7a7a\u95f4\u7684\u3002\u6628\u5929\u53c8\u770b\u5230\u4ed6\u5728\u670b\u53cb\u5708\u6c42\u52a9\u8fd9\u4e2a\u95ee\u9898\uff0c\u51b3\u5b9a\u7814\u7a76\u4e0b\u3002<\/p>\n<p>\u6309\u4ee5\u524d\u7684\u7406\u89e3\uff0c\u7269\u7406\u5185\u5b58\u4e0d\u591f\u65f6\uff0c\u5c31\u4f1a\u628a\u4e00\u4e9b\u4e0d\u5e38\u7528\u7684\u5185\u5b58\u9875\u4ea4\u6362\u5230 swap \u7a7a\u95f4\uff0c\u4ee5\u91ca\u653e\u5185\u5b58\u3002\u4ed6\u78b0\u5230\u7269\u7406\u5185\u5b58\u8017\u5c3d\u3001swap \u7a7a\u95f4\u589e\u957f\uff0c\u8fd9\u662f\u5f88\u6b63\u5e38\u7684\u3002\u53ea\u662f\u8fd9\u4e9b\u589e\u957f\u7684\u5185\u5b58\u5e72\u561b\u7528\u4e86\u3002<\/p>\n<p><code>free -m<\/code> \u547d\u4ee4\u80fd\u53ea\u770b\u5230\u7269\u7406\u5185\u5b58\u3001\u4ea4\u6362\u7a7a\u95f4\u5404\u4f7f\u7528\u4e86\u591a\u5c11\uff0c\u4f46\u770b\u4e0d\u5230\u662f\u6bcf\u4e2a\u8fdb\u7a0b\u5177\u4f53\u7528\u4e86\u591a\u5c11\u3002<\/p>\n<p>\u8fd8\u662f\u5f97\u9760 <code>top<\/code> \u547d\u4ee4\uff0c\u8fdb\u5165 <code>top<\/code> \u547d\u4ee4\u7684\u663e\u793a\u754c\u9762\u540e\uff0c\u6309\u4e0b <code>Shift+m<\/code> \u5c31\u53ef\u4ee5\u6309\u5185\u5b58\u4f7f\u7528\u6392\u5e8f\uff0c\u5982\u4e0b\u56fe\uff1a<br \/>\n<img decoding=\"async\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2017\/05\/top-demo.png\" alt=\"top demo\" \/><\/p>\n<p>\u5047\u5982\u6392\u5728\u7b2c\u4e00\u7684\u662f\u4e2a Java \u8fdb\u7a0b\uff0c\u5360\u7528\u4e86 6G \u5185\u5b58\uff0c\u800cJVM\u914d\u7f6e\u7684\u6700\u5927\u5806\u5185\u5b58\u662f 4G\uff0c\u8bf4\u660e\u975e\u5806\u5185\u5b58\uff08\u672c\u5730\u5185\u5b58\u3001\u7ebf\u7a0b\u6808\u7b49\uff09\u5360\u7528\u4e86 2G\u3002<\/p>\n<p>\u540e\u9762\u8ddf\u90a3\u4e2a\u540c\u4e8b\u6c42\u8bc1\uff0c\u662f\u4ed6\u4eec\u6700\u8fd1\u4e0a\u7ebf\u7684\u4e00\u4e2a\u7ec4\u4ef6\u7528\u4e86 Netty\uff0c\u4f7f\u7528\u4e0d\u5f53\u5bfc\u81f4\u672c\u5730\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<h2>\u5173\u4e8e swap \u7684\u4e00\u5207<\/h2>\n<p>\u539f\u6587\uff1a <a href=\"https:\/\/www.linux.com\/news\/all-about-linux-swap-space\">https:\/\/www.linux.com\/news\/all-about-linux-swap-space<\/a><\/p>\n<p>Linux \u628a\u7269\u7406\u5185\u5b58\uff08RAM\uff09\u5206\u4e3a\u4e00\u5757\u4e00\u5757\uff0c\u79f0\u4e3a \u9875\uff08page\uff09\u3002<br \/>\n\u4ea4\u6362\u662f\u628a\u5185\u5b58\u9875\u62f7\u8d1d\u5230\u63d0\u524d\u914d\u7f6e\u5728\u786c\u76d8\u4e0a\u7684\u7a7a\u95f4\uff08\u79f0\u4e3a\u4ea4\u6362\u7a7a\u95f4\uff09\u7684\u8fc7\u7a0b\uff0c\u4ee5\u91ca\u653e\u9875\u7684\u5185\u5b58\u3002<br \/>\n\u7269\u7406\u5185\u5b58\u548c\u4ea4\u4e92\u7a7a\u95f4\u7684\u7ec4\u5408\u5c31\u662f\u53ef\u7528\u7684\u865a\u62df\u5185\u5b58\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4ea4\u4e92\u6709\u4e24\u4e2a\u91cd\u5927\u610f\u4e49\uff1a<br \/>\n* \u9996\u5148\uff0c\u7cfb\u7edf\u9700\u8981\u7684\u5185\u5b58\u6bd4\u7269\u7406\u5185\u5b58\u66f4\u5927\u65f6\uff0c\u5185\u6838\u4ea4\u6362\u51fa\u8f83\u5c11\u4f7f\u7528\u7684\u9875\uff0c\u7ed9\u5f53\u524d\u5e94\u7528\uff08\u8fdb\u7a0b\uff09\u7acb\u5373\u9700\u8981\u7684\u5185\u5b58\u3002<br \/>\n* \u5176\u6b21\uff0c\u5e94\u7528\u542f\u52a8\u9636\u6bb5\u9700\u8981\u5927\u91cf\u9875\u53ef\u80fd\u53ea\u7528\u4e8e\u521d\u59cb\u5316\uff0c\u7136\u540e\u5c31\u518d\u4e5f\u6ca1\u6709\u4f7f\u7528\u3002\u7cfb\u7edf\u53ef\u4ee5\u4ea4\u6362\u8fd9\u4e9b\u9875\u5e76\u91ca\u653e\u5185\u5b58\u7528\u4e8e\u7ed9\u5176\u4ed6\u8fdb\u7a0b\u6216\u78c1\u76d8\u7f13\u5b58\u3002<\/p>\n<p>\u4ea4\u6362\u7684\u8d1f\u9762\u4f5c\u7528\uff1a<br \/>\n*  \u786c\u76d8\u6bd4\u5185\u5b58\u6162\u4e86\u6570\u4e2a\u6570\u91cf\u7ea7\uff0c\u5185\u5b58\u662f\u4ee5\u5fae\u79d2\u8861\u91cf\u7684\uff0c\u786c\u76d8\u662f\u4ee5\u6beb\u79d2\u8861\u91cf\uff1b<br \/>\n*  \u9891\u7e41\u7684\u4ea4\u6362\u5165\u3001\u4ea4\u6362\u51fa\u5c06\u5bfc\u81f4\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<p>Linux \u6709\u4e24\u79cd\u5f62\u5f0f\u7684\u4ea4\u6362\u7a7a\u95f4\uff1a<br \/>\n*  \u4ea4\u6362\u5206\u533a\uff1a\u786c\u76d8\u4e0a\u72ec\u7acb\u7684\u533a\u57df\uff0c\u5176\u4ed6\u6587\u4ef6\u4e0d\u80fd\u5b58\u653e\u3002<br \/>\n*  \u4ea4\u6362\u6587\u4ef6\uff1a\u6587\u4ef6\u7cfb\u7edf\u91cc\u7684\u4e00\u4e2a\u7279\u5b9a\u6587\u4ef6\u3002<\/p>\n<p>\u67e5\u770b swap \u7a7a\u95f4\u4fe1\u606f\uff1a <code>swapon -s<\/code><\/p>\n<pre><code>Filename                Type        Size    Used    Priority\n\/dev\/sda5                                  partition    1046524    54244    -1\n<\/code><\/pre>\n<p>\u5982\u679c\u6709\u4e24\u4e2a\u4ea4\u6362\u7a7a\u95f4\u4e14\u4f18\u5148\u7ea7\u76f8\u540c\uff0cLinux swapping \u7cfb\u7edf\u5c06\u4ea4\u6362\u4f7f\u7528\u8fd9\u4e24\u4e2a\u7a7a\u95f4\uff0c\u8fd9\u6837\u53ef\u4ee5\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<h2>\u4ea4\u6362\u7a7a\u95f4\u5e94\u8be5\u591a\u5927\uff1f<\/h2>\n<p>\u5982\u679c\u6709\u8db3\u591f\u7684\u5185\u5b58\uff0c\u53ef\u4ee5\u628a\u4ea4\u6362\u7a7a\u95f4\u7981\u7528\u4e86\u3002<\/p>\n<p>\u5bf9\u4e8e\u684c\u9762\u7cfb\u7edf\uff0c\u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f\u53ef\u4ee5\u662f\u5185\u5b58\u7684\u4e24\u500d\uff1b<br \/>\n\u5bf9\u4e8e\u670d\u52a1\u5668\uff0c\u4f7f\u7528\u5c0f\u7684\u4ea4\u6362\u7a7a\u95f4\uff08\u6bd4\u5982\u662f\u7269\u7406\u5185\u5b58\u7684\u4e00\u822c\uff09\uff0c\u8981\u76d1\u63a7\u4ea4\u6362\u7a7a\u95f4\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u5982\u679c\u9700\u8981\uff0c\u5347\u7ea7\u5185\u5b58\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2a\u95ee\u9898 51\u653e\u5047\u524d\u7684\u65f6\u5019\uff0c\u4e00\u4e2a\u4ee5\u524d\u7684\u540c\u4e8b\u8bf4\u4ed6\u4eec\u7684\u7cfb\u7edf\u51fa\u73b0 \u7269\u7406\u7a7a\u95f2\u5185\u5b58\u4e3a 0\uff0c &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/linux\/20170507\/1513\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[272,271],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1513"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1513"}],"version-history":[{"count":4,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1513\/revisions"}],"predecessor-version":[{"id":1530,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1513\/revisions\/1530"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}