当前位置:网站首页>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 !
边栏推荐
- 《opencv学习笔记》-- 感兴趣区域(ROI)、图像混合
- Multi gate mixture of experts and code implementation
- Deep learning ~11+ a new perspective on disease-related miRNA research
- Beauty of script │ VBS introduction interactive practice
- 12+!不同癌症中TMB与ICI反应之间的免疫相关因素研究
- Understanding of homogeneous coordinates
- Linker --- linker
- Embedded must learn! Detailed explanation of hardware resource interface - based on arm am335x development board (Part 2)
- Nacos source code - configure automatic update
- Example of PHP observer mode [useful in the laravel framework]
猜你喜欢

Qt: judge whether the string is in numeric format
![[go language questions] go from 0 to entry 4: advanced usage of slice, elementary review and introduction to map](/img/7a/16b481753d7d57f50dc8787eec8a1a.png)
[go language questions] go from 0 to entry 4: advanced usage of slice, elementary review and introduction to map

TP-LINK 1208路由器教程(2)

计组-总复习

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

软件测试 对前一日函数的基本路径测试

ArrayList # sublist these four holes, you get caught accidentally

Insurance app aging service evaluation analysis 2022 issue 06

Install Kali on the U disk and persist it

《opencv学习笔记》-- 感兴趣区域(ROI)、图像混合
随机推荐
电商红包雨是如何实现的?拿去面试用(典型高并发)
Axi low power interface
Beauty of script │ VBS introduction interactive practice
ArrayList # sublist these four holes, you get caught accidentally
《opencv学习笔记》-- 离散傅里叶变换
Chenglixin research group of Shenzhen People's hospital proposed a new method of multi group data in the diagnosis and prognosis analysis of hepatocellular carcinoma megps
d的10个0符
5 points + single gene pan cancer pure Shengxin idea!
TP-LINK 1208路由器教程(2)
Go basic series | 4 Environment construction (Supplement) - gomod doubts
11+的基于甲基化组和转录组综合分析识别葡萄膜黑色素瘤中新的预后 DNA 甲基化特征~
"Meng Hua Lu" is about to have a grand finale. It's better to learn it first than to look ahead!
计组-总复习
深度学习~11+高分疾病相关miRNA研究新视角
哪个商业保险养老险好?2022年商业养老保险产品排名
《opencv学习笔记》-- 矩阵归一化 normalize()函数
5分+的单基因泛癌纯生信思路!
【206】使用php语言去生成go语言的代码
How to export only the titles in word documents? (i.e. delete all the text contents and keep only the title) stop B
How to develop mRNA vaccine? 27+ pancreatic cancer antigen and immune subtype analysis to tell you the answer!