linux boot process and service control

1, the system boot process

 

 

(1)BIOS( Basic Input Output System )

  • After the boot server host, according to the settings on the motherboard BIOS CPU (Central ProcessingUhit central processing unit),
  • Memory card, keyboard and other equipment for preliminary testing, testing has been successfully handed over control of the system according to the preset startup sequence, most of the time will be handed over to the local hard disk.
  • Detecting failure typically by an alarm buzzer or a display screen pedicle.

 

Basic Input Output System main functions:

  1. BIOS storage hardware configuration information,
  2. CPU virtualization switch,
  3. The system boot sequence,
  4. Time host hardware (BIOS separate battery, the battery power of no effect, a host of time allowed, will not affect the system boot, but the hardware part of the configuration information is lost, BIOS will restore factory settings)
  5. BIOS battery discharge is factory set to recover
  • Power On Self Test
  • Hardware initialization
  • Booting the Operating System

(2) MBR boot
  when the machine is started in the system from the hard disk, the first (master boot record Master Boot Record) The MBR of the hard disk sector is provided, the system passes control to the operating system partition contains the boot file (/ boot);

  Or directly in the MBR boot record information boot menu call (e.g. GRUB).

(3) GRUB menu
  For Linux operating systems, GRUB (GRand Unified Bootloader. System boot loader) is the most widely used multi-system boot program.

  After the transfer system control to GRUB, the boot menu will be displayed to the user selected, and depending on the option (or default value) to load the Linux kernel files, then the system control to the kernel.

  Note that, CentOS 7 uses GRUB2 boot loader.

(4) to load Linux kernel
  Linux kernel is a special pre-compiled binary files between various hardware and system resources between programs. Responsible for resource allocation and scheduling.

  After the kernel took control of the system, we will have complete control over the entire process of running the Linux operating system.

  In CentOS system, the default kernel file is located in "/bootvmlinuz-3.10.0-514.el7.x86_ 64".

(5) init process initialization

  In order to further the system boot process, Linux kernel first system in the / sbin / init program is loaded into memory to run (running program called process), init process is responsible for system initialization. Finally, waits for the user to log in

2, the guide system level (0-6)

  • 0: off state, using this level will host closed
  • 1: single-user mode, you can log in without a password verification system for system maintenance
  • 2: character-based interface, multi-user mode (does not support access network) [rarely used]
  • 3: Full multi-user mode interface characters, most servers run at this level
  • 4: Unassigned used (power saving mode)
  • 5: Multi-user mode graphical interface provides a graphical desktop environment
  • 6: reboot, reboot the host will use this level

3, init process

  By the linux kernel load and run / sbin / init program

  The first process is the system, the parent of all processes

  PID (process mark) is always No. 1

4, guide level view and switch

  View run level: runlevel command

  Temporary switching the operating level: using the command init run levels 0-6 combined parameters

5, Service Control

(1) Method used:

  • /etc/rc.d/init.d/ name control service type (/etc/init.d/ is a shortcut to the /etc/rc.d/init.d/) [This method is recommended above]
  • Service Name service control type [This method is only described for Red Hat Linux system and centos, Unix systems do not support]

(2) Common control type

  • start start
  • stop stop
  • restart restart
  • status View status
  • reload smooth restart, without stopping the service [common]

6, the service start-up optimization

(1) ntsysv tool

  • Providing an interactive visualization window
  • You can run on an ASCII terminal.
  • Facilitate collective management of multiple services

(2) chkconfig tool

  • It does not provide an interactive visualization window
  • Single service management more efficient

      format:

  • chkconfig --list
  • chkconfig --list service name
  • chkconfig --level 级别列表 服务名 on|off (不指定级别时,默认 2345)

