{"id":306,"date":"2023-02-24T22:11:47","date_gmt":"2023-02-24T14:11:47","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=306"},"modified":"2023-04-30T15:06:10","modified_gmt":"2023-04-30T07:06:10","slug":"systemd-instruction-for-centos-7-and-rhel-7","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/24\/systemd-instruction-for-centos-7-and-rhel-7\/","title":{"rendered":"CentOS 7\u4e0eRHEL 7\u7684systemd\u6307\u4ee4"},"content":{"rendered":"<p>CentOS 7 \u5df2\u7ecf\u5207\u6362\u5230 systemd\uff0c\u7cfb\u7edf\u6307\u4ee4\u4e5f\u6709\u6240\u53d8\u5316\u3002\u4e4b\u524d\u7528\u4e8e\u542f\u52a8\u3001\u91cd\u542f\u3001\u505c\u6b62\u5404\u79cd\u670d\u52a1\u7684 service \u4f5c\u4e3a\u5411\u540e\u517c\u5bb9\u7684\u6307\u4ee4\u8fd8\u80fd\u4f7f\u7528\uff0c\u4f46\u662f\u5c06\u6765\u53ef\u80fd\u4f1a\u6d88\u5931\u3002\u540c\u65f6\uff0cchkconfig \u4e5f\u6539\u6210\u4e86 systemctl \u3002\u8fd9\u91cc\u5217\u4e3e\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u5bf9\u5e94\u4e8e service \u548c chkconfig \u7684\u65b0\u7684 systemctl \u6307\u4ee4\u3002<\/p>\n<h2>\u670d\u52a1<\/h2>\n<p>\u5728\u76ee\u524d\u7684 CentOS 7\uff08\u6216 RHEL 7\uff09\u7cfb\u7edf\u4e2d\uff0c\u4f9d\u7136\u53ef\u4ee5\u4f7f\u7528 service \u6307\u4ee4\u3002\u4f8b\u5982\uff0c<\/p>\n<p><!-- more --><\/p>\n<pre><code>[root@localhost ~]# service network restart\nRestarting network (via systemctl):                        [  OK  ]\n\n[root@localhost ~]# service httpd restart\nRedirecting to \/bin\/systemctl restart  httpd.service\n\n[root@localhost ~]# service sshd restart\nRedirecting to \/bin\/systemctl restart  sshd.service<\/code><\/pre>\n<p>\u4f46\u662f\u7cfb\u7edf\u4f1a\u81ea\u52a8\u91cd\u5b9a\u5411\u8be5\u6307\u4ee4\u5230\u65b0\u7684\u6307\u4ee4 \/bin\/systemctl \u6765\u6267\u884c\uff0c\u5e76\u7ed9\u51fa\u63d0\u793a\u3002<\/p>\n<p>\u662f\u65f6\u5019\u5207\u6362\u5230\u65b0\u7684\u6307\u4ee4\u683c\u5f0f\u4e86\uff0c\u76f4\u63a5\u4f7f\u7528 systemctl \u5427\u3002\u8fd9\u4e2a\u6307\u4ee4\u7684\u610f\u601d\u5c31\u662f system contrl\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u4f8b\u5b50\uff1a<\/p>\n<ul>\n<li>\u542f\u52a8\u670d\u52a1\uff1a<\/li>\n<\/ul>\n<pre><code>systemctl start httpd<\/code><\/pre>\n<ul>\n<li>\u505c\u6b62\u670d\u52a1\uff1a<\/li>\n<\/ul>\n<pre><code>systemctl stop httpd<\/code><\/pre>\n<ul>\n<li>\u91cd\u542f\u670d\u52a1\uff08\u5148\u505c\u6b62\uff0c\u540e\u542f\u52a8\uff09\uff1a<\/li>\n<\/ul>\n<pre><code>systemctl restart httpd<\/code><\/pre>\n<ul>\n<li>\u91cd\u65b0\u52a0\u8f7d\uff08\u4f7f\u7528\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff09\uff1a<\/li>\n<\/ul>\n<pre><code>systemctl reload httpd<\/code><\/pre>\n<ul>\n<li>\u663e\u793a\u670d\u52a1\u72b6\u6001\uff1a<\/li>\n<\/ul>\n<pre><code>systemctl status httpd<\/code><\/pre>\n<h2>\u81ea\u542f\u52a8<\/h2>\n<p>\u4e0e\u6b64\u540c\u65f6\uff0c\u4e4b\u524d\u7528\u4e8e\u8bbe\u5b9a\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u8fd0\u884c\u67d0\u670d\u52a1\u7684\u6307\u4ee4 chkconfig \u4e5f\u6539\u6210 systemctl\u3002<\/p>\n<ul>\n<li>\u81ea\u542f\u52a8\u670d\u52a1 chkconfig service on \u6539\u6210<\/li>\n<\/ul>\n<pre><code>systemctl enable httpd<\/code><\/pre>\n<ul>\n<li>\u5173\u95ed\u81ea\u542f\u52a8 chkconfig service off \u6539\u6210<\/li>\n<\/ul>\n<pre><code>systemctl disable httpd<\/code><\/pre>\n<ul>\n<li>\u68c0\u67e5\u670d\u52a1\u72b6\u6001\u7684 chkconfig service \u6539\u6210<\/li>\n<\/ul>\n<pre><code>systemctl is-enabled httpd<\/code><\/pre>\n<ul>\n<li>\u5217\u4e3e\u51fa\u6240\u6709\u670d\u52a1\u7684\u6307\u4ee4 chkconfig \u2013list \u6539\u6210<\/li>\n<\/ul>\n<pre><code>systemctl list-unit-files --type=service<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CentOS 7 \u5df2\u7ecf\u5207\u6362\u5230 systemd\uff0c\u7cfb\u7edf\u6307\u4ee4\u4e5f\u6709\u6240\u53d8\u5316\u3002\u4e4b\u524d\u7528\u4e8e\u542f\u52a8\u3001\u91cd\u542f\u3001\u505c\u6b62\u5404\u79cd\u670d\u52a1\u7684 serv [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-306","post","type-post","status-publish","format-standard","hentry","category-devops-base"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=306"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/306\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}