systemctlコマンドの使い方と主要オプションの使い方
CentOSやRedhatの7系からサービス管理に使用する「systemctl 」コマンドの
7系以前の「service 」コマンドとは少々使用方法が違いますので、利用時には注意してください。
systemctlコマンドとは?
systemctlコマンドはsystemd を操作するコマンドで、
サービスの起動 や停止 ・起動設定の変更 と状態確認 ができます。
systemdは従来のinitの代替機能で、高速なシステム起動・終了 や、様々なシステム管理機能 を提供されています。
ちなみに従来のinitはシンボリックリンクでsystemdとして利用されています。
$ ls -l /sbin/init
lrwxrwxrwx. 1 root root 22 Mar 30 22:53 /sbin/init -> ../lib/systemd/systemd
systemctlコマンドの使用方法
以下がsystemctlコマンドの書き方になります。
systemctl [オプション] コマンド [Unit名]
[table id=39 column_widths=30%|70% /]
ここから実際の使用方法を記載します。今回はMariaDBを使用して起動や停止を実施していきます。
サービスの起動
systemctl start mariadb.service
サービスを停止
systemctl stop mariadb.service
サービスの自動起動有効化
systemctl enable mariadb.service
サービスの自動起動無効化
systemctl disable mariadb.service
サービスのステータス確認
systemctl status mariadb.service
systemctlコマンドのオプション
[table id=40 column_widths=20%|80% /]
[itemlink post_id=“4902”]