7、常见的系统服务

  1. Redhat Linux 操作系统下常用服务介绍
  2. aep1000 挂载或卸载 aep1000/2000 协处理器驱动的。
  3. anacron 不过可以在指定时间没有开机无法完成任务的情况下另寻时间完成任务。
  4. Apmd 高级电源管理能源管理服务,可以为你监控电池
  5. Arpwatch 记录日志并构建一个在 LAN 接口上看到的以太网地址和 IP 地址对数据库
  6. Atd 用于 at 和 batch 的服务 atd 类似 cron,提供在指定的时间做指定的事的服务,就象计划任务
  7. Autofs 自动安装管理进程 automount,与 NFS 相关,依赖于 NIS(autofs自动挂载/卸载文件系统服务,可以自动挂载你想访问但还为挂载的文件系统,自动卸载长期不访问的文件系统。)
  8. bcm5820 提供对 CryptoNetX SSL Accelerator 适配器(用来处理 SSL 密钥的设备)的支持。
  9. Crond 为 Linux 下自动安排的进程提供运行服务.
  10. Gpm 提供字符模式下对鼠标的支持.
  11. Cups UNIX 通用打印系统
  12. cups-lpd 支持用 LPD 协议跑 CUPS
  13. daytime 获取并显示系统时间用的
  14. daytime-udp udp 版的 daytime
  15. echo 输出字符到客户端的
  16. finger 用来查询系统内用户信息
  17. firstboot 故名思意,安装完后第一次启动时跑的脚本,在第二次启动就不在运行了
  18. imap 为邮件提供 imap 服务
  19. imaps 为客户端提供 SSL 加密后的 imap 服务
  20. ipop2 提供 POP2 服务,
  21. ipop3 pop3 大名鼎鼎的 
  22. iptables 2.4 内核默认的防火墙
  23. irda 红外线传输支持
  24. netfs 提供网络文件系统(NSF,SMB,NCP)挂载/卸载的。
  25. Keytable 用于装载键盘镜像
  26. Kudzu 硬件探测器
  27. Netfs 安装和卸载 NFS、SAMBA 和 NETWARE 网络文件系统
  28. Network 激活已配置网络接口的脚本程序
  29. Nfslock NFS 锁定
  30. Pcmcia 安装 pcmcia 卡(一般用于笔记本电脑)
  31. Sshd OpenSSH 服务器
  32. Syslog 一个让系统引导时启动 syslog 和 klogd 系统日志守候里程的脚本
  33. Xfs Xwindow 字型服务器,为本地和远程 X 服务器提供字型集
  34. Xinetd 支持多种网络服务的核心守候程序。
  35. Kudzu 检测硬件变化的
  36. Mysqld Mysql database server
  37. Named BIND 域名服务
  38. Netfs 提供网络文件系统(NSF,SMB,NCP)挂载/卸载的
  39. Network 激活/关闭网络设备的
  40. Nfs (NFS)network filesystem 服务
  41. Nfslock 提供一种 NFS 的权限设置
  42. Ntalk 可以让不同用户在系统上一起聊天的
  43. Ntpd 网络时间协议 NTP(Network Time Protocol)和网络上同步时间用的
  44. Pops 提供 SSL 加密的 pop3
  45. Portmap 端口映射,很多网络服务需要此服务
  46. Rexec 远程执行命令时提供用户验证
  47. Rhnsd redhat 的网络服务,可以自动检查软件的升级
  48. rlogin 提供远程登录服务
  49. rsh 远程执行 linux 命令服务
  50. rsyn 高效的网络远程备份和镜象工具
  51. sendmail 赫赫有名的邮件服务器,(用来发匿信的好东东:) )
  52. servers 监听被激活的服务用的
  53. sgi_fam 检测文件变化的
  54. smb 提供 samba 服务的
  55. snmp 简单网络管理服务
  56. snmptrapd 也是网络管理的
  57. squid web 代理服务器
  58. sshd 提供 sshd 登录
  59. svscan daemontools 的一部分,用来管理后台服务
  60. syslogd 日志服务,很重要的服务
  61. tux 集成内核的 web 服务工具
  62. vsftpd 一个 ftp 服务端,以安全著称
  63. winbind smb 服务中解析来自 NT 服务器名字的
  64. xinetd 超级服务器的 Inetd 的替代者,提供很多服务,非常重要。
  65. Yppasswdd nis 服务中提供 NIS 用户验证服务
  66. random 当系统需要时会,产生随机数。关闭对大多数系统没什么大的影响,服务器不要轻易

 

 

