{"id":45476,"date":"2024-10-06T23:37:17","date_gmt":"2024-10-06T15:37:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45476\/"},"modified":"2024-10-06T23:37:17","modified_gmt":"2024-10-06T15:37:17","slug":"%e6%9c%80%e8%a9%b3%e7%b4%b0%e7%9a%84-centos-6-%e8%88%87-7-%e5%b0%8d%e6%af%94%ef%bc%88%e4%ba%8c%ef%bc%89%ef%bc%9a%e6%9c%8d%e5%8b%99%e7%ae%a1%e7%90%86%e5%b0%8d%e6%af%94","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45476\/","title":{"rendered":"\u6700\u8a73\u7d30\u7684 CentOS 6 \u8207 7 \u5c0d\u6bd4\uff08\u4e8c\uff09\uff1a\u670d\u52d9\u7ba1\u7406\u5c0d\u6bd4"},"content":{"rendered":"<h1 id=\"%e6%9c%80%e8%a9%b3%e7%b4%b0%e7%9a%84-centos-6-%e8%88%87-7-%e5%b0%8d%e6%af%94%ef%bc%88%e4%ba%8c%ef%bc%89%ef%bc%9a%e6%9c%8d%e5%8b%99%e7%ae%a1%e7%90%86%e5%b0%8d%e6%af%94-TADGglMGAh\">\u6700\u8a73\u7d30\u7684 CentOS 6 \u8207 7 \u5c0d\u6bd4\uff08\u4e8c\uff09\uff1a\u670d\u52d9\u7ba1\u7406\u5c0d\u6bd4<\/h1>\n<p>\u5728\u63a2\u8a0e CentOS 6 \u8207 CentOS 7 \u7684\u5dee\u7570\u6642\uff0c\u670d\u52d9\u7ba1\u7406\u662f\u4e00\u500b\u91cd\u8981\u7684\u65b9\u9762\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0cCentOS 7 \u5728\u670d\u52d9\u7ba1\u7406\u4e0a\u5f15\u5165\u4e86\u8a31\u591a\u65b0\u7279\u6027\uff0c\u9019\u4e9b\u6539\u8b8a\u4e0d\u50c5\u5f71\u97ff\u4e86\u7cfb\u7d71\u7ba1\u7406\u54e1\u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u4e5f\u63d0\u5347\u4e86\u6574\u9ad4\u7684\u7cfb\u7d71\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"1-%e6%9c%8d%e5%8b%99%e7%ae%a1%e7%90%86%e5%b7%a5%e5%85%b7%e7%9a%84%e8%ae%8a%e5%8c%96-TADGglMGAh\">1. \u670d\u52d9\u7ba1\u7406\u5de5\u5177\u7684\u8b8a\u5316<\/h2>\n<p>\u5728 CentOS 6 \u4e2d\uff0c\u670d\u52d9\u7ba1\u7406\u4e3b\u8981\u4f9d\u8cf4\u65bc\u50b3\u7d71\u7684 SysVinit \u7cfb\u7d71\u3002\u9019\u610f\u5473\u8457\u670d\u52d9\u7684\u555f\u52d5\u3001\u505c\u6b62\u548c\u91cd\u555f\u90fd\u9700\u8981\u4f7f\u7528\u4e00\u7cfb\u5217\u7684\u547d\u4ee4\uff0c\u5982\uff1a<\/p>\n<pre><code>service  start\nservice  stop\nservice  restart\n<\/code><\/pre>\n<p>\u800c\u5728 CentOS 7 \u4e2d\uff0c\u7cfb\u7d71\u8f49\u5411\u4e86 systemd \u4f5c\u70ba\u4e3b\u8981\u7684\u670d\u52d9\u7ba1\u7406\u5de5\u5177\u3002systemd \u63d0\u4f9b\u4e86\u66f4\u9ad8\u6548\u7684\u670d\u52d9\u7ba1\u7406\u65b9\u5f0f\uff0c\u4e26\u4e14\u652f\u6301\u4e26\u884c\u555f\u52d5\u670d\u52d9\uff0c\u9019\u6a23\u53ef\u4ee5\u986f\u8457\u7e2e\u77ed\u555f\u52d5\u6642\u9593\u3002\u4f7f\u7528 systemd\uff0c\u7ba1\u7406\u670d\u52d9\u7684\u547d\u4ee4\u8b8a\u70ba\uff1a<\/p>\n<pre><code>systemctl start \nsystemctl stop \nsystemctl restart \n<\/code><\/pre>\n<h2 id=\"2-%e6%9c%8d%e5%8b%99%e7%9a%84%e5%95%9f%e5%8b%95%e9%a1%9e%e5%9e%8b-TADGglMGAh\">2. \u670d\u52d9\u7684\u555f\u52d5\u985e\u578b<\/h2>\n<p>\u5728 CentOS 6 \u4e2d\uff0c\u670d\u52d9\u7684\u555f\u52d5\u985e\u578b\u4e3b\u8981\u662f\u57fa\u65bc runlevel \u7684\u6982\u5ff5\u3002\u7cfb\u7d71\u555f\u52d5\u6642\u6703\u9032\u5165\u4e0d\u540c\u7684 runlevel\uff0c\u9019\u4e9b runlevel \u5b9a\u7fa9\u4e86\u54ea\u4e9b\u670d\u52d9\u61c9\u8a72\u555f\u52d5\u3002\u4f8b\u5982\uff0crunlevel 3 \u901a\u5e38\u7528\u65bc\u591a\u7528\u6236\u6a21\u5f0f\uff0c\u800c runlevel 5 \u5247\u7528\u65bc\u5716\u5f62\u754c\u9762\u6a21\u5f0f\u3002<\/p>\n<p>\u76f8\u5c0d\u800c\u8a00\uff0cCentOS 7 \u5247\u4f7f\u7528\u4e86 target \u7684\u6982\u5ff5\uff0c\u9019\u662f\u4e00\u7a2e\u66f4\u9748\u6d3b\u7684\u65b9\u5f0f\u4f86\u7ba1\u7406\u670d\u52d9\u3002\u6bcf\u500b target \u90fd\u53ef\u4ee5\u5305\u542b\u591a\u500b\u670d\u52d9\uff0c\u4e26\u4e14\u53ef\u4ee5\u6839\u64da\u9700\u8981\u9032\u884c\u555f\u52d5\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u7528\u4f86\u67e5\u770b\u7576\u524d\u7684 target\uff1a<\/p>\n<pre><code>systemctl get-default\n<\/code><\/pre>\n<p>\u8981\u6539\u8b8a\u9ed8\u8a8d\u7684 target\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre><code>systemctl set-default \n<\/code><\/pre>\n<h2 id=\"3-%e6%9c%8d%e5%8b%99%e7%8b%80%e6%85%8b%e6%aa%a2%e6%9f%a5-TADGglMGAh\">3. \u670d\u52d9\u72c0\u614b\u6aa2\u67e5<\/h2>\n<p>\u5728 CentOS 6 \u4e2d\uff0c\u6aa2\u67e5\u670d\u52d9\u72c0\u614b\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n<pre><code>service  status\n<\/code><\/pre>\n<p>\u800c\u5728 CentOS 7 \u4e2d\uff0c\u4f7f\u7528 systemd \u7684\u8a71\uff0c\u6aa2\u67e5\u670d\u52d9\u72c0\u614b\u7684\u547d\u4ee4\u8b8a\u70ba\uff1a<\/p>\n<pre><code>systemctl status \n<\/code><\/pre>\n<p>\u9019\u4e0d\u50c5\u63d0\u4f9b\u4e86\u670d\u52d9\u7684\u904b\u884c\u72c0\u614b\uff0c\u9084\u986f\u793a\u4e86\u76f8\u95dc\u7684\u65e5\u8a8c\u4fe1\u606f\uff0c\u9019\u5c0d\u65bc\u6545\u969c\u6392\u67e5\u975e\u5e38\u6709\u5e6b\u52a9\u3002<\/p>\n<h2 id=\"4-%e6%97%a5%e8%aa%8c%e7%ae%a1%e7%90%86-TADGglMGAh\">4. \u65e5\u8a8c\u7ba1\u7406<\/h2>\n<p>CentOS 6 \u4f7f\u7528 syslog \u4f86\u7ba1\u7406\u65e5\u8a8c\uff0c\u800c CentOS 7 \u5247\u5f15\u5165\u4e86 journald\uff0c\u9019\u662f\u4e00\u500b\u66f4\u5148\u9032\u7684\u65e5\u8a8c\u7cfb\u7d71\u3002journald \u652f\u6301\u4e8c\u9032\u5236\u65e5\u8a8c\u683c\u5f0f\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u9032\u884c\u65e5\u8a8c\u67e5\u8a62\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u65e5\u8a8c\uff1a<\/p>\n<pre><code>journalctl -u \n<\/code><\/pre>\n<p>\u9019\u6a23\u7684\u8a2d\u8a08\u4f7f\u5f97\u65e5\u8a8c\u7684\u7ba1\u7406\u548c\u67e5\u8a62\u8b8a\u5f97\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n<h2 id=\"5-%e7%b8%bd%e7%b5%90-TADGglMGAh\">5. \u7e3d\u7d50<\/h2>\n<p>\u7e3d\u7684\u4f86\u8aaa\uff0cCentOS 7 \u5728\u670d\u52d9\u7ba1\u7406\u65b9\u9762\u7684\u6539\u9032\u4f7f\u5f97\u7cfb\u7d71\u7ba1\u7406\u8b8a\u5f97\u66f4\u52a0\u9ad8\u6548\u548c\u9748\u6d3b\u3002\u5f9e\u50b3\u7d71\u7684 SysVinit \u5230\u73fe\u4ee3\u7684 systemd\uff0c\u9019\u4e00\u8f49\u8b8a\u4e0d\u50c5\u63d0\u5347\u4e86\u670d\u52d9\u7684\u555f\u52d5\u901f\u5ea6\uff0c\u4e5f\u6539\u5584\u4e86\u65e5\u8a8c\u7ba1\u7406\u548c\u670d\u52d9\u72c0\u614b\u6aa2\u67e5\u7684\u4fbf\u5229\u6027\u3002\u5c0d\u65bc\u4f7f\u7528 CentOS \u7684\u7cfb\u7d71\u7ba1\u7406\u54e1\u4f86\u8aaa\uff0c\u719f\u6089\u9019\u4e9b\u8b8a\u5316\u5c07\u6709\u52a9\u65bc\u66f4\u597d\u5730\u7ba1\u7406\u548c\u7dad\u8b77\u4f3a\u670d\u5668\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u5ba2\u6236\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u4f3a\u670d\u5668\u9700\u6c42\uff0c\u6211\u5011\u90fd\u80fd\u63d0\u4f9b\u5c08\u696d\u7684\u652f\u6301\u548c\u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u6bd4\u8f03 CentOS 6 \u8207 7 \u7684\u670d\u52d9\u7ba1\u7406\uff0c\u63a2\u8a0e\u7cfb\u7d71\u555f\u52d5\u3001\u670d\u52d9\u63a7\u5236\u53ca\u7ba1\u7406\u5de5\u5177\u7684\u8b8a\u5316\u8207\u512a\u5316\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-45476","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=45476"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45476\/revisions"}],"predecessor-version":[{"id":45477,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45476\/revisions\/45477"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}