Systemd程序

Systemd的主要目的就是减少系统引导时间和计算开销。Systemd(系统管理守护进程)

 

SysV init 是一个老旧的系统,它基本上仅运行/etc/init.d目录下的一些脚本。

Systemd是一个现代技术,用以取代老旧以及粗糙的SysV init。它可以在接收到事件响应时启动相关服务

Systemd是一个巨大的项目,其中包括了很多其他的功能。它是一个软件套件,而不仅仅是一个init。

systemd好像成为了一个仅依赖Linux核心的完全统一的系统层。

 

 

 

1. 当你打开电源后电脑所做的第一件事情就是BIOS初始化。BIOS会读取引导设备设定,定位并传递系统控制权给MBR(假设硬盘是第一引导设备)。

2. MBR从Grub或LILO引导程序读取相关信息并初始化内核。接下来将由Grub或LILO继续引导系统。如果你在grub配置文件里指定了systemd作为引导管理程序,之后的引导过程将由systemd完成。Systemd使用“target”来处理引导和服务管理过程。这些systemd里的“target”文件被用于分组不同的引导单元以及启动同步进程。

3. systemd执行的第一个目标是default.target。但实际上default.target是指向graphical.target的软链接。Linux里的软链接用起来和Windows下的快捷方式一样。文件Graphical.target的实际位置是/usr/lib/systemd/system/graphical.target。在下面的截图里显示了graphical.target文件的内容。

[root@sky cdrom]# ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 36 11月 18 18:51 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
[root@sky cdrom]# ll  /lib/systemd/system/graphical.target
-rw-r--r--. 1 root root 522 4月   2 2014 /lib/systemd/system/graphical.target

[root@sky system]# cat graphical.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
[root@sky system]#

[root@sky system]# cat multi-user.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=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes

[Install]
Alias=default.target

[root@sky system]# cat basic.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=Basic System
Documentation=man:systemd.special(7)
Requires=sysinit.target
Wants=sockets.target timers.target paths.target slices.target
After=sysinit.target sockets.target timers.target paths.target slices.target
RefuseManualStart=yes

[root@sky system]# cat sysinit.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=System Initialization
Documentation=man:systemd.special(7)
Conflicts=emergency.service emergency.target
Wants=local-fs.target swap.target
After=local-fs.target swap.target emergency.service emergency.target
RefuseManualStart=yes
[root@sky system]#

 

 

image

取代init程序,管理系统。

image

service.service,

socket.socket,

device.device,

mount.mount,

automount.automount,

swap.swap,

target.target,

path.path,

timer.timer,
snapshot.snapshot,

slice.slice,

scope.scope

 

/etc/systemd/system/*
/run/systemd/system/*
/usr/lib/systemd/system/*

image

 

1007  ls /etc/systemd/system
 1008  ls /run/systemd/system/
 1009  ls /usr/lib/systemd/system
 1010  systemctl
 1011  systemctl --failed
 1012  systemctl start httpd.service
 1013  systemctl --failed
 1014  systemctl stop httpd.service
 1015  systemctl restart httpd.service
 1016  systemctl reload httpd.service
 1017  systemctl ststus httpd.service
 1018  systemctl status httpd.service
 1019  ll /etc/systemd/system/default.target
 1020  runlevel
 1021  cat /lib/systemd/system/graphical.target
 1022  systemctl list-unit --type=taget
 1023  systemctl list-unit --type=target
 1024  systemctl list-units --type=target
 1025  systemctl list-units
 1026  systemctl list-unit-files
 1027  systemctl isenable httpd.service
 1028  systemctl is-enable httpd.service
 1029  systemctl is-enabled httpd.service
 1030  systemctl is-active httpd.service
 1035  systemctl disable httpd.service
 1036  systemctl is-active httpd.service
 1037  systemctl is-enabled httpd.service
 1038  systemctl ensable httpd.service
 1039  systemctl enaable httpd.service
 1040  systemctl enable httpd.service
 1044  systemctl list-unit --type=target
 1045  systemctl list-units --type=target
 1046  journalctl
 1047  journalctl -b

转载于:https://www.cnblogs.com/skyfly0772/p/5001251.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值