In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge of what the method of Linux system startup and service management is. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
1. Preface
server rarely restarts during normal operation, but if there is an unknown failure or human misoperation, abnormal startup may occur. Although the startup process of Linux system is a relatively low-level knowledge, this article is summarized in order to deepen the understanding of Linux system.
2. Linux system startup process
2.1 post
After the mainframe of the server is booted, the CPU, memory, graphics card, hard disk and other devices will be initially tested according to the settings in the motherboard BIOS. After successful detection, the control of the system will be transferred according to the preset boot sequence, and will be handed over to the local hard disk most of the time.
2.2 MBR Boot
When boots the system from the local hard disk, it first transfers the system control to the partition containing the operating system boot file according to the setting of MBR (master boot record) in the first sector of the hard disk, or invokes the boot menu (such as GRUB) directly according to the boot information in the MBR record.
2.3 GRUB menu
for Linux operating system, GRUB (Unified Boot Loader) is the most widely used multi-system bootstrap program. After system control is passed to GRUB, a boot menu will be displayed for the user to choose, and the Linux kernel file will be loaded according to the selected option (or default), and then system control will be transferred to the kernel. It is important to note that Centos7 uses the GRUB2 boot loader.
2.4 load the Linux kernel
Linux kernel is a pre-compiled special binary file, which is between various hardware resources and system programs, and is responsible for resource allocation and scheduling. After the kernel takes over the control of the system, it will completely control the running process of the entire Linux operating system.
On CentoS systems, the default kernel file is located in "/ boot/vmlinuz-3.10.0-514.el7.x86_64".
2.5 init process initialization
in order to complete the further system boot process, the Linux kernel first loads the "/ sbin/init" program in the system to run in memory, and the init process is responsible for completing a series of system initialization processes, and finally waiting for the user to log in.
2.6 Summary of system startup process
Detected the first device capable of booting the system, such as a hard drive or optical drive
Run the startup GRUB bootstrap program placed in the MBR sector
The GRUB bootstrapper reads the GRUB configuration file / boot/grub2/grub.cfg to get the kernel and image file system settings and path locations
Load the kernel and image file system into memory
Load the hardware driver, and the kernel loads the init process into memory to run
3. Init process and systemd3.1 init process
/ sbin/init program is loaded and run by the Linux kernel
The init process is the first process in the system
The PID number of the init process is always 1
[root@c7-1] # ll / sbin/initlrwxrwxrwx. 1 root root 22 August 13 21:44 / sbin/init->.. / lib/systemd/systemd3.2 Centos5/6/7 init process comparison
3.3 systemd
Systemd is an init software of Linux operating system.
A new systemd startup mode is adopted in CentOS7 to replace the traditional SysVinit.
The first init process running in CentOS7 is / lib/systemd/systemd
[root@c7-1] # ps-efUID PID PPID C STIME TTY TIME CMDroot 1 00 August 15-00:00:31 / usr/lib/systemd/systemd-- switched-root-- system-- deserialize 22root 2 00 August 15-00:00:00 [kthreadd] root 4 20 August 15-00:00:00 [kworker/0: 0H] root 6 20 August 15-00:00:00 [ksoftirqd/0] root 7 20 August 15-00:00:00 [migration/0] .3.4 systemd Unit Type Unit Type extension description Service.service describes a system service Socket.socket describes an interprocess communication socket Device.device describes a kernel-recognized device File Mount.mount describes the mount point of a file system Automount.automount describes the automatic mount point of a file system Swap.swap describes a memory swap device or swap file Path.path describes a file or directory in a file system Timer.timer describes a timer (used to implement cron-like scheduling tasks) Snapshot.snapshot is used to save the state of an systemd Scope.scope uses systemd's bus interface to program The way to create external processes Slice.slice describes a group of management system processes that reside in Cgroup through hierarchical organization Target.target describes a set of systemd unit 3.5 run level corresponding to systemd target run level systemd target description 0target shutdown status Using this level turns off the host 1rescue.target single-user mode and allows you to log in to the system without password authentication, mostly for system maintenance of 2multi-user.target user-defined / domain-specific runlevels. The default is equivalent to the full multi-user mode of the 33multi-user.target character interface, at which most server hosts run at the 4multi-user.target user-defined / domain-specific run level. The default is equivalent to the multi-user mode of the 35graphical.target graphical interface, which provides a graphical desktop operating environment 6reboot.target restart, which will restart the host 3.6systemd management command systemctl.
Format:
Systemctl COMMAND name.service # .service can also be omitted
Comparison of Sysvinit and Systemd commands
Sysvinit command Systemd command meaning service name startsystemctl start name startup service service name stopsystemctl stop name shutdown service service name restartsystemctl restart name restart service regardless of whether the current startup or shutdown status service name reloadsystemctl reload name reloads service configuration information without interrupting the service service name condrestartsystemctl condrestart name running state services can be restarted Unable to restart the running status of the service name statussystemctl status name viewing service while not in running state the chkconfig name onsystemctl enable name setting service for boot self-startup chkconfig name offsystemctl disable name setting service for boot shutdown chkconfig namesystemctl is-enabled name check whether the service is boot self-boot chkconfig name-addsystemctl daemon-reload to create a new service file, or to use when changing configuration
Example:
# start httpd service systemctl start httpd# stop httpd service systemctl stop httpd# restart httpd service systemctl restart httpd# check httpd service status systemctl status httpd# disable automatic and manual startup of services (running services can be shut down) systemctl mask name.service# cancel disable systemctl unmask name.service# check whether a service is currently running systemctl is-active name.service# view all services systemctl list-unit-files-- type=service# view all already Activated service systemctl list-unit-files-- type=service | grep enabled# lists the services that failed to start systemctl-- failed-- type=service or systemctl list-units-- state failed or systemctl list-unit-files-- state=failed# to start the httpd service and set the boot systemctl enable-- now httpd.service# shuts down the httpd service and closes the boot systemctl disable-- now httpd.service# view service dependencies systemctl list-dependencies name.service# kills the process systemctl kill Unitname above is all the content of the article "what is the method of Linux system startup and service management?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.