systemvinit-upstart
▶ systemvinit
systemv 是 UNIX 的一种。
1982 年左右 AT&T 基于原来的 UNIX7 版本开发了 UNIX System Ⅲ 后来基于多方的经验在 1983 开发了 System V Release 1。
这个 System V 就是一个版本的UNIX名称,其中 System V 的初始化程序就是 Systemvinit。
早期的 Linux 发行版本采取的是 Systemvinit 的初始化程序,少量发行版本使用 FreeBSD 的初始化程序。
在 SystemVinit 初始化的就是 init 进程。
▷ /etc/inittab
init 进程会读取 /etc/inittab 这个配置文件。
SystemVinit是一个传统的UNIX初始化系统,在较老旧的操作系统中使用,这里使用的是 CentOS 6.5。
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
systemVinit 用 runlevel[运行级别] 来定义预先定义的运行级别。
配置文件的语法格式:
id:runlevels:action:process
表示符:运行级别:动作的类型:所要执行的命令
| 运行级别 | 作用 |
|---|---|
| 0 | 让init关闭所有的进程,终止系统 |
| 1 | 进入到单用户模式 |
| 2 | 多用户,但是不支持NFS文件共享 |
| 3 | 提供一种真正的多用户文本模式 |
| 4 | 没用 |
| 5 | X11 是吧系统初始化一个XWindow的终端 |
| 6 | 关闭所有的运行程序并且重新启动系统 |
该文件描述了启动或者运行时运行那些程序。
id:3:initdefault:
标识符为 id,级别是 3,initdefault 表示系统启动后默认进入级别,最后是空的表示什么都不做。
SystemV 的优点是:概念简单,易于控制与排除。
SystemV 的缺点:串行执行,效率低,启动慢。
▶ upstart
upstart 技术的出现起源于 Linux桌面系统 和 嵌入式 环境的需求,与服务器不同,桌面的设备、便携式的设备需要频繁的启动、热插拔技术,现在的计算机硬件比较多,物理接口是有限的,所以人们不是把所有的设备都初始连接到计算机上,比如 `U盘。
对Linux内核来说,一旦外部设备连接到系统内核就能初始化设备,这就给便携式的设备提高了灵活性。
上面的情况对于 SystemV 来说,这些需要被初始化的设备并没有连接到计算机上, SystemV 没有能力初始化这些设备, SystemV 只能一次性将所有的服务都开启,服务都需要一直启动。
于是就有了 upstart 这种基于事件的机制,比如将 U盘 插入接口,这样内核就知道了新的设备,这就是一个新的事件,upstart 会感知这些事件。
由于是采用了事件驱动,所以就能 即插即用硬件设备的问题,同时 upstart 支持并行启动,这也就 加快了机器启动的时间。

浙公网安备 33010602011771号