(1)BIOS( Basic Input Output System )

  • 服务器主机开机以后,将根据主板BIOS中的设置对CPU (Central ProcessingUhit中央处理器) ,
  • 内存显卡,键盘等设备进行初步检测,检测成功后根据预设的启动顺序移交系统控制权,大多时候会移交给本机硬盘。
  • 检测失败通常会通过显示器屏蒂或者蜂鸣器报警。

 

基本输入输出系统主要功能:

  1. BIOS存储硬件的配置信息,
  2. CPU虚拟化开关,
  3. 系统的引导顺序,
  4. 主机硬件时间( BIOS独立的电池、电池没电的效果,主机的时间不准,不会影响系统引导,但是硬件的部分配置信息会丢失,BIOS会恢复出厂设置)
  5. BIOS电池放电也是为恢复出厂设置
  • 加电自检
  • 硬件初始化
  • 引导操作系统

(2)MBR引导
  当从本机硬 盘中启动系统时,首先根据硬盘第个扇区中MBR (Master Boot Record主引导记录)的设置, 将系统控制权传递给包含操作系统引导文件的分区( /boot) ;

  或者直接根据MBR记录中的引导信息调用启动菜单(如GRUB)。

(3)GRUB菜单
  对于Linux操作系统来说, GRUB (GRand Unified Bootloader.统启动加载器) 是使用最为广泛的多系统引导器程序。

  系统控制权传递给GRUB以后,将会显示启动菜单给用户选择,并根据所选项(或采用默认值)加载Linux内核文件,然后将系统控制权转交给内核。

  需要注意的是, CentOS 7采用的是GRUB2启动引导器。

(4)加载Linux内核
  Linux内核是一个预先编译好的特殊二进制文件 ,介于各种硬件资源与系统程序之间.负责资源分配与调度。

  内核接过系统控制权以后,将完全掌控整个Linux操作系统的运行过程。

  在CentOS系统中,默认的内核文件位于"/bootvmlinuz-3.10.0-514.el7.x86_ 64".

(5)init进程初始化

  为了进一步的系统引导过程,Linux内核首先将系统中的/sbin/init程序加载到内存中运行(运行中的程序称为进程),init进程负责系统初始化过程。最后等待用户进行登录

2、系统引导级别(0-6)

  • 0:关机状态,使用该级别时将会关闭主机
  • 1:单用户模式,无需密码验证即可登录系统,用于系统维护
  • 2:字符界面的多用户模式(不支持访问网络)【很少使用】
  • 3:字符界面的完整多用户模式,大多数服务器运行在此级别
  • 4:未分配使用(省电模式)
  • 5:图形界面的多用户模式,提供了图形桌面操作环境
  • 6:重新启动,使用该级别时将会重启主机

3、init 进程

  由 linux 内核加载运行/sbin/init 程序

  是系统中的第一个进程,所有进程的父进程

  PID(进程标记)号永远为 1

4、引导级别查看及切换

  查看运行级别:runlevel 命令

  临时切换运行级别:使用 init 命令结合 0-6 运行级别参数

5、服务控制

(1)常用方法:

  • /etc/rc.d/init.d/ 服务名称 控制类型(/etc/init.d/ 是/etc/rc.d/init.d/的快捷方式)【推荐使用此述方法】
  • service 服务名称 控制类型【此述方法仅用于 Linux 的红帽系统及 centos,Unix 系统不支持】

(2)常用控制类型

  • start 启动
  • stop 停止
  • restart 重启
  • status 查看状态
  • reload 平滑重启,无需停止服务【常用】

6、服务开机启动优化

(1)ntsysv 工具

  • 提供一个交互式、可视化窗口
  • 可以在字符终端运行
  • 便于集体管理多个服务

(2)chkconfig 工具

  • 不提供交互式、可视化窗口
  • 管理单个服务效率更高

      格式:

  • chkconfig --list
  • chkconfig --list 服务名称
  • chkconfig --level 级别列表 服务名 on|off (不指定级别时,默认 2345)

