{"id":884,"date":"2017-09-05T18:06:12","date_gmt":"2017-09-05T10:06:12","guid":{"rendered":"http:\/\/www.bluesdream.com\/blog\/?p=884"},"modified":"2017-09-05T18:06:12","modified_gmt":"2017-09-05T10:06:12","slug":"add-swap-partitionto-centos","status":"publish","type":"post","link":"https:\/\/www.bluesdream.com\/blog\/add-swap-partitionto-centos.html","title":{"rendered":"\u7ed9CentOS\u6dfb\u52a0SWAP\u5206\u533a"},"content":{"rendered":"<p>\u8fd9\u4e24\u5929\u6253\u5f00\u535a\u5ba2\u603b\u663e\u793a<code>\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5\u65f6\u51fa\u9519<\/code>\uff0c\u5934\u4e24\u6b21\u624b\u52a8\u91cd\u542f\u4e86\u4e00\u4e0b\u3002\u7ed3\u679c\u4eca\u5929\u53c8\u53d1\u751f\u7c7b\u4f3c\u4e8b\u60c5\uff0c\u77e5\u9053\u80af\u5b9a\u662f\u6570\u636e\u5e93\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u4e8e\u662f\u67e5\u770b\u4e86<code>MariaDB<\/code>\u65e5\u5fd7<code>\/var\/log\/mariadb\/mariadb.log<\/code>\u3002<\/p>\n<p>\u901a\u8fc7\u65e5\u5fd7\uff0c \u53ef\u4ee5\u770b\u5230\u662f\u7531\u4e8e\u5185\u5b58\u4e0d\u8db3\u6240\u5bfc\u81f4\u7684\u6570\u636e\u5e93\u5d29\u6e83\uff1a<\/p>\n<blockquote><p>\n  170902 4:21:18 [ERROR] Plugin 'InnoDB' init function returned error.<br \/>\n  170902 4:21:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.<br \/>\n  170902 4:21:18 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)<br \/>\n  170902 4:21:18 [Note] Plugin 'FEEDBACK' is disabled.<br \/>\n  170902 4:21:18 [ERROR] Unknown\/unsupported storage engine: InnoDB<br \/>\n  170902 4:21:18 [ERROR] Aborting<br \/>\n  170902 4:21:18 [Note] \/usr\/libexec\/mysqld: Shutdown complete<br \/>\n  <!--more-->\n<\/p><\/blockquote>\n<p>\u65e2\u7136\u77e5\u9053\u4e86\u539f\u56e0\uff0c\u90a3\u4e5f\u5c31\u6709\u4e86\u89e3\u51b3\u65b9\u6cd5\u3002\u9996\u5148\u901a\u8fc7<code>free -m<\/code>\u547d\u4ee4\u67e5\u770b\u5185\u7528\u4f7f\u7528\u60c5\u51b5\uff0c\u770b\u5230<code>swap<\/code>\u5206\u533a\u5927\u5c0f\u4e3a0\uff0c\u65e2\u7136\u5982\u6b64\u90a3\u5c31\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u4e00\u4e2a<code>swap<\/code>\u5206\u533a\u3002<\/p>\n<p>1&#46; \u8fdb\u5165\u4e00\u4e2a\u76ee\u5f55\u521b\u5efaSWAP\u5206\u533a\u6587\u4ef6\uff1a<\/p>\n<blockquote><p>\n  cd \/var\n<\/p><\/blockquote>\n<p>\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u5927\u5c0f\u4e3a1G\uff1a\uff08 if\uff1a\u8f93\u5165\u6587\u4ef6\uff0cof\uff1a\u8f93\u51fa\u6587\u4ef6\uff0cbs\uff1a\u5757\u5927\u5c0f 1024bytes\uff0c count\uff1a\u6709\u591a\u5c11\u4e2a\u8fd9\u6837\u5927\u5c0f\u7684\u5757 1048576 = 1024*1024 \uff09<\/p>\n<blockquote><p>\n  dd if=\/dev\/zero of=swapfile bs=1024 count=1048576\n<\/p><\/blockquote>\n<p>2&#46; \u521b\u5efaSWAP\u6587\u4ef6\uff1a<\/p>\n<blockquote><p>\n  mkswap swapfile\n<\/p><\/blockquote>\n<p>3&#46; \u4e4b\u540e\u8bbe\u7f6e\u5b83\u7684\u6743\u9650\uff1a\uff08\u4e0d\u8fd9\u6837\u8bbe\u7f6e\u4f1a\u51fa\u73b0\u7cfb\u7edf\u8b66\u544a swapon: \/var\/swapfile: insecure permissions 0644, 0600 suggested.\uff09<\/p>\n<blockquote><p>\n  chmod 0600 swapfile\n<\/p><\/blockquote>\n<p>4&#46; \u7acb\u5373\u6fc0\u6d3bSWAP\u6587\u4ef6\uff1a<\/p>\n<blockquote><p>\n  swapon swapfile\n<\/p><\/blockquote>\n<p>5&#46; \u8bbe\u7f6e\u5f00\u673a\u6302\u8f7d\u8fd9\u4e2aSWAP\u6587\u4ef6<\/p>\n<blockquote><p>\n  echo \"\/var\/swapfile swap swap defaults 0 0\" >> \/etc\/fstab\n<\/p><\/blockquote>\n<p>6&#46; \u7ee7\u7eed\u4f7f\u7528 <code>free -m<\/code> \u547d\u4ee4\uff0c\u67e5\u770b\u5206\u533a\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<p>\u9644\uff1a\u5220\u9664SWAP\u5206\u533a<\/p>\n<p>1&#46; \u4f7f\u7528<code>swapoff<\/code>\u547d\u4ee4\u5173\u95ed\u7cfb\u7edf\u4ea4\u6362\u533a\uff1a<\/p>\n<blockquote><p>\n  swapoff \/swapfile\n<\/p><\/blockquote>\n<p>2&#46; \u4fee\u6539<code>fstab<\/code>\u6587\u4ef6\uff1a<\/p>\n<blockquote><p>\n  vim \/etc\/fstab\n<\/p><\/blockquote>\n<p>3&#46; \u5220\u9664\u5206\u533a\u6587\u4ef6<\/p>\n<blockquote><p>\n  \u6587\u4ef6 rm -rf \/swapfile\n<\/p><\/blockquote>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"http:\/\/www.vpser.net\/opt\/vps-add-swap.html\">VPS\u4f18\u5316\u4e4b\u6dfb\u52a0swap\u4ea4\u6362\u5206\u533a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e24\u5929\u6253\u5f00\u535a\u5ba2\u603b\u663e\u793a\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5\u65f6\u51fa\u9519\uff0c\u5934\u4e24\u6b21\u624b\u52a8\u91cd\u542f\u4e86\u4e00\u4e0b\u3002\u7ed3\u679c\u4eca\u5929\u53c8\u53d1\u751f\u7c7b\u4f3c\u4e8b\u60c5\uff0c\u77e5\u9053\u80af\u5b9a\u662f\u6570\u636e\u5e93\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u4e8e\u662f\u67e5\u770b\u4e86MariaDB\u65e5\u5fd7\/var\/log\/mariadb\/mariadb.log\u3002 \u901a\u8fc7\u65e5\u5fd7\uff0c \u53ef\u4ee5\u770b\u5230\u662f\u7531\u4e8e\u5185\u5b58\u4e0d\u8db3\u6240\u5bfc\u81f4\u7684\u6570\u636e\u5e93\u5d29\u6e83\uff1a 170902 4:21:18 [ERROR] Plugin 'InnoDB' init function returned error. 170902 4:21:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 170902 4:21:18 [ERROR] mysqld: Out of memory (Needed 128917504 bytes) 170902 4:21:18 [Note] Plugin 'FEEDBACK' is disabled. 170902 4:21:18 [ERROR] Unknown\/unsupported storage engine: InnoDB 170902 4:21:18 [ERROR] Aborting 170902 4:21:18 [Note] \/usr\/libexec\/mysqld: &hellip; <a href=\"https:\/\/www.bluesdream.com\/blog\/add-swap-partitionto-centos.html\"><span class=\"more-link\">[ \u67e5\u770b\u5168\u6587... ]<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":885,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[165,11,170,169,163],"class_list":["post-884","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-program","tag-centos","tag-linux","tag-swap","tag-vps","tag-163"],"_links":{"self":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/884"}],"collection":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/comments?post=884"}],"version-history":[{"count":0,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/884\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media\/885"}],"wp:attachment":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media?parent=884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/categories?post=884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/tags?post=884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}