{"id":246,"date":"2021-02-10T01:12:51","date_gmt":"2021-02-09T17:12:51","guid":{"rendered":"http:\/\/www.pfloat.top\/?p=246"},"modified":"2022-05-16T11:32:28","modified_gmt":"2022-05-16T03:32:28","slug":"linux-swap%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98%e6%b7%bb%e5%8a%a0-%e4%bf%ae%e6%94%b9-%e5%88%a0%e9%99%a4","status":"publish","type":"post","link":"https:\/\/www.eutaboo.com\/index.php\/2021\/02\/10\/linux-swap%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98%e6%b7%bb%e5%8a%a0-%e4%bf%ae%e6%94%b9-%e5%88%a0%e9%99%a4\/","title":{"rendered":"Linux swap\u865a\u62df\u5185\u5b58\u6dfb\u52a0\/\u4fee\u6539\/\u5220\u9664"},"content":{"rendered":"<h2>\u4ec0\u4e48\u662fswap\u865a\u62df\u5185\u5b58<\/h2>\n<p>\u4e09\u4e24\u53e5\u5927\u767d\u8bdd\u7b80\u8ff0\u4e00\u4e0b\uff0cswap\u5206\u533a\u4e5f\u5c31\u662fcentOs\u4e0a\u865a\u62df\u5185\u5b58\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u9ed8\u8ba4\u662f0\uff0c\u4e5f\u5c31\u662f\u6ca1\u6709\u4f7f\u7528\u8fd9\u4e2a\u865a\u62df\u5185\u5b58\u7684\u3002<br \/>\n\u90a3\u8fd9\u4e2a\u865a\u62df\u5185\u5b58\u6709\u4ec0\u4e48\u7528\uff1f\u5b83\u5c31\u662f\u628a\u6211\u4eec\u7684\u78c1\u76d8\u7a7a\u95f4\u8f6c\u4e3a\u5185\u5b58\uff0c\u6bd4\u65b9\u8bf4\u62ff\u51fa2G\u7684\u78c1\u76d8\u7a7a\u95f4\u6765\u505a\u5185\u5b58\u4f7f\u7528\u3002<br \/>\n\u5f53\u7136\u5b83\u7684\u6027\u80fd\u4e0e\u6211\u4eec\u7269\u7406\u5185\u5b58\u7684\u6027\u80fd\u76f8\u6bd4\u90a3\u53ef\u662f\u4f4e\u4e0d\u5c11\u7684\u3002<br \/>\n\u50cf\u6211\u7684\u8bdd\uff0c\u7269\u7406\u5185\u5b58\u4e0d\u591f\u7528\u4e86\uff0c\u4e3a\u4e86\u7701\u94b1\uff0c\u4e8e\u662f\u5c31\u7528\u865a\u62df\u5185\u5b58\u6765\u505a\u5185\u5b58\u3002<br \/>\nbb\u5b8c\u4e86\uff0c\u63a5\u4e0b\u6765\u5b9e\u8df5\u4e00\u4e0b<\/p>\n<hr \/>\n<h2>\u5206\u533a\u8bbe\u7f6e\u5927\u5c0f\u5efa\u8bae<\/h2>\n<div class=\"table-box\">\n<table>\n<thead>\n<tr>\n<th>\u7269\u7406\u5185\u5b58<\/th>\n<th>\u5efa\u8bae\u7684\u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f<\/th>\n<th>\u5982\u679c\u5f00\u542f\u4f11\u7720\u529f\u80fd\u5efa\u8bae\u7684\u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u2a7d 2GB<\/td>\n<td>\u5185\u5b58\u76842\u500d<\/td>\n<td>\u5185\u5b58\u76843\u500d<\/td>\n<\/tr>\n<tr>\n<td>> 2GB \u2013 8GB<\/td>\n<td>\u7b49\u4e8e\u5185\u5b58\u5927\u5c0f<\/td>\n<td>\u5185\u5b58\u76842\u500d<\/td>\n<\/tr>\n<tr>\n<td>> 8GB \u2013 64GB<\/td>\n<td>\u81f3\u5c114G<\/td>\n<td>\u5185\u5b58\u76841.5\u500d<\/td>\n<\/tr>\n<tr>\n<td>> 64GB<\/td>\n<td>\u81f3\u5c114G<\/td>\n<td>\u4e0d\u5efa\u8bae\u4f7f\u7528\u4f11\u7720<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<hr \/>\n<h2>\u6dfb\u52a0\u5206\u533a<\/h2>\n<pre><code class=\"language-bash line-numbers\"># \u521b\u5efa4G\u7684\u865a\u62df\u5185\u5b58\u5927\u5c0f\uff0c\u5728\/home\/swap\u4e0b\ndd if=\/dev\/zero of=\/home\/swap bs=1024 count=4096000\n# \u5e94\u7528\u4e3aswap\u683c\u5f0f\u6587\u4ef6\nmkswap \/home\/swap\n# \u5c06\u81ea\u5b9a\u4e49\u7684swap\u6302\u8f7d\u5230swap\u5206\u533a\n\/sbin\/swapon \/home\/swap\n<\/code><\/pre>\n<pre><code class=\"language-bash line-numbers\">[root@VM_16_14_centos \/]# free -h\n              total        used        free      shared  buff\/cache   available\nMem:           3.7G        641M        168M        684K        2.9G        2.8G\nSwap:          3.9G          0B        3.9G\n<\/code><\/pre>\n<p>\u67e5\u770bswap\u5206\u533a\u5927\u5c0f\u53ca\u60c5\u51b5<\/p>\n<pre><code class=\"language-bash line-numbers\">[root@VM_16_14_centos \/]# cat \/proc\/swaps\nFilename                                Type            Size    Used    Priority\n\/home\/swap                              file            4095996 6144    -2\n<\/code><\/pre>\n<h3>\u6c38\u4e45\u751f\u6548<\/h3>\n<pre><code class=\"language-bash line-numbers\">vi \/etc\/fstab\n# \u5728\u6587\u4ef6\u6700\u540e\u6dfb\u52a0\u5982\u4e0b\u4e00\u884c\n\/home\/swap swap swap default 0 0\n<\/code><\/pre>\n<hr \/>\n<h2>\u4fee\u6539\u5206\u533a\u5927\u5c0f<\/h2>\n<pre><code class=\"language-bash line-numbers\"># \u5173\u95edswap\u5206\u533a\n\/sbin\/swapoff \/home\/swap\n# \u4fee\u6539\u4e3a2G\ndd if=\/dev\/zero of=\/home\/swap bs=1024 count=2048000\n# \u5e94\u7528\u4e3aswap\u683c\u5f0f\u6587\u4ef6\nmkswap \/home\/swap\n# \u5c06\u81ea\u5b9a\u4e49\u7684swap\u6302\u8f7d\u5230swap\u5206\u533a\n\/sbin\/swapon \/home\/swap\n<\/code><\/pre>\n<pre><code class=\"language-bash line-numbers\">[root@VM_16_14_centos \/]# free -h\n              total        used        free      shared  buff\/cache   available\nMem:           3.7G        643M        902M        684K        2.2G        2.8G\nSwap:          2.0G          0B        2.0G\n<\/code><\/pre>\n<hr \/>\n<h2>\u5220\u9664swap\u5206\u533a<\/h2>\n<pre><code class=\"language-bash line-numbers\"># \u5173\u95edswap\u5206\u533a\n\/sbin\/swapoff \/home\/swap\n# \u5220\u9664\u5206\u533a\u6587\u4ef6\nrm -rf \/home\/swap\n# \u5220\u9664\u81ea\u52a8\u6302\u8f7d\u914d\u7f6e\u547d\u4ee4\n# \u5c06\u521a\u521a\u6c38\u4e45\u751f\u6548\u914d\u7f6e\u7684\u6700\u540e\u4e00\u884c\u5220\u9664\u5373\u53ef\nvi \/etc\/fstab\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fswap\u865a\u62df\u5185\u5b58 \u4e09\u4e24\u53e5\u5927\u767d\u8bdd\u7b80\u8ff0\u4e00\u4e0b\uff0cswap\u5206\u533a\u4e5f\u5c31\u662fcentOs\u4e0a\u865a\u62df\u5185\u5b58\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u9ed8\u8ba4\u662f0\uff0c\u4e5f\u5c31\u662f\u6ca1\u6709\u4f7f\u7528\u8fd9\u4e2a\u865a\u62df &#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":[],"class_list":["post-246","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts\/246","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=246"}],"version-history":[{"count":1,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":938,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/posts\/246\/revisions\/938"}],"wp:attachment":[{"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eutaboo.com\/index.php\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}