7、常见的系统服务

  1. Redhat Linux 操作系统下常用服务介绍
  2. aep1000 挂载或卸载 aep1000/2000 协处理器驱动的。
  3. anacron 不过可以在指定时间没有开机无法完成任务的情况下另寻时间完成任务。
  4. Apmd 高级电源管理能源管理服务,可以为你监控电池
  5. Arpwatch 记录日志并构建一个在 LAN 接口上看到的以太网地址和 IP 地址对数据库
  6. Atd 用于 at 和 batch 的服务 atd 类似 cron,提供在指定的时间做指定的事的服务,就象计划任务
  7. Autofs 自动安装管理进程 automount,与 NFS 相关,依赖于 NIS(autofs自动挂载/卸载文件系统服务,可以自动挂载你想访问但还为挂载的文件系统,自动卸载长期不访问的文件系统。)
  8. bcm5820 提供对 CryptoNetX SSL Accelerator 适配器(用来处理 SSL 密钥的设备)的支持。
  9. Crond 为 Linux 下自动安排的进程提供运行服务.
  10. Gpm 提供字符模式下对鼠标的支持.
  11. Cups UNIX 通用打印系统
  12. cups-lpd 支持用 LPD 协议跑 CUPS
  13. daytime 获取并显示系统时间用的
  14. daytime-udp udp 版的 daytime
  15. echo 输出字符到客户端的
  16. finger 用来查询系统内用户信息
  17. firstboot 故名思意,安装完后第一次启动时跑的脚本,在第二次启动就不在运行了
  18. imap 为邮件提供 imap 服务
  19. imaps 为客户端提供 SSL 加密后的 imap 服务
  20. ipop2 提供 POP2 服务,
  21. ipop3 pop3 大名鼎鼎的 
  22. iptables 2.4 内核默认的防火墙
  23. irda 红外线传输支持
  24. netfs 提供网络文件系统(NSF,SMB,NCP)挂载/卸载的。
  25. Keytable 用于装载键盘镜像
  26. Kudzu 硬件探测器
  27. Netfs 安装和卸载 NFS、SAMBA 和 NETWARE 网络文件系统
  28. Network 激活已配置网络接口的脚本程序
  29. Nfslock NFS 锁定
  30. Pcmcia 安装 pcmcia 卡(一般用于笔记本电脑)
  31. Sshd OpenSSH 服务器
  32. Syslog 一个让系统引导时启动 syslog 和 klogd 系统日志守候里程的脚本
  33. Xfs Xwindow 字型服务器,为本地和远程 X 服务器提供字型集
  34. Xinetd 支持多种网络服务的核心守候程序。
  35. Kudzu 检测硬件变化的
  36. Mysqld Mysql database server
  37. Named BIND 域名服务
  38. Netfs 提供网络文件系统(NSF,SMB,NCP)挂载/卸载的
  39. Network 激活/关闭网络设备的
  40. Nfs (NFS)network filesystem 服务
  41. Nfslock 提供一种 NFS 的权限设置
  42. Ntalk 可以让不同用户在系统上一起聊天的
  43. Ntpd 网络时间协议 NTP(Network Time Protocol)和网络上同步时间用的
  44. Pops 提供 SSL 加密的 pop3
  45. Portmap 端口映射,很多网络服务需要此服务
  46. Rexec 远程执行命令时提供用户验证
  47. Rhnsd redhat 的网络服务,可以自动检查软件的升级
  48. rlogin 提供远程登录服务
  49. rsh 远程执行 linux 命令服务
  50. rsyn 高效的网络远程备份和镜象工具
  51. sendmail 赫赫有名的邮件服务器,(用来发匿信的好东东:) )
  52. servers 监听被激活的服务用的
  53. sgi_fam 检测文件变化的
  54. smb 提供 samba 服务的
  55. snmp 简单网络管理服务
  56. snmptrapd 也是网络管理的
  57. squid web 代理服务器
  58. sshd 提供 sshd 登录
  59. svscan daemontools 的一部分,用来管理后台服务
  60. syslogd 日志服务,很重要的服务
  61. tux 集成内核的 web 服务工具
  62. vsftpd 一个 ftp 服务端,以安全著称
  63. winbind smb 服务中解析来自 NT 服务器名字的
  64. xinetd 超级服务器的 Inetd 的替代者,提供很多服务,非常重要。
  65. Yppasswdd nis 服务中提供 NIS 用户验证服务
  66. random 当系统需要时会,产生随机数。关闭对大多数系统没什么大的影响,服务器不要轻易

Guess you like

Origin www.cnblogs.com/wangyuiming/p/11441296.html