{"id":1152,"date":"2020-05-21T00:09:38","date_gmt":"2020-05-20T16:09:38","guid":{"rendered":"https:\/\/www.siediyer.cn\/?p=1152"},"modified":"2020-05-21T00:09:38","modified_gmt":"2020-05-20T16:09:38","slug":"linux%e6%95%99%e7%a8%8b%ef%bc%9a%e6%90%ac%e7%93%a6%e5%b7%a5vps%e6%9f%a5%e7%9c%8b%e3%80%81%e4%bf%ae%e6%94%b9%e3%80%81%e6%96%b0%e5%a2%9eswap%e5%88%86%e5%8c%ba%e7%9a%84%e5%a4%a7%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=1152","title":{"rendered":"Linux\u6559\u7a0b\uff1a\u642c\u74e6\u5de5VPS\u67e5\u770b\u3001\u4fee\u6539\u3001\u65b0\u589eSWAP\u5206\u533a\u7684\u5927\u5c0f"},"content":{"rendered":"<p>\u642c\u74e6\u5de5 Linux VPS \u4e0a\u5982\u4f55\u67e5\u770bSWAP\u5206\u533a\u7684\u5927\u5c0f\uff0c\u4fee\u6539SWAP\u5206\u533a\u7684\u5927\u5c0f\uff0c\u65b0\u589eSWAP\u5206\u533a\u3002\u8fd9\u6837\u5199\u6bd4\u8f83\u987a\uff0c\u6807\u9898\u5c31\u52c9\u5f3a\u770b\u4e00\u4e0b\u3002<\/p>\n<p>\u4eca\u5929\u62ff\u51fa\u642c\u74e6\u5de5\u7684\u9999\u6e2fVPS\uff0c9.9\u5143\u6708\u4ed8\u4f20\u5bb6\u5b9d\uff0c\u6253\u7b97\u628a\u7f51\u7ad9\u642c\u8fc7\u53bb\u3002\u88c5\u4e0aLAMP\u540e\uff0c\u51b3\u5b9a\u589e\u52a0SWAP\u5206\u533a\u7684\u5927\u5c0f\uff0c\u4e0b\u9762\u8bb0\u5f55\u4e00\u4e0b\u8fc7\u7a0b\u3002<\/p>\n<h2><strong>\u67e5\u770bSWAP\u5206\u533a\u5927\u5c0f<\/strong><\/h2>\n<p>\u8fd9\u4e2a\u6bd4\u8f83\u7b80\u5355\uff0c\u4f7f\u7528\u547d\u4ee4\uff1a<\/p>\n<pre>free -h<\/pre>\n<p>\u6216\u8005<\/p>\n<pre>free -m<\/pre>\n<p>\u5c31\u80fd\u770b\u5230SWAP\u5206\u533a\u76ee\u524d\u7684\u5927\u5c0f\u4e86\u3002<\/p>\n<h2><strong>\u4fee\u6539\u3001\u65b0\u589eSWAP\u5206\u533a\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>\u4fee\u6539\u5927\u5c0f\uff0c\u6211\u4eec\u91c7\u53d6\u7684\u65b9\u6cd5\u662f\u5148\u5220\u9664SWAP\u5206\u533a\uff0c\u7136\u540e\u65b0\u5efa\u66f4\u5927\u7684\u3002<\/p>\n<p><strong>1. \u5220\u9664\u6240\u6709SWAP\u5206\u533a<\/strong><\/p>\n<pre>swapoff -a<\/pre>\n<p><strong>2. \u65b0\u589eSWAP\u5206\u533a<\/strong><\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u6dfb\u52a0\u4e00\u4e2aswap\u6587\u4ef6\u4f5c\u4e3aswap<\/strong><\/p>\n<p>\u8fd9\u4e2a\u662f\u642c\u74e6\u5de5\u76ee\u524d\u7684\u9ed8\u8ba4\u505a\u6cd5\uff0c\u6240\u4ee5\u6211\u4eec\u4e5f\u5efa\u8bae\u91c7\u7528\u8fd9\u4e2a\u505a\u6cd5\u3002<\/p>\n<p>2.1 \u521b\u5efaswap\u5206\u533a\u7684\u6587\u4ef6\uff1a<\/p>\n<pre>dd if=\/dev\/zero of=\/root\/swapfile bs=1M count=1024<\/pre>\n<p>\u5176\u4e2d bs\u662f\u6bcf\u5757\u7684\u5927\u5c0f\uff0ccount\u662f\u5757\u7684\u6570\u91cf\uff0cbs*count\uff0c\u5c31\u662fswap\u6587\u4ef6\u7684\u5927\u5c0f\u4e86\uff0c\u8fd9\u91cc\u5c31\u662f1M*1024=1G\u3002\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u8c03\u6574count\u7684\u6570\u91cf\u3002<\/p>\n<p>\u6b64\u5916\uff0c<code>\/root\/swapfile<\/code>\u662fswap\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u4fee\u6539\u3002<\/p>\n<p>2.2 \u683c\u5f0f\u5316\u4ea4\u6362\u5206\u533a\u6587\u4ef6\uff1a<\/p>\n<pre>mkswap \/root\/swapfile<\/pre>\n<p>\u8fd9\u91cc\u7684\u8def\u5f84\u548c\u4e4b\u524d\u7684\u8def\u5f84\u8981\u5bf9\u5e94\u8d77\u6765\u3002<\/p>\n<p>2.3 \u542f\u7528swap\u5206\u533a\u6587\u4ef6\uff1a<\/p>\n<pre>swapon \/root\/swapfile<\/pre>\n<p>2.4 \u6dfb\u52a0\u5f00\u673a\u542f\u52a8\uff1a<\/p>\n<p>\u4fee\u6539\u00a0<code>\/etc\/fstab<\/code>\u00a0\u8fd9\u4e2a\u6587\u4ef6\uff0c\u6dfb\u52a0\u6216\u8005\u4fee\u6539\u8fd9\u4e00\u884c\uff1a<\/p>\n<pre>\/root\/swapfile swap swap defaults 0 0<\/pre>\n<p>\u6ce8\u610f\uff0c\u8def\u5f84\u8fd8\u662f\u8981\u5bf9\u5e94\u3002\u6700\u540e\u4e24\u4e2a\u662f\u96f6\uff0c\u4e0d\u662f\u6b27\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u73b0\u5728\u53ef\u4ee5\u518d\u770b\u4e00\u4e0bswap\u7684\u5927\u5c0f\u4e86\uff08\u6211\u6dfb\u52a0\u4e862G\u7684swap\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1153\" src=\"https:\/\/qiniu.shijitianchen.com\/2020\/05\/QQ\u622a\u56fe20171214191002.png\" width=\"682\" height=\"102\" alt=\"\" srcset=\"https:\/\/qiniu.shijitianchen.com\/2020\/05\/QQ\u622a\u56fe20171214191002.png 682w, https:\/\/qiniu.shijitianchen.com\/2020\/05\/QQ\u622a\u56fe20171214191002-300x45.png 300w\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" \/><\/p>\n<p>\u4e0b\u9762\u518d\u4ecb\u7ecd\u4e00\u4e0b\u65b9\u6cd5\u4e8c\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u65b0\u5efa\u5206\u533a\u4f5c\u4e3aswap\u5206\u533a<\/strong><\/p>\n<p>\u8fd9\u4e2a\u662fLinode\u7684\u9ed8\u8ba4\u505a\u6cd5\uff0c\u8fd9\u91cc\u4e5f\u4ecb\u7ecd\u4e00\u4e0b\u3002<\/p>\n<p>\u4f7f\u7528fdisk\u521b\u5efa\u4ea4\u6362\u5206\u533a\uff08\u5047\u8bbe\u662f\u00a0<code>\/dev\/sdb2<\/code>\uff09\uff1b<\/p>\n<p>\u4f7f\u7528 mkswap \u8bbe\u7f6e\u4ea4\u6362\u5206\u533a\uff1a<\/p>\n<pre>mkswap \/dev\/sdb2<\/pre>\n<p>\u542f\u7528\u4ea4\u6362\u5206\u533a\uff1a<\/p>\n<pre>swapon \/dev\/sdb2<\/pre>\n<p>\u5199\u5165\u00a0<code>\/etc\/fstab<\/code>\uff1a<\/p>\n<pre>\/dev\/sdb2 swap swap defaults 0 0<\/pre>\n<p>\u597d\u4e86\uff0c\u5230\u6b64\u90fd\u80fd\u5b8c\u6210\u8fd9\u4e2a\u64cd\u4f5c\u3002<\/p>\n<h2>\u5176\u4ed6<\/h2>\n<p>\u8d76\u7d27\u4e70\u4e00\u4e2a\u73a9\u73a9\u5427\u3002<\/p>\n<p><strong>\u4e70\u7684\u4eba\u6700\u591a\u7684\uff1a<\/strong><\/p>\n<p><strong>CN2 \u7279\u4ef7\u4fc3\u9500\u7248 \u2013 10G\uff08\u76ee\u524d\u6700\u4fbf\u5b9c\uff09<\/strong><\/p>\n<ul>\n<li>\u786c\u76d8\uff1a10 GB RAID-10<\/li>\n<li>\u5185\u5b58\uff1a512 MB<\/li>\n<li>CPU\uff1a1x Intel Xeon<\/li>\n<li>\u6d41\u91cf\uff1a500 GB\/\u6708<\/li>\n<li>\u5e26\u5bbd\uff1a1 Gigabit<\/li>\n<li>\u673a\u623f\uff1a\u8d2d\u4e70\u65f6\u53ea\u6709CN2\uff0c\u8d2d\u4e70\u540e\u53ef\u8fc1\u5230\u522b\u7684\u673a\u623f<\/li>\n<li>\u5907\u6ce8\uff1aDirect route via CN2 and China Unicom\uff08\u7535\u4fe1CN2\u548c\u8054\u901a\u76f4\u8fde\uff09<\/li>\n<li>\u4ef7\u683c\uff1a29.99\u7f8e\u5143\/\u5e74\uff08<strong>\u7528\u4f18\u60e0\u7801 BWH3HYATVBJW \u540e28.19\u7f8e\u5143\/\u5e74<\/strong><input type=\"button\" value=\"\u70b9\u51fb\u590d\u5236\u4f18\u60e0\u7801\" \/>\uff09<\/li>\n<li><a href=\"https:\/\/bwh88.net\/aff.php?aff=23114&amp;pid=56\" target=\"_blank\" rel=\"noopener noreferrer\">\u8d2d\u4e70\u94fe\u63a5<\/a><\/li>\n<\/ul>\n<p><strong>CN2 \u7279\u4ef7\u4fc3\u9500\u7248 \u2013 20G \uff08\u76ee\u524d\u6027\u4ef7\u6bd4\u6700\u9ad8\uff09<\/strong><\/p>\n<ul>\n<li>\u786c\u76d8\uff1a20 GB RAID-10<\/li>\n<li>\u5185\u5b58\uff1a1024 MB<\/li>\n<li>CPU\uff1a1x Intel Xeon<\/li>\n<li>\u6d41\u91cf\uff1a1000 GB\/\u6708<\/li>\n<li>\u5e26\u5bbd\uff1a1 Gigabit<\/li>\n<li>\u673a\u623f\uff1a\u8d2d\u4e70\u65f6\u53ea\u6709CN2\uff0c\u8d2d\u4e70\u540e\u53ef\u4ee5\u8fc1\u5230\u522b\u7684\u673a\u623f<\/li>\n<li>\u5907\u6ce8\uff1aDirect route via CN2 and China Unicom\uff08\u7535\u4fe1CN2\u548c\u8054\u901a\u76f4\u8fde\uff09<\/li>\n<li>\u4ef7\u683c\uff1a5.99\u7f8e\u5143\/\u6708 \u6216 49.99\u7f8e\u5143\/\u5e74\uff08<strong>\u4f7f\u7528\u4f18\u60e0\u7801 BWH3HYATVBJW \u540e46.99\u7f8e\u5143\/\u5e74<\/strong><input type=\"button\" value=\"\u70b9\u51fb\u590d\u5236\u4f18\u60e0\u7801\" \/>\uff09<\/li>\n<li><a href=\"https:\/\/bwh88.net\/aff.php?aff=23114&amp;pid=57\" target=\"_blank\" rel=\"noopener noreferrer\">\u8d2d\u4e70\u94fe\u63a5<\/a><\/li>\n<\/ul>\n<p><strong>\u9999\u6e2f\u7279\u4ef7\u4fc3\u9500\u7248 \u2013 40G<\/strong><\/p>\n<ul>\n<li>\u786c\u76d8\uff1a40 GB RAID-10 SSD<\/li>\n<li>\u5185\u5b58\uff1a2048 MB<\/li>\n<li>CPU\uff1a1x Intel Xeon<\/li>\n<li>\u6d41\u91cf\uff1a200 GB\/\u6708<\/li>\n<li>\u5e26\u5bbd\uff1a1 Gigabit<\/li>\n<li>\u673a\u623f\uff1aHong Kong MCX10\uff08\u9999\u6e2f\uff09<\/li>\n<li>\u5907\u6ce8\uff1aDirect route via China Telecom and China Unicom\uff08\u4e2d\u56fd\u7535\u4fe1\u548c\u4e2d\u56fd\u8054\u901a\u76f4\u8fde\uff09<\/li>\n<li>\u6d4b\u8bd5IP\uff1a23.252.97.148<\/li>\n<li>\u4ef7\u683c\uff1a<strong>19.99\u7f8e\u5143\/\u6708<\/strong>\u00a0or 199.99\u7f8e\u5143\/\u5e74\uff08<strong>\u4f7f\u7528\u4f18\u60e0\u7801 BWH3HYATVBJW \u540e 18.79\u7f8e\u5143\/\u6708 or 187.99\u7f8e\u5143\/\u5e74<\/strong><input type=\"button\" value=\"\u70b9\u51fb\u590d\u5236\u4f18\u60e0\u7801\" \/>\uff09<\/li>\n<li><a href=\"https:\/\/bwh88.net\/aff.php?aff=23114&amp;pid=62\" target=\"_blank\" rel=\"noopener noreferrer\">\u8d2d\u4e70\u94fe\u63a5<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u642c\u74e6\u5de5 Linux VPS \u4e0a\u5982\u4f55\u67e5\u770bSWAP\u5206\u533a\u7684\u5927\u5c0f\uff0c\u4fee\u6539SWAP\u5206\u533a\u7684\u5927\u5c0f\uff0c\u65b0\u589eSWAP\u5206\u533a\u3002\u8fd9\u6837\u5199\u6bd4\u8f83 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1153,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1152","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1152"}],"version-history":[{"count":1,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1152\/revisions"}],"predecessor-version":[{"id":1154,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1152\/revisions\/1154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/media\/1153"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}