当前位置:网站首页>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)、图像混合
- 不用做实验的6分+基因家族纯生信思路~
- 《opencv学习笔记》-- 图像的载入和保存
- 11+! Methylation modification patterns based on m6A regulatory factors in colon cancer are characterized by different tumor microenvironment immune spectra
- GLOG从入门到入门
- 《梦华录》要大结局了,看超前点映不如先来学学它!
- 打新债的条件 开户是安全的吗
- 《opencv学习笔记》-- CV::Mat类
- 怎么申请打新债 开户是安全的吗
- [digital ic/fpga] booth multiplier
猜你喜欢

我真傻,招了一堆只会“谷歌”的程序员!
![[live review] battle code pioneer phase 7: how third-party application developers contribute to open source](/img/fa/e52bd8a1a404a759ef6ba88e8da0f0.png)
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source

ArrayList # sublist these four holes, you get caught accidentally

@Requestbody annotation

Ten thousand campus developers play AI in a fancy way. It's enough to see this picture!
[Old Wei makes machines] issue 090: keyboard? host? Full function keyboard host!

Axi low power interface

Tools and methods - use code formatting tools in source insight

AXI低功耗接口

工具及方法 - 在Source Insight中使用代码格式化工具
随机推荐
Programmers spend most of their time not writing code, but...
How is the e-commerce red envelope realized? For interview (typical high concurrency)
The idea of "6 points + gene family" without experiment~
The latest hot spot: the use of copper death related genes for tumor prognosis typing!
How to open a new bond? Is it safe to open an account
GLOG from getting started to getting started
数据标注科普:十种常见的图像标注方法
[digital ic/fpga] booth multiplier
Install Kali on the U disk and persist it
@Requestbody annotation
Libuv的安装及运行使用
About the unsupported instruction set SSE 4.2 of CPU in virtualization
Opencv optical flow prediction and remap remapping function usage
Popular science of data annotation: ten common image annotation methods
我真傻,招了一堆只会“谷歌”的程序员!
8 types of API automated testing that technicians must know
Variable parameter template implements max (accepts multiple parameters, two implementation methods)
What code did the full stack programmer write this month?
怎样申请打新债 开户是安全的吗
程序员大部分时间不是写代码,而是。。。