您的位置:首页 > 其它

systemd和systemctl

2016-02-05 12:44 281 查看
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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: