Systemdとsystemctl

2605 ワード

systemd
RHEL 7の新しい初期化プロセス:systemdは、同時起動メカニズムを使用し、起動速度を向上させた.初期化プロセスの置き換えにより、元のinittabは機能せず、「実行レベル」の概念もなくなりました.
システム起動時に行う大量の初期化作業、例えばファイルシステムのマウント、各種プロセスサービスの起動などはユニット(Unit)と見なすことができる.
[root@linuxprobe ~]# cat /etc/systemd/system/default.target
# This file is part of systemd.
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.[Unit]Description=Graphical Interface 
Documentation=man:systemd.special(7)
Requires=multi-user.target
After=multi-user.target
Conflicts=rescue.target
Wants=display-manager.service
AllowIsolate=yes[Install]Alias=default.target

Systemdとsysvinitの実行レベルの対応関係
Sysvinit実行レベル
Systemdターゲット名
さぎょう
0
runlevel0.target, poweroff.target
シャットダウン
1
runlevel1.target, rescue.target
シングルユーザモード
2
runlevel2.target, multi-user.target
レベル3と同等
3
runlevel3.target, multi-user.target
マルチユーザのテキストインタフェース
4
runlevel4.target, multi-user.target
レベル3と同等
5
runlevel5.target, graphical.target
マルチユーザのグラフィックインタフェース
6
runlevel.target, reboot.target
再起動
emergency
emergency.target
緊急hell
例1.デフォルトの実行レベルを「マルチユーザ、グラフィックなしモード」に変更
# ln -sf/lib/systemd/system/multi-user.target/etc/systemd/system/default.target
例2.デフォルトの実行レベルをグラフィカルモードに変更
# ln -sf/lib/systemd/system/graphical.target/etc/systemd/system/default.target
systemctl
RHEL 7システムの管理サービスコマンドをサービスからシステムctlに変更します.
Systemctl管理サービスコマンド
Sysvinitコマンド(RHEL 6システム)
Systemctlコマンド(RHEL 7システム)
さぎょう
service foo start
systemctl start foo.service
サービスの開始
service foo restart
systemctl restart foo.service
サービスの再起動
service foo stop
systemctl stop foo.service
サービスの停止
service foo reload
systemctl reload foo.service
プロファイルの再ロード(サービスを終了しない)
service foo status
systemctl status foo.service
サービスステータスの表示
Systemctlサービス設定コマンド
Sysvinitコマンド(RHEL 6システム)
Systemctlコマンド(RHEL 7システム)
さぎょう
chkconfig foo on
systemctl enable foo.service
自動起動
chkconfig foo off
systemctl disable foo.service
自動的に起動しない
chkconfig foo
systemctl is-enabled foo.service
特定のサービスがPOSTしているかどうかを確認します.
chkconfig --list
systemctl list-unit-files --type=service
参考文献:http://www.linuxprobe.com/chapter-08/