In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
CentOS system startup process
Components of the Linux system
Components of Linux system: kernel + root file system
Kernel: process management, memory management, network protocol stack, file system, driver, security functions
Kernel design genre:
Single kernel design: integrate all functions into one program
Microkernel design: each function is implemented using a separate subsystem
Linux kernel features: support modularization: .ko (kernel object)
Support dynamic loading or unloading of modules at runtime
Components:
Core file: / boot/vmlinuz-VERSION-release
Ramdisk:CentOS 5:/boot/initrd-VERSION-release.img
CentOS 6, 7, 7, 15, 5, 5, 7, 7, 7, 7, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
Module file: / lib/modules/VERSION-release
The running system environment can be divided into two layers: kernel space and user space.
User space: application (process or thread)
Kernel space: kernel code (system calls)
Startup process of CentOS system
1. Load the hardware information of BIOS and get the first boot device
two。 Read the boot information of the boot loader (grub) of the first boot device MBR
3. Load the core information of the core operating system, the core begins to decompress, and try to drive all the hardware devices
4. The core executes the init program and gets the default running information
5.init program execution / etc/rc.d/rc.sysinit file
6. Start the plug-in module of the core
7.init executes each batch file that runs (scripts)
8.init execution / etc/rc.d/rc.local
9. Execute the / bin/login program and wait for the user to log in
10. After logging in, the host is controlled by shell
Describe the startup process in detail
1.。 Load the hardware information of BIOS and get the first boot device:
POST, power-on self-test is a major part of BIOS function, which is responsible for the detection of CPU, motherboard, memory, hard disk subsystem, display subsystem, serial-parallel interface, keyboard and other hardware.
ROM:BIOS, which stores the most important basic input and output programs of the computer system, system information settings, power-on self-test program and system boot bootstrap, etc.
RAM:CMOS complementary metal oxide semiconductor to save the setting of various parameters
Find the boot device in order, and the first device with a boot program is the boot device.
Bootloader: boot loader, program
Windows:ntloader
Linux:
LILO:LIinux LOader
GRUB:Grand Uniform Bootloader
GRUB 0.X:Grub Legacy
GRUB 1.X:Grub2
Function: provides a menu that allows the user to select a system or a different kernel version to boot; load the user-selected kernel into a specific space in RAM, decompress, expand, and then transfer system control to the kernel
two。 Read the boot information of the boot loader (grub) of the first boot device MBR
MBR: first sector
First 446 bytes: bootloader
Middle 64 bytes: partition table
Last 2 bytes: 55AA
GRUB:
Bootloader:1st stage
Partition:filesystem driver, 1.5 stage
Partition:/boot/grub, 2nd stage
3. Load the core information of the core operating system, the core begins to decompress, and try to drive all the hardware devices
Kernel:
Self-initialization:
Detect all recognizable hardware devices
Load hardware driver
Mount the root file system read-only
Run the first application in user space: / sbin/init
Type of init program:
Centos5-:SysV int
Configuration file: / etc/inittab
Centos6:Upstart
Configuration file: / etc/inittab
/ etc/init/*.conf
CentOS 7:Systemd
Configuration file: / usr/lib/systemd/system/, / etc/systemd/system/
Ramdisk:
One of the features of the Linux kernel: using buffering and caching to speed up file access on disk
Ramdisk-- > ramfs
CentOS 5: initrd
Tool program: mkinitrd
CentOS 6,7: initramfs
Tool programs: dracut, mkinitrd
4. The core executes the init program and gets the default running information
Type of init program:
1.SysV: init, the slowest boot speed in CentOS 5 is due to the use of SysV init, which is characterized by starting user-space service programs, usually through scripts, and dependent services will be started serially.
(1) Operation level: a mechanism set for the purpose of operation or maintenance of the system.
0-6:7 level
0: shutdown, shutdown
1: single user mode (single user), root user, no authentication required; maintenance mode
2: multi-user mode (multi user), which starts the network function, but not the NFS; maintenance mode
3: multi-user mode (mutli user), fully functional mode; text interface
4: reservation level: there is no special purpose at present, but it is used to use the function at the same level 3.
5: multi-user mode (multi user), fully functional mode, graphical interface
6: restart, reboot
Default level: 3, 5
Level switching: init #
Level View:
Who-r
Runlevel
(2) configuration file: / etc/inittab
Each line defines an action and its corresponding process
Id:runlevels:action:process
Id: the identifier of a task
Runlevels: at which level to start this task; #, #, or empty, indicating all levels
Action: under what conditions to start this task
Process: task
Action:
Wait: execute once when waiting to switch to the level of this task
Respawn: once this task is terminated, restart it automatically
Initdefault: sets the default run level; at this point, process omits
Sysinit: sets the initialization mode of the system. The / etc/rc.d/rc.sysinit script is usually specified here.
2.Upstart: init,CentOS 6 # CentOS 6 boots faster than 5 because it uses the Upstart method, although the name you see is also init, but many mechanisms use the Upstart mechanism developed by ubuntu. The characteristic is that the communication between daemons depends on D-Bus, so it can basically achieve similar parallel startup.
Init program: upstart, but still / sbin/init, its configuration file:
/ etc/init/.conf, / etc/inittab (used only to define the default run level)
.conf is a upstart-style configuration file
3.Systemd: systemd, CentOS 7 # starts fastest in 7 because it uses Systemd, which is characterized by the fact that the service really starts only when it is accessed for the first time
Core concept: unit,unit is identified, identified and configured by its related configuration files, which mainly contain system services, monitored socket, saved snapshots and other init-related information
These configuration files are mainly saved in:
/ usr/lib/systemd/system
/ run/systemd/system
/ etc/systemd/system
Common types of unit:
Service unit: file extension .service, used to define system services
Target unit: the file extends to .target, which is used to simulate the implementation of "run level"
Device unit: .device, which defines the device recognized by the kernel
Mount unit: .mount, which defines the file system mount point
Socket unit: .socket, which is used to identify the socket file used for interprocess communication
Snapshot unit: .snapshot to manage system snapshots
Swap unit: .swap, used to identify swap devices
Automount unit: .automount, file system automatic point device
Path unit: .path, which defines a file or directory in the file system
Key features:
Activation Mechanism based on socket: separation of socket from Program
Activation mechanism based on bus
Activation mechanism based on device
Activation mechanism based on Path
System snapshot: saves the current state information of each unit in a persistent storage device
Backward compatibility with sysv init scripts; / etc/init.d/
Incompatible:
Systemctl's commands are fixed.
Systemctl cannot communicate with services that are not started by systemd
5.init program execution / etc/rc.d/rc.sysinit file
System initialization script: / etc/rc.d/rc.sysinit
(1) set the host name
(2) set welcome information
(3) activate udev and selinux
(4) Mount all file systems defined in the / etc/fstab file
(5) detect the root file system and remount the root file system in read-write mode
(6) set the system clock
(7) set kernel parameters according to / etc/sysctl.conf file
(8) activate lvm and soft raid devices
(9) activate swap device
(10) load drivers for additional devices
(11) cleanup operation
6. Start the plug-in module of the core
7init executes each batch file that runs (scripts)
After the initialization of the system / etc/rc.d/rc.sysinit, the system can work normally, but the services needed for startup are still missing, so that the host can provide some functions we need, such as network services, dhcp services and so on. Here, it is configured through l3:3:wait:/etc/rc.d/rc 3 mentioned in inittab. In fact, all the linked files under / etc/rc.d/rc3.d/ are used to decide how to start or shut down the service. Everything that begins with S is started by passing the start parameter, and all those that start with K are stopped by passing the stop parameter. All linked files under / etc/rc.d/rc3.d/ are all scripts under / etc/init, and these scripts must accept at least four basic parameters. {start | stop | status | restart} means to start or shut down the service controlled by the service script in the / etc/rc.d/rc3.d/ directory. The dependent service shuts down first, and then the dependent service; slots: the service to be started; the smaller the number, the higher the priority; the dependent service starts first, and the dependent service starts later; rc script: accepts a run-level number as a parameter / etc/init.d/* (/ etc/rc.d/init.d/*) script execution mode: / etc/init.d/SRV_SCRIPT {start | stop | restart | status} service SRV_SCRIPT {start | stop | restart | status} chkconfig command: control / etc/init.d/ the startup or shutdown status of each service script at all levels View: chkconfig-- list [name] add: chkconfig-- one of the script definition formats for add name services that can be added: #! / bin/bash # # chkconfig: LLL NN NN # description: delete: chkconfig-- del name modify the specified link type: chkconfig [--level LEVELS] name-- level LEVELS: specify the level to be controlled The default is 2345
8.init execution / etc/rc.d/rc.local
Note: at a normal level, the last service S99local started is not linked to a script under / etc/init.d, but to / etc/rc.d/rc.local (/ etc/rc.local) script; therefore, when a program that is inconvenient or does not need to be written as a service script expects to boot and run automatically, it can be placed directly in this script file.
/ etc/rc.d/rc.local runs after the specified run-level script
You can make custom modifications according to the situation.
9 execute / bin/login program and wait for the user to log in
10 starting to control the host with Shell after logging in
CentOS 6 startup process: POST-- > Boot Sequence (BIOS)-- > Boot Loader-- > Kernel (ramdisk)-- > rootfs-- > switchroot-- > / sbin/init-- > (/ etc/inittab, / etc/init/*.conf)-- > Don't set the default run level-- > system initialization script rc.sysinit-- > shut down or start the corresponding level of service-- > start the terminal.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.