当前位置:网站首页>Cluster control management
Cluster control management
2022-06-24 12:03:00 【Hua Weiyun】
Current Linux There are two mainstream init The way : One is widely spread System V initialization, It comes from Unix And it is still used by all kinds of Linux Adopted by ; The other is proposed in recent years Upstart The way , Based on the event mechanism , All services of the system , Tasks are event driven . as far as I am concerned , At present, there are Ubuntu(6.10 and later),Fedora(9.10 and later),Debian(optional). Although Upstart There are not many distributions of , But it is designed to replace the old style System V initialization.
Sort out as knowledge , I will now summarize the initialization processes of these two methods , This is also for the convenience of sorting out ideas :
I was looking for Linux System init You can always see relevant information about the process inittab The figure of , But in my Ubuntu There is no such file on , Only later did I know that Upstart The way of Ubuntu There was no inittab Of this file . In the old style System V initialization in ,/etc/inittab It's a very important document .init The first thing to look for after the process is started !inittab Responsible for initializing the system , Set up the system runlevel Ji Jin Enter each runlevel Corresponding to the command to be executed . Assuming the current inittab The default value set in runlevle yes 5, be init Will run /etc/init.d/rc 5 command , This command will traverse and execute according to the dependencies of system services /etc/rc5.d The script in the / Program . Get into /etc/rc5.d You can find that the files in the directory are all to /etc /init.d/ Under the corresponding script / Soft links to programs . With S The beginning means to start , With K The beginning is stop . also S/K The last two digits represent the starting sequence of the service ( Determined by service dependencies ).
that Upstart job What is it like ? We know ,System V initializaiton In order to runlevel At the core , Based on the dependencies between services init The way , But in Upstart job,runlevel Although it also has an impact on service startup, it is not the key .Upstart job It's event driven , Start of system services 、 Stop and so on are all determined by events , In turn, , Start of system services 、 Stopping can also be used as an event source to trigger other services . And events don't have to be generated internally , Users can manually type start/stop [Service] Generate an event to start / Termination of services .man upstart-evnets see upstart job Events defined , You can find ,runlevel It is also treated as an event ( because runlevel A change of events ), And so on, and so forth startup,started,filesystem wait . How does the system service know when it should start , When did it end ? The answer is /etc /init in ( yes , we have distros May be in /etc/event.d). Get into /etc/init Take a look at the table of contents , Are configuration files of system services , Or say , yes job definition files.( actually Upstart init It only needs /etc/init Such a directory , Unlike System V init,“ Turn and wipe feet ” It takes many turns to reach the destination , It is inferior to the former in performance ). Open any file , such as cron.conf:
# cron - regular background program processing daemon
# cron is a standard UNIX program that runs user-specified programs at
# periodic scheduled times
description “regular background program processing daemon”
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
exec cron
I believe the sharp procedural apes have found :start on runlevel [2345];stop on runlevel [!2345]
you 're right , The configuration file is used to set when the service is started , When to terminate .
In fact, it's not just at the beginning of system startup , The service can be started or stopped by sending events at any time when the system is running . This is Upstart job One of the advantages of , Except for system initialization , It can also play a role in the system operation phase . by comparison System V initialization The configuration file in the mode is generally only used in the system initialization phase , Of course, during the system operation phase, we can pass /etc/init.d/Service start/stop/otherCommand To operate the service , But obviously not as good as Upstart The way is simple and clear .
good , Introduction after System V initialization and Upstart, So now we can introduce Ubuntu init System initialization process . I mentioned it earlier Ubuntu It uses Upstart The way of initialization, It's not all , in consideration of 6.10 Previous versions used System V init And the need for certain services ,Ubuntu The compatibility mode is adopted , namely : In the system, there are System V-style Services started , Also have Upstart Services started . If you're using Ubuntu14.04( I am currently PC System on ), Then you can see that there are several directories in the system :
/etc/init
/etc/init.d
/etc/rc${runlevel}.d
As two kinds init The way each has its own characteristics /etc/init.d,/etc/rc{runlevel}.d In the directory ,( and /etc/rc{runlevel}.d/ And go , It takes a compromise approach , adopt /etc/init Some configuration file calls under /etc/rc${runlevel}.d/ Script in to start using the old style System V-style Service for . alas , I think it's easy to say , See the example , Look below .
Get into /etc/init Catalog (Upstart init The configuration file will be read in this directory ), You will find a few rc About the configuration file :
rc.conf
rc-sysinit.conf
rcS.conf
rc-sysinit stay startup It is started when the event occurs ,rc In system runlevel It is activated when changing ,rcS In system runlevel by S( Service startup ) When to start . In the comments of the configuration file , These files , It is Upstart init Handle System V-style The key to service .
rc-sysinit stay startup It is started when the event occurs , namely ,Upstart init Will first read rc-sysinit.conf And execute relevant configurations and scripts .rc-sysinit.conf The main task of is to set the system default runlevel, Detect the presence of /etc/inittab Or kernel command line , If exist , Then press the kernel command line >/etc/inittab> Default runlevel Set up the system in sequence runlevel. Last , call telinit Enter the set runlevel.
Because the call telinit Entered the set runlevel,runlevel Changing events happen , here rc Service startup ( Of course, other services will also ). that , It is necessary for us to have a look rc.conf What the hell is in it . open rc.conf, Notice the last line :
exec /etc/init.d/rc $RUNLEVEL
Does it feel /etc/init.d/rc Familiar with , you 're right , stay System V initialization in ,/etc/inittab Each of runlevel The corresponding command line is set in this form .
Obviously ,/etc/init.d/rc Is called the , And it is transmitted to the system set up earlier runlevel As a parameter . and /etc/init.d/rc According to the incoming runlevel Parameter call /etc/rc${runlevel}.d/ Next script ( With S start ) To start the service , Terminate in the previous runlevel Started and currently in runlevel Services that need to be terminated . thus ,Ubuntu Handle System V-style Is the service process becoming clear . adopt rc-sysinit and rc Indirect call /etc/init.d/rc To start System V-style service ,Ubuntu In the adoption of new Upstart init Took care of the old style System V init.
use Upstart The services started in the mode are /etc/init/ There is a configuration file of its own in the directory , Input under terminal : initctl list ( View service ), See if the listed services are the same /etc/init/ The services under are exactly the same !
Shut down a service
#initctl stop
atd atd stop/waiting
PS: A lot of the above content is my personal understanding , The general direction should be right , But the understanding of the details is not guaranteed . Don't forget to give advice when you find out !
边栏推荐
- mRNA疫苗的研制怎么做?27+ 胰腺癌抗原和免疫亚型的解析来告诉你答案!
- 9+!通过深度学习从结直肠癌的组织学中预测淋巴结状态
- 巧妙构思-铁死亡调节因子分型预后发6+
- Group planning - General Review
- How is the e-commerce red envelope realized? For interview (typical high concurrency)
- 程序员大部分时间不是写代码,而是。。。
- Code is really - omnipotent! Refuse to fight
- Embedded must learn! Detailed explanation of hardware resource interface - based on arm am335x development board (Part 2)
- Oxylabs live online: website capture demo
- Jenkins performance test
猜你喜欢

AXI低功耗接口
![[digital ic/fpga] booth multiplier](/img/42/3da3b1d3cc82cb9c0694241148011b.png)
[digital ic/fpga] booth multiplier

保险APP适老化服务评测分析2022第06期

如何优雅的写 Controller 层代码?

程序员大部分时间不是写代码,而是。。。

How stupid of me to hire a bunch of programmers who can only "Google"!

u盘安装kali并且持久化

电商红包雨是如何实现的?拿去面试用(典型高并发)

How to develop hospital information system (his) with SMS notification and voice function

Linker --- linker
随机推荐
Realization of alarm clock with AHK
PHP SMS notification + voice broadcast automatic double call
Why choose b+ tree as storage engine index structure
[deep learning][pytorch][original]crnn trains loss on the higher version of pytorch as a solution for Nan
The idea of "6 points + gene family" without experiment~
2021-06-03: Boolean operation. Given a Boolean expression and an expected cloth
10 zeros of D
How to develop mRNA vaccine? 27+ pancreatic cancer antigen and immune subtype analysis to tell you the answer!
Introduction to C language circular statements (foe, while, do... While)
ArrayList#subList这四个坑,一不小心就中招
AXI低功耗接口
Qt: judge whether the string is in numeric format
New progress in the construction of meituan's Flink based real-time data warehouse platform
Jenkins performance test
GLOG from getting started to getting started
u盘安装kali并且持久化
I want 18K. Can I pass it?
打新债可以申请多少 开户是安全的吗
嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)
Using the collaboration database query of Poole in laravel5.6