GNU/Linux >> Linux の 問題 >  >> Cent OS

Systemctlは、CentOS7のChkconfigおよびServiceコマンドを置き換えます

CentOS / RedHatの以前の経験から 、私たちは皆、「 chkconfig コマンドは、システムサービスのランレベル情報を確認および更新するために使用されます 。これらのレガシーコマンドは、下位互換性のためにCentOS 7に引き続き含まれていますが、将来のリリースでは廃止される予定です。 CentOS 7 / Redhat 7 systemctl chkconfigを置き換えます およびservice コマンド。これは、systemctlを理解して学習するのに役立つ小さなチュートリアルです。 コマンド!

SystemctlはChkconfigおよびServiceコマンドを置き換えます

CentOS 7 /Redhat7でシステムサービスを再起動します

私たちは皆CentOS/Redhatを広範囲に使用しているため、通常は次のようにサービスを開始/再開します。

[root@root ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service

しかし、あなたはその小さなメッセージに注意するかもしれません! 「ねえ、状況は変わったし、将来的には…systemctlの使用を開始する 従来のコマンドの代わりにコマンド」。

systemctlの使用方法は次のとおりです 以下に示すように、サービスを開始/再開するためのコマンド:

サービスを開始する

# systemctl start mysqld

サービスを再開します:

# systemctl restart mysqld
CentOS 7 /Redhat7でサービスのステータスを確認する方法

上記のコマンドは、サービスが開始されたかどうかについての出力を提供しません。ステータスを確認するには、次のコマンドを使用します。

# systemctl status mysqld
 mysqld.service - MySQL Server
 Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
 Active: active (running) since Thu 2017-11-09 09:32:57 CST; 1min 57s ago
 Docs: man:mysqld(8)
 http://dev.mysql.com/doc/refman/en/using-systemd.html
 Process: 1660 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
 Process: 1640 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1662 (mysqld)
 CGroup: /system.slice/mysqld.service
 ââ1662 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...

Nov 09 09:32:56 s119957 systemd[1]: Starting MySQL Serv...
Nov 09 09:32:57 s119957 systemd[1]: Started MySQL Server.
Hint: Some lines were ellipsized, use -l to show in full.

CentOS7のChkconfig

起動時にサービスを自動起動する場合は、chkconfigを使用できません。 (古いCentOSのレガシーコマンド)!はい、あなたはそれを正しく聞きました。今度はsystemctl chkconfigを置き換えます コマンドも…

chkconfigサービスオン– CentOS 7 / Redhat 7:

#systemctl enable <service_name>

たとえば、

#systemctl enable mysqld

chkconfigサービスオフ– CentOS7 / Redhat 7:

#systemctl disable <service_name>

たとえば、

#systemctl disable mysqld

chkconfig特定のサービスリスト– CentOS 7 / Redhat 7:

#systemctl is-enabled <service_name>

たとえば、

#systemctl is-enabled mysqld
enabled

chkconfig –list – CentOS 7 / Redhat 7:

#systemctl list-unit-files --type=service

UNIT FILE                                     STATE
arp-ethers.service                           disabled
auditd.service                               enabled
[email protected]                              enabled
blk-availability.service                     disabled
brandbot.service                             static
console-getty.service                        disabled
console-shell.service                        disabled
[email protected]                     static
cpupower.service                             disabled
...
...

自分自身を更新して、CentOS7での作業を楽しんでください🙂


Cent OS
  1. CentOS6にMongoDBをインストールします

  2. CentOS8およびFedora33にFail2Banをインストールおよび構成する方法

  3. CentOS 8でサービスを開始、停止、または再起動します-ステップバイステップのプロセス?

  1. CentOS 7でFirewalldを停止して無効にする-ステップバイステップのプロセス?

  2. CentOS / RHEL :Apache httpd サービスをインストールして開始する方法

  3. CentOS/RHEL 7 および 8 でサービスをマスクまたはマスク解除する方法

  1. Centos4.8およびGlibc2.5?

  2. 基本サービスコマンド

  3. CentOS / RHEL 7 :レガシー コマンド service および chkconfig の systemctl 置換