In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you the detailed introduction of init and systemd under linux. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Early init management mechanism
When centOS6, the service management mechanism of init is still adopted. I'll introduce it a little bit here, because there are some things that can be used in centOS7. Mainly look at the following characteristics:
Start, shut down and status check of the service
Start the service: / etc/init.d/nginx start
Restart the service: / etc/init.d/nginx restart
Shut down the service: / etc/init.d/nginx stop
Status View: / etc/init.d/nginx status
Service startup mode
Start independently: most services adopt this mode, such as mysqld, php-fpm, nginx, httpd and so on.
Started by super daemon hosting: the startup of these services is hosted by another service, and the service hosting these services is called super daemon. The common supuer daemon are inetd and xinetd.
Executive level
There are seven execution levels on linux, which are 0, 1, 2, 3, 4, 5, and 6, respectively. The commonly used ones are
1 single maintenance mode
3 plain text mode
5 graphic mode
The startup scripts for each execution level are linked to / etc/init.d/daemon through / etc/rc [0-6] .d / SNNdaemon.
Ll / etc/rc3.d/S55nginx lrwxrwxrwx 1 root root 15 Sep 21 11:30 / etc/rc3.d/S55nginx->.. / init.d/nginx
S means to start, and NN means numbers, which indicate the order in which the script is executed, and the smaller the number, the first to be executed. This order of execution can well manage the dependency relationships of services.
Boot self-booting service
Boot self-boot: chkconfig on deamon
Turn it off and start it on: chkconfig off deamon
Check whether the service has been started: chkconfig-- list daemon
Systemd management mechanism
Since centos7, the previous init management mechanism has been abandoned and systemd has been used instead. Let's take a look at how systemd management is different.
Parallel processing of all services to speed up the boot process.
Unlike init to start a service, systemd can start many services at the same time. Therefore, this will greatly speed up the boot and wait for the opportunity.
Address service dependency
For example, to start B service, you must start A service first. At this time, use systemd to start B service, it will automatically check for dependencies, and then start A service before starting B service.
Unit Typ
Compared with stand alone and super daemon, which have only two startup modes in init, systemd defines a unified service unit (unit), and unit is divided into: service, socket, target, path, snapshot, timer and other types.
Downwards compatible service scripts for init
The old / etc/inid.d/ service startup script can also be managed through systemd. Note: if you start the service startup script in the / etc/init.d directory manually, systemd cannot detect the health of the service.
# systemctl status mysqld ● mysqld.service-LSB: start and stop MySQL Loaded: loaded (/ etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (running) since Wed 2020-10-28 13:26:53 CST; 1 weeks 5 days ago. # / etc/init.d/mysqld restartShutting down MySQL.... [OK] Starting MySQL. [OK] [root@lijia ~] # systemctl status mysqld ● mysqld.service-LSB: start and stop MySQL Loaded: loaded (/ etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (exited) since Wed 2020-10-28 13:26:53 CST; 1 weeks 5 days ago.
With regard to init and systemd, we need to focus on systemd, and we also need to understand init.
Thank you for reading! This is the end of the detailed introduction of init and systemd under linux. I hope the above content can help you to some extent, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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.