systemd
RHEL7全新的初始化進程: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
RHEL7系統的管理服務命令從service改爲systemctl。
systemctl管理服務命令
sysvinit命令(RHEL6系統) | systemctl命令(RHEL7系統) | 作用 |
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命令(RHEL6系統) | systemctl命令(RHEL7系統) | 作用 |
chkconfig foo on | systemctl enable foo.service | 開機自動啓動 |
chkconfig foo off | systemctl disable foo.service | 開機不自動啓動 |
chkconfig foo | systemctl is-enabled foo.service | 查看特定服務是否爲開機自啓動 |
chkconfig --list | systemctl list-unit-files --type=service |
參考文獻:http://www.linuxprobe.com/chapter-08/