{"id":165,"date":"2020-09-06T21:05:41","date_gmt":"2020-09-06T13:05:41","guid":{"rendered":"http:\/\/www.peijy.top\/?p=165"},"modified":"2022-05-16T11:35:21","modified_gmt":"2022-05-16T03:35:21","slug":"vps%e4%bc%98%e5%8c%96%e4%b9%8blinux%e6%b7%bb%e5%8a%a0swap%e4%ba%a4%e6%8d%a2%e5%88%86%e5%8c%ba%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98","status":"publish","type":"post","link":"https:\/\/www.eutaboo.com\/index.php\/2020\/09\/06\/vps%e4%bc%98%e5%8c%96%e4%b9%8blinux%e6%b7%bb%e5%8a%a0swap%e4%ba%a4%e6%8d%a2%e5%88%86%e5%8c%ba%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98\/","title":{"rendered":"VPS\u4f18\u5316\u4e4bLinux\u6dfb\u52a0swap\u4ea4\u6362\u5206\u533a(\u865a\u62df\u5185\u5b58)"},"content":{"rendered":"<h2>\u7b80\u4ecb<\/h2>\r\n\r\n<p>\u76f8\u4fe1\u5f88\u591a\u4f7f\u7528<a href=\"https:\/\/www.vpser.net\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >VPS<\/a>\u7684\u670b\u53cb\u548c\u6211\u4e00\u6837\uff0c\u6ca1\u6709\u592a\u591a\u7684\u7c73\u4e70\u66f4\u591a\u7684\u5185\u5b58\u6765\u8fdb\u884c\u5347\u7ea7\uff0c\u901a\u5e38\u4f7f\u7528swap\u4ea4\u6362\u5206\u533a\u6765\u7f13\u89e3\u7cfb\u7edf\u8d44\u6e90\u7d27\u5f20\u7684\u538b\u529b\uff0c\u95f4\u63a5\u7ed9VPS\u63d0\u9ad8\u4e00\u4e0b\u6027\u80fd\u3002<\/p>\r\n\r\n\r\n\r\n<p>\u4e0b\u9762\u8bf4\u4e00\u4e0bVPS\u6dfb\u52a0swap\u4ea4\u6362\u5206\u533a\u7684\u65b9\u6cd5(<strong>\u53ea\u6709\u865a\u62df\u5316\u4e3aXen\u3001KVM\u3001VMWare\u7684VPS\u53ef\u4ee5\uff0cOpenVZ\u4e0d\u652f\u6301\u6dfb\u52a0swap<\/strong>)\u3002<\/p>\r\n\r\n\r\n\r\n<p>1\u3001\u786e\u8ba4\u662f\u5426\u6709SWAP\uff0c\u53ef\u4ee5\u6267\u884cfree -m \u547d\u4ee4\u67e5\u770b\uff0c\u5982\u679c\u6709swap\u4e00\u884c\u4e14total\u9879\u4e0b\u4e0d\u4e3a\u96f6\u7684\u8bdd\u5c31\u662f\u5b58\u5728swap\uff0c\u5c31\u4e0d\u9002\u5408\u518d\u8fdb\u884c\u6dfb\u52a0swap\u3002<\/p>\r\n\r\n\r\n\r\n<p>2\u3001\u4ee5\u4e0b\u4ee5\u6dfb\u52a02GB SWAP\u4e3a\u4f8b\uff0c\u751f\u6210\u6587\u4ef6\u5757\uff1a\uff08SWAP\u4e00\u822c\u8bbe\u7f6e\u4e3a\u5185\u5b58\u76842\u500d\uff0c\u5e76\u975e\u5b8c\u5168\u4ee5\u6b64\u4e3a\u6807\u51c6\uff0c\u53ea\u9002\u54084GB\u4ee5\u4e0b\u5185\u5b58\uff0ccount\u540e\u9762\u7684\u6570\u4e3a\u8981\u8bbe\u7f6e\u7684swap\u5927\u5c0fxxMB\uff09dd if=\/dev\/zero of=\/var\/swapfile bs=1M count=2048<\/p>\r\n\r\n\r\n\r\n<p>3\u3001\u521b\u5efaswap\u6587\u4ef6\/sbin\/mkswap \/var\/swapfile<\/p>\r\n\r\n\r\n\r\n<p>4\u3001\u6fc0\u6d3bswap\u6587\u4ef6\/sbin\/swapon \/var\/swapfile<\/p>\r\n\r\n\r\n\r\n<p>5\u3001\u67e5\u770b\u4e00\u4e0bswap\u662f\u5426\u6b63\u786e\uff1a\/sbin\/swapon -s<\/p>\r\n\r\n\r\n\r\n<p>\u53e6\u5916\u4e3a\u4e86\u5b89\u5168\u5efa\u8bae\u6267\u884c\uff1achmod 0600 \/var\/swapfile<\/p>\r\n\r\n\r\n\r\n<p>\u6539\u4e00\u4e0b\u6743\u9650<br \/>6\u3001\u5230fstab\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5f00\u673a\u81ea\u52a8\u6302\u8f7d\u8bbe\u7f6evi \/etc\/fstab<\/p>\r\n\r\n\r\n\r\n<p>\u5728\u672b\u5c3e\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\/var\/swapfile swap swap defaults 0 0\u4e5f\u53ef\u4ee5\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u611f\u89c9\u8fd9\u6837\u66f4\u65b9\u4fbfecho \"\/var\/swapfile swap swap defaults 0 0\" >>\/etc\/fstab<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">SWAP\u5220\u9664\u65b9\u6cd5\uff1a<\/h2>\r\n\r\n\r\n\r\n<p>\/sbin\/swapoff \/var\/swapfilerm -f \/var\/swapfile<\/p>\r\n\r\n\r\n\r\n<p>\u5220\u6389\u6dfb\u52a0\u7684\u81ea\u52a8\u6302\u8f7dswap\u7684\u8bbe\u7f6evi \/etc\/fstab<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">\u987a\u4fbf\u9644\u4e0aDD\u547d\u4ee4\u7684\u53c2\u6570\u4ecb\u7ecd\uff1a<\/h3>\r\n\r\n\r\n\r\n<p>dd\u547d\u4ee4<br \/>\u529f\u80fd\uff1a\u628a\u6307\u5b9a\u7684\u8f93\u5165\u6587\u4ef6\u62f7\u8d1d\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u6587\u4ef6\u4e2d\uff0c\u5e76\u4e14\u5728\u62f7\u8d1d\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u8fdb\u884c\u683c\u5f0f\u8f6c\u6362\u3002\u53ef\u4ee5\u7528\u8be5\u547d\u4ee4\u5b9e\u73b0DOS\u4e0b\u7684diskcopy\u547d\u4ee4\u7684\u4f5c\u7528\u3002\u5148\u7528dd\u547d\u4ee4\u628a\u8f6f\u76d8\u4e0a\u7684\u6570\u636e\u5199\u6210\u786c\u76d8\u7684\u4e00\u4e2a\u5bc4\u5b58\u6587\u4ef6\uff0c\u518d\u628a\u8fd9\u4e2a\u5bc4\u5b58\u6587\u4ef6\u5199\u5165\u7b2c\u4e8c\u5f20\u8f6f\u76d8\u4e0a\uff0c\u5b8c\u6210diskcopy\u7684\u529f\u80fd\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5e94\u8be5\u5c06\u786c\u76d8\u4e0a\u7684\u5bc4\u5b58\u6587\u4ef6\u7528rm\u547d\u4ee4\u5220\u9664\u6389\u3002\u7cfb\u7edf\u9ed8\u8ba4\u4f7f\u7528\u6807\u51c6\u8f93\u5165\u6587\u4ef6\u548c\u6807\u51c6\u8f93\u51fa\u6587\u4ef6\u3002<br \/>\u8bed\u6cd5\uff1add [\u9009\u9879] if =\u8f93\u5165\u6587\u4ef6\uff08\u6216\u8bbe\u5907\u540d\u79f0\uff09\u3002<\/p>\r\n\r\n\r\n\r\n<p>of =\u8f93\u51fa\u6587\u4ef6\uff08\u6216\u8bbe\u5907\u540d\u79f0\uff09\u3002<\/p>\r\n\r\n\r\n\r\n<p>ibs = bytes \u4e00\u6b21\u8bfb\u53d6bytes\u5b57\u8282\uff0c\u5373\u8bfb\u5165\u7f13\u51b2\u533a\u7684\u5b57\u8282\u6570\u3002<\/p>\r\n\r\n\r\n\r\n<p>skip = blocks \u8df3\u8fc7\u8bfb\u5165\u7f13\u51b2\u533a\u5f00\u5934\u7684ibs*blocks\u5757\u3002<\/p>\r\n\r\n\r\n\r\n<p>obs = bytes \u4e00\u6b21\u5199\u5165bytes\u5b57\u8282\uff0c\u5373\u5199\u5165\u7f13\u51b2\u533a\u7684\u5b57\u8282\u6570\u3002<\/p>\r\n\r\n\r\n\r\n<p>bs = bytes \u540c\u65f6\u8bbe\u7f6e\u8bfb\/\u5199\u7f13\u51b2\u533a\u7684\u5b57\u8282\u6570\uff08\u7b49\u4e8e\u8bbe\u7f6eibs\u548cobs\uff09\u3002<\/p>\r\n\r\n\r\n\r\n<p>cbs = byte \u4e00\u6b21\u8f6c\u6362bytes\u5b57\u8282\u3002<\/p>\r\n\r\n\r\n\r\n<p>count=blocks \u53ea\u62f7\u8d1d\u8f93\u5165\u7684blocks\u5757\u3002<\/p>\r\n\r\n\r\n\r\n<p><strong>>>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\uff1a<a href=\"https:\/\/www.vpser.net\/\" target=\"_blank\"  rel=\"nofollow\" >VPS\u4fa6\u63a2<\/a>\u00a0<\/strong><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb \u76f8\u4fe1\u5f88\u591a\u4f7f\u7528VPS\u7684\u670b\u53cb\u548c\u6211\u4e00\u6837\uff0c\u6ca1\u6709\u592a\u591a\u7684\u7c73\u4e70\u66f4\u591a\u7684\u5185\u5b58\u6765\u8fdb\u884c\u5347\u7ea7\uff0c\u901a\u5e38\u4f7f\u7528swap\u4ea4\u6362\u5206\u533a\u6765\u7f13\u89e3\u7cfb\u7edf\u8d44\u6e90\u7d27\u5f20\u7684\u538b\u529b\uff0c\u95f4\u63a5 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[5],"tags":[40,43],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-5","tag-swap","tag-vps"],"_links":{"self":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":0,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}