[转帖][Linux]systemd和sysV
[Linux]systemd和sysV
转自:https://www.cnblogs.com/EasonJim/p/7168216.html
在Debian8中systemd和sysVinit同时存在,NTP就是在/etc/init.d/ntp中启动
首先了解以下Ubuntu运行级别(init)对应工具的变化历史:
1、Ubuntu 6.10及以前版本使用Sysvinit。
2、Ubuntu 14.10及以前版本使用Upstart但是还留着Sysvinit并存。
https://wiki.ubuntu.com/Upstart
https://help.ubuntu.com/community/UpstartHowto
3、Ubuntu 15.04开始预设使用Systemd,但是可以在开机选项选择使用Systemd或Upstart,但是不可同時使用Sysvinit或Upstart并存。
https://wiki.ubuntu.com/SystemdForUpstartUsers
整个Linux的init发展历史:
https://zh.wikipedia.org/wiki/Init
详细介绍三个体系:Sysvinit、Upstart、Systemd
Sysvinit:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init1/index.html
Upstart:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init2/index.html
Systemd:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html
总结Sysvinit:
对于其它两项在Ubuntu上已经有介绍其使用方法,主要是Sysvinit比较历史悠久,其主要就是一个Shell脚本,并且是放置在/etc/init.d文件夹下。然后通过update-rc.d命令进行运行级别的操作来达到服务的启动。下面是一些服务脚本的编写参考:
其实系统提供的说明文档,在/etc/init.d/README
https://gist.github.com/naholyr/4275302
https://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html
来自:stackexchange的回答
chaos' answer is what some documentation says. But it's not what systemd actually does. (It's not what van Smoorenburg rc
did, either. The van Smoorenburg rc
most definitely did not ignore LSB headers, which insserv
used to calculate static orderings, for starters.) The Freedesktop documentation, such as that "Incompatibilities" page, is in fact wrong, on these and other points. (The HOME
environment variable in fact is often set, for example. This went wholly undocumented anywhere for a long time. It's now documented in the manual, at least, but that Freedesktop WWW page still hasn't been corrected.)
The native service format for systemd is the service unit. systemd's service management proper operates solely in terms of those, which it reads from one of nine directories where (system-wide) .service
files can live. /etc/systemd/system
, /run/systemd/system
, /usr/local/lib/systemd/system
, and /usr/lib/systemd/system
are four of those directories.
The compatibility with van Smoorenburg rc
scripts is achieved with a conversion program, named systemd-sysv-generator
. This program is listed in the /usr/lib/systemd/system-generators/
directory and is thus run automatically by systemd early in the bootstrap process at every boot, and again every time that systemd is instructed to re-load its configuration later on.
This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located. systemd-sysv-generator
generates the service units that run the van Smoorenburg rc
scripts from /etc/init.d
, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
systemd service management only knows about service units. These automatically (re-)generated service units are written to invoke the van Smoorenburg rc
scripts. They have, amongst other things:
[Unit] SourcePath=/etc/init.d/wibble [Service] ExecStart=/etc/init.d/wibble start ExecStop=/etc/init.d/wibble stop
Received wisdom is that the van Smoorenburg rc
scripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the /etc/rc?.d/
system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator
can recognize the more limited old RedHat comment headers (description:
, pidfile:
, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the /etc/rc?.d
symbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that /etc/rc3.d
didn't appear to matter is that you probably had that script enabled via another /etc/rc?.d/
directory. systemd-sysv-generator
translates being listed in any of /etc/rc2.d/
, /etc/rc3.d/
, and /etc/rc4.d/
into a native Wanted-By
relationship to systemd's multi-user.target
. Run levels are "obsolete" in the systemd world, and you can forget about them.
[转帖][Linux]systemd和sysV的更多相关文章
- [转帖]Linux systemd 常用命令
Linux systemd 常用命令 https://www.cnblogs.com/tsdxdx/p/7288490.html systemctl hostnamectl timedatectl l ...
- [Linux]systemd和sysV
转自:https://www.cnblogs.com/EasonJim/p/7168216.html 在Debian8中systemd和sysVinit同时存在,NTP就是在/etc/init.d/n ...
- Linux systemd 打开调试终端、添加开机自运行程序
/************************************************************************* * Linux systemd 打开调试终端.添加 ...
- Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务
RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...
- Linux systemd资源控制初探
Linux systemd资源控制初探 本文记录一次cgroup子目录丢失问题,并简单探索了Linux systemd的资源控制机制. 问题现象 我们希望通过systemd拉起服务并通过cgroup限 ...
- linux systemd 从简单的例子入门
linux systemd 从简单的例子入门 网上很多相关链接,一上来就给一大堆命令和讲解,让人头都大. 我们希望有一个service(服务),让它在开机启动的时候就执行. 用 root 登陆以后: ...
- [转帖]LINUX PID 1 和 SYSTEMD
LINUX PID 1 和 SYSTEMD 2017年07月16日 陈皓 评论 46 条评论 57,176 人阅读 https://coolshell.cn/articles/17998.html ...
- linux systemd详解
CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...
- Linux Systemd 详细介绍: Unit、Unit File、Systemctl、Target
Systemd 简介 CentOS 7 使用 Systemd 替换了SysV Ubuntu 从 15.04 开始使用 Systemd Systemd 是 Linux 系统工具,用来启动守护进程,已成为 ...
随机推荐
- kubernetes运用
1:kubernetes基本介绍 kubernetes 是一个开源的容器集群管理系统,K8s用于容器化应用程序的部署 扩展和管理,提供容器编排 资源调度 弹性伸缩 部署管理 服务发现等一系列功能. ...
- SpringBoot2.0集成Shiro
1.shiro的三个核心概念: 1)Subject:代表当前正在执行操作的用户,但Subject代表的可以是人,也可以是任何第三方系统帐号.当然每个subject实例都会被绑定到SercurityMa ...
- 计蒜客 2018南京网络赛 I Skr ( 回文树 )
题目链接 题意 : 给出一个由数字组成的字符串.然后要你找出其所有本质不同的回文子串.然后将这些回文子串转化为整数后相加.问你最后的结果是多少.答案模 1e9+7 分析 : 应该可以算是回文树挺裸的题 ...
- plt.plot() 无法使用参数ax
问题参考 TypeError: inner() got multiple values for keyword argument 'ax' fig, ax=plt.subplots(2,1) plt. ...
- linux输出与查看的几种方式
输出的几种方式:echo/ tee echo "postgres install Failed !!!!!!" | tee -a "$Install_log"# ...
- b站编程课程资源汇总
b站编程课程资源汇总 一.总结 一句话总结: b站的编程资源很多,而且很良心 二.编程课程资源汇总 b站看到的,分享给大家 https://www.bilibili.com/video/av50680 ...
- sql server中 设置与查看锁的超时时间(ZT) @@LOCK_TIMEOUT
在数据库的应用系统中,死锁是不可避免的.通过设置死锁的处理优先级方法,可以在数据库引擎中自动检测到死锁,对发生的死锁会话进行干预,从而达到解除死锁的目点,但在这种情况下,会话只能被动的等待数据库引 ...
- IP处理模块IPy
#安装IPy模块#pip install IPy #from IPy import IPip_s = input('please input an IP or net-range:')#192.168 ...
- mysql replaceinto VS insertinto
https://blog.csdn.net/t8116189520/article/details/78908975 所以,若想基于插入值累加是不行的,需要insert into https://ww ...
- golang入门案例之SOCKET
//服务端代码package main import ( "fmt" "net" "log" "os" "en ...