Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux initialization init systems - Systemd     - Implement firewall function on a closed Linux machine (Linux)

- Oracle PLS-00231 error analysis (Database)

- The method of installing software under Ubuntu Linux (Linux)

- After installing minimize RHEL / CentOS 7 need to do some things (Linux)

- To learn linux security (Linux)

- VMware virtual machines to install virt-manager unable to connect to libvirt's approach (Linux)

- PHP loop reference caused strange problems (Programming)

- MySQL Tutorial: About checkpoint mechanism (Database)

- Linux Security trust with users (Linux)

- Getting Started with Linux system to learn: How do I know which processes are running on the CPU core (Linux)

- Linux data redirection (Linux)

- Apache Spark1.1.0 deployment and development environment to build (Server)

- Redhat Close SELinux correct step (Linux)

- Ubuntu server 8.04 Firewall Guide (Linux)

- MySQL EXPLAIN SQL output description (Database)

- Linux / UNIX: Use the dd command to create a 1GB size binary (Linux)

- Spring AOP (Programming)

- Programmers Do not neglect debugging techniques (Programming)

- History of the most complex validation e-mail address regular expression (Linux)

- vnStatSVG: traffic monitoring software vnStat (Linux)

 
         
  Linux initialization init systems - Systemd
     
  Add Date : 2017-08-31      
         
         
         
  In recent years, init process Linux system has undergone two major evolution of the traditional sysvinit been gradually fading out the stage of history, the new systemd UpStart and have their own characteristics, a growing number of Linux distributions adopted systemd. This article briefly describes the use of these three principles and init systems, each Linux system administrators and software developers should understand them in order to better manage their systems and developing applications. This article is part 3 of this series, it focuses on the characteristics and use of systemd.

Systemd profile and features

Systemd Linux system is the latest system initialization (init), its primary design goal was to overcome the inherent shortcomings sysvinit, improve the startup speed of the system. systemd and Ubuntu upstart competitors, is expected to replace UpStart, in fact, when the author of this writing, there have been news that Ubuntu will also use systemd as its standard system initialization system.

Many of the concepts derived from launchd Systemd Apple Mac OS operating system, but launchd dedicated to the Apple system, so long failed to get proper attention. Systemd launchd draw a lot of thought, it's important features are as follows:

With SysVinit and LSB init scripts compatible

Systemd is a "new" and many applications on Linux and have not had time for it to do the appropriate changes. And UpStart Like, systemd introduces a new configuration for application development, there are some new requirements. If you want an alternative systemd initialize the system currently in operation, it must be compatible with existing procedures. Any Linux distribution is very difficult to adopt systemd in a short time all services will modify the code again.

Systemd provided and Sysvinit and LSB initscripts compatible features. System already exists in the services and processes without modification. This reduces the cost of the system migration to systemd, making initialization systemd replace the existing system as possible.

Faster boot

Systemd provides more radical than UpStart Parallel start-up capability, using a socket / D-Bus activation technology start the service. An obvious result: faster boot.

To reduce boot time, systemd objectives are:

Start the process as much as possible less
The process started in parallel as much as possible more
Similarly, UpStart also trying to achieve both goals. UpStart event-driven mechanism, the service may temporarily start, only when needed by the event trigger its start, in line with the first design goals; moreover, irrelevant services can be started in parallel, which also achieved a second goal.

 UpStart respect SysVInit start to improve this aspect of concurrency:

Suppose there are seven different start-up projects, such as JobA, Job B and so on. In SysVInit, each project starts by a separate script is responsible, they consist sysVinit sequentially serially calls. Therefore, the total startup time is T1 + T2 + T3 + T4 + T5 + T6 + T7. Some of these tasks have dependencies, such as A, B, C, D.

The Job E and F and has A, B, C, D irrelevant. In this case, UpStart tasks can run concurrently {E, F, (A, B, C, D)}, so that the overall start-up time is reduced to T1 + T2 + T3.

It will increase the system starts parallelism, thereby improving the system boot speed. But UpStart, there are dependencies or service must have started. Tasks such as A, B, (C, D) as dependencies, so the implementation of this part, or serial.

Let's include some examples, Avahi service needs D-Bus provides, therefore Avahi start depends on the D-Bus, UpStart in, Avahi after D-Bus must be ready to start until just started. Similar, livirtd HAL and X11 are required to start the service, and all these services require syslog logging service, so they have to wait for the syslog service to start up. However httpd and they have no relationship, so httpd can start Avahi services such as concurrency.

Systemd can further increase the concurrency, even for those interdependencies must serial service UpStart believes that such Avahi and D-Bus to be started concurrently.

systemd provides on-demand start capability

When sysvinit system initialization time, it will be possible to use all the background services start all the processes running. And the system must wait after all services are ready to start, the user is allowed to log on. This approach has two drawbacks: First, start-up time is too long; second is a waste of system resources.

Some services are likely to in a very long time, even during the entire server is running have not been used before. Such as CUPS, print service on most servers rarely actually used to. You may not think, in many server SSHD is rarely true access to. Spent on these services start time is not necessary; similarly, system resources spent on these services is a waste.

Systemd can provide the ability to start on demand, only when a service is requested before the real start it. When the end of the service, systemd can turn it off, wait for the next time you need to start it again.

Systemd life-cycle characteristics of Linux Cgroup tracking and management process

An important responsibility init system is responsible for tracking and lifecycle management services processes. It can not only start a service, it must also be able to stop the service. It looks nothing special, but when you actually use the code, you may find difficult to stop the service than to start thinking.

Service process generally as daemons (daemon) running in the background, this service program sometimes derivative (fork) twice. In UpStart, you need to configure the expect section correctly in the configuration file. Thus UpStart by fork system call counts and thereby learns the true spirit of the PID number.

If UpStart got it wrong, will p1` as a service process Pid, then stop the service when, UpStart p1` will try to kill the process, while the real p1`` process proceed. In other words the service is out of control.

There are more special circumstances. For example, a CGI program will derive twice, and from the Apache parent-child relationships. When the Apache process is stopped, the CGI program continues to run. And we hope that the service is stopped, it starts all the relevant processes have been stopped.

To deal with such problems, UpStart through strace to track fork, exit system calls, but this method is very clumsy, and the lack of scalability. systemd takes advantage of the Linux kernel that is characteristic CGroup track to complete the task. When you stop the service by querying CGroup, systemd can be found to ensure that all relevant processes, so as to cleanly stop the service.

CGroup have been for a long time, it is mainly used to implement the quota system resource management. CGroup offers a similar file system interface, easy to use. When a process creates a child process, the child process will inherit the parent process CGroup. So no matter how the service starts new child processes, all of which will belong to the same relevant processes CGroup, systemd simply traverse the CGroup can correctly find all the relevant processes, to stop them one by one.

Start automatically mount and mount point management

Traditional Linux system, users can use the / etc / fstab file to maintain a fixed file system mount points. These mount points during system startup is mounted automatically, once the end of the boot process, which will ensure that the mount points exist. These mount points are critical to the operation of the system file systems, such as HOME directory. And, like sysvinit, Systemd management of these mount points, so that they can be mounted automatically at system startup. Systemd also compatible with / etc / fstab file, you can continue to use the file manager mount point.

Sometimes users need dynamic mount points, such as when accessing DVD content intended only for temporary mount execution access the content, when accessed without the CD-ROM mount point is canceled (umount), in order to conserve resources. Traditionally, people rely autofs services to achieve this functionality.

Systemd built automount services, without having to install autofs service can be directly used to automatically mount systemd provides management capabilities to achieve autofs function.

Implement transactional dependency management

The system startup process is a lot to work independently composed, there may be dependencies between these tasks, such as mount an NFS file system must rely on the network to work properly. Although Systemd to maximize concurrent execution dependencies lot of work, but like "mount NFS" and "Start network" this kind of work still exist inherently has dependencies can not be executed concurrently. For these tasks, systemd maintains a "transaction consistency" concept, to ensure that all relevant services can be started normally and will not appear depend on each other, so that a deadlock situation.

The system can snapshot and recovery

systemd support on-demand start, so the system's operational status is dynamic, people can not know exactly what the system is currently running services. Ability Systemd provides a snapshot of the current system operating state is saved and restored.

For example, the system is currently running services A and B, you can use systemd command line to create a snapshot of the current system operating conditions. A process is then stopped, or make any other changes to the system, such as starting a new process C. After these changes, run systemd snapshot restore command, you can immediately restore your system to the state of a snapshot in time, and that only services A, B running. One possible scenario is debugging the application: for example, the server some exceptions, in order to debug the user will be saved as a snapshot of the current state, then can be any action, such as stopping services. Debugging and other end, you can restore the snapshot.

The snapshot feature is currently in systemd is not perfect, it seems that developers are particularly concerned about it, and therefore it has been reported that there are some problems of use, the use of fashion to be careful.

Log Service

systemd comes log service journald, designed the log service is to overcome the disadvantages of existing syslog service. such as:

syslog unsafe content of the message could not be verified. Each local process can claim to be the Apache PID 4711, and syslog believe it and save it to disk.
There is no strict data format, very casual. Automated Log Analyzer requires the analysis of human language strings to identify the message. On the one hand this type of analysis is difficult inefficient; moreover log format change will cause analysis code needs to be updated or rewritten.
Systemd Journal binary format to save all log information, user journalctl command to view the log information. No need to write your own complex string vulnerability analysis and processing procedures.

Advantages Systemd Journal as follows:

Simplicity: less code, less dependent, abstract minimal overhead.
Zero maintenance: log is a core function of debugging and monitoring system, so it can no longer produce their own problems. For example, automatic management of disk space, to avoid the continuous generation of logs and disk space is exhausted.
Portability: The log file should be available on all types of Linux systems, no matter what kind of CPU or byte sequence it uses.
Performance: Add and view the log very quickly.
Minimum resource consumption: log data files need to be smaller.
Unification: Various log storage technology should unite all the events can be recorded is stored in the same data store. So log contents global context will be saved and available for future reference. For example, after a firmware records often will follow a core record, eventually there will be a userland record. It is important when you save to your hard drive relationship between these three is not lost. Syslog different information will be saved to a separate file, the analysis time is difficult to determine which entries are relevant.
Scalability: the scope of the log is very wide, from embedded devices to supercomputers are able to meet the needs of the cluster.
Security: The log file can be verified, so that modifications can not be detected is no longer possible.

The basic concept of Systemd

The concept of unit

System initialization needs to be done very much. Need to start background service, such as start SSHD service; configuration work needs to be done, for example, mount the file system. Each step in this process are systemd abstracted as a hive that unit. It can be considered a service is a hive; a mount point is a hive; a swap partition configuration is a hive; and so on. systemd hive summarized in the following few different types. However, systemd is evolving rapidly increasing new features. So the type of hive may continue to increase in the near future.

service: on behalf of a background server process, such as mysqld. This is the most common type.
socket: Such hive packaging system and the Internet in a socket. Moment, systemd support streaming, continuous data packet and package of AF_INET, AF_INET6, AF_UNIX socket. Each unit has a socket configuration corresponding service hive. The appropriate service when the first "connected" to enter the socket starts (for example: nscd.socket in new connections after the start nscd.service).
device: Such a package exists in the hive Linux devices in the device tree. Each device uses udev rules are labeled in systemd will hive as a device appears.
mount: Such packaging hive file system hierarchy in a mount point. Systemd mount point will be monitored and managed. For example, it can automatically mount at boot; can automatically unloaded under certain conditions. Systemd will / etc / fstab entries are converted to the mount point, and processed at boot time.
automount: Such hive packaging system hierarchy from a mount point. Each unit corresponds to a self-mount configuration mount hive, when the automatic mount point is accessed, systemd perform a mount point defined mount behavior.
swap: hive and mount similar exchange hive used to manage swap. Users can configure the switching unit to define the system swap partition, you can make these swap at startup is activated.
target: Such hive logical grouping for other hive. They themselves do not actually do anything, but just refer to other hives. This makes it possible to configure the unit to make a unified control. This allows running a conceptual level we are already very familiar with. For example, want the system to enter the graphical mode, you need to run many services and configuration commands, these operations are controlled by one of the hive, he said a combination of all these hives as a goal (target), it means that you need to perform all of these hives again in order to enter the target represents the system running. (Example: multi-user.target equivalent to running traditional use SysV system Level 5)
timer: Timer hive used to periodically trigger user-defined actions, such hive replaced atd, crond traditional timing services.
snapshot: the target hive similar snapshot is a hive. It saves the current state of the system.
Each hive has a corresponding configuration file, the system administrator's task is to prepare and maintain these different profiles, such as a MySQL service corresponds to a mysql.service file. This configuration file syntax is very simple, users do not need to write and maintain complex systems 5 script.

Dependencies

Although a lot of systemd will start work to lift the dependency so that they can be complicated to start. But there is still some tasks, dependencies exist between them naturally, can not use a "socket activation" (socket activation), D-Bus activation and autofs three ways to wean (the three methods detailed in the subsequent description). For example: mount must wait for the mount point is created in the file system; mount also must wait for the corresponding physical device is ready. In order to solve these dependencies, between systemd hive can define codependent relationship.

Systemd with hive definition file keywords to describe the dependencies between the hive. For example: unit A dependency unit B, can "require A" to indicate the definition of unit B is used in. Such systemd will ensure first start A restart B.

Systemd Affairs

Systemd to ensure transaction integrity. Systemd transactional database concepts and different, mainly in order to ensure that no endless references between multiple dependent hive.

Circular dependency, the systemd will not start any of the services. At this point systemd will try to solve this problem, because the dependencies between the hive, there are two: required is a strong dependence; want is a weak dependence, systemd will remove wants keyword specified see if we can break the cycle of dependency. If you can not repair, systemd error.

Systemd can automatically detect and repair this type of configuration errors, greatly reducing the burden on administrators troubleshooting.

Target and run level

systemd in the target (target) instead of the concept of run levels, providing greater flexibility, as you can inherit an existing target and add other services to create their own goals. The following table lists the correspondence between the objectives and common runlevel systemd under:

Table 1. Sysvinit run levels and systemd target correspondence table


Sysvinit run target level Systemd Remarks
0 runlevel0.target, poweroff.target shut down the system.
1, s, single runlevel1.target, rescue.target single-user mode.
2, 4 runlevel2.target, runlevel4.target, multi-user.target user-defined / domain specific operating level. The default is equivalent to 3.
3 runlevel3.target, multi-user.target multi-user, non-graphical. Users can log on multiple consoles or network.
5 runlevel5.target, graphical.target multi-user, graphical. All services typically run level 3, plus a graphical login.
6 runlevel6.target, reboot.target restart
emergency emergency.target emergency Shell


Systemd principle of simultaneous start

As described above, in Systemd, all services are started concurrently, such as Avahi, D-Bus, livirtd, X11, HAL can be started simultaneously. At first glance, this seems a little problem, such as Avahi need syslog service, Avahi and syslog started simultaneously, assuming Avahi start faster, so syslog was not ready, but they need Avahi logging, this would not be a problem ?

Systemd developers carefully study the nature of the problem of interdependence between the service and found that the so-called dependency can be divided into three specific types, and each type can actually relieve dependence through appropriate technology.

Concurrent start one principle: to solve the socket dependence

The vast majority of service depends on the socket is dependent. A service such as providing their services through a socket port S1, other services if needed service A, you need to connect S1. So if A service has not been started, S1 does not exist, other services will get startup errors. So Traditionally, people need to start service A, wait for it to enter the ready state, and then start the other services that require it. Systemd that as long as we advance the S1 is set up, then all the other services can be started simultaneously without waiting for a service A to create S1. A If the service is not started, then the service request process actually sent to S1 will be Linux operating system cache will wait for other processes where this request. A Once the service is ready to start, you can process the request cache immediately, everything begins normal operation.

So how to use the service sockets created by the init process it?

Linux operating system has a feature that, when the process calls fork or exec create a child process, the parent process is all open file handle (file descriptor) are inherited by child processes. Socket is a file handle, process A can create a socket, then when process A calls exec to start a new child process, just make sure the socket close_on_exec flag is cleared, then the new child process you can inherit the socket. Sockets sockets and the parent process child process created a system see the same socket, the socket is the same as if the child process to create their own, without any distinction.

This feature was previously used by a system called the inetd service. Inetd process will be responsible for monitoring some common socket port, such as Telnet, when there is a connection request on the port, inetd starts telnetd process only, and to have a socket connection is passed to the new telnetd process to be processed. Thus, when the system does not telnet client connections, you need to start telnetd process. Inetd can represent a lot of network services, so you can save a lot of system load and memory resources only when there is a real connection request to start the appropriate services, and the socket is passed to the service process.

And similar inetd, systemd is the parent of all other processes, it may be required to establish all the sockets, and then calling exec when the socket is passed to the new service process, and the new process directly using the socket word the service.

Concurrent start of the two principles: solve D-Bus dependence

 

D-Bus is a desktop-bus for short, it is a low-latency, low overhead, between the high-availability process communication mechanism. It is increasingly being used for communication between applications, but also for communication applications and the operating system kernel. Many modern service processes use D-Bus interprocess communication as substituted socket mechanism, external services. Such as simplified Linux network configuration NetworkManager service is using D-Bus to interact with other applications or services: e-mail client software evolution can obtain network status change from NetworkManager service via D-Bus, in order to make the appropriate treatment.

D-Bus supports so-called "bus activation" function. Auto-start service if the service requires the use of service B A D-Bus service for a B and is not running, you can request D-Bus service B D-Bus service A B. The service request will be issued A D-Bus cache waits for service A service B ready to start. Using this feature, dependent D-Bus services can be achieved in parallel to start.

Three concurrent start of principle: to resolve the file system dependent

During system startup, the file system-related activities is the most time-consuming, for example, mount the file system, the file system disk check (fsck), disk quotas inspections are very time-consuming operation. Waiting for this has been done at the same time, the system is idle. Those who want to use the file system service appears to have to wait for the file system initialization is complete before you can start. But systemd found that this dependence is avoided.

Systemd reference autofs design ideas, so that both initialize itself can be complicated jobs depend file system services and file systems. autofs can monitor a file system mount point actually be accessed when it is triggered to mount the operation, which is supported by the kernel automounter module achieved. For example, a open () system call to action "/ misc / cd / file1" when, / misc / cd mount operation has not been performed, then open () call is pending wait, Linux kernel notification autofs, autofs mount execution . At this time, control is returned to the open () system call, and normally open the file.

Systemd integrated autofs implementations, the system mount points, such as / home, when the system starts, systemd automatically create a temporary mount point. At this moment / home mount the device is not really a good start, really mount operation has not been performed, the system detects the file has not yet completed. But those who depend on the process can be complicated directory already started their open () operation is built in systemd in autofs capture, the open () call to suspend (interruptible sleep state). And then wait for the real mount operation is completed, the file system detects also completed, systemd replace the automatic mount point for the real mount point, and let the open () call returns. Thus, to achieve that rely on the file system services and file system itself simultaneous start.

Of course, for "/" is actually dependent on the root directory or to a certain serial execution, since systemd themselves stored in / under, you must wait for the system to check the root directory is mounted good.

But the case for similar / home mount point, etc., which can improve the startup speed of concurrent systems, especially when / home is an NFS remote node, or encrypted disk, etc., it takes a long time to be ready by the because concurrent start, this time, the system is not entirely nothing to do, but you can use this spare time to do something more to start the process, in general shortens the system startup time.

Systemd use

The following role-technical staff to brief you use systemd. This article is only intended to give a simple description that allows you to use systemd have a general understanding. Specific details of too much, it can not be written in full in an essay, I am not so powerful capabilities. Also you need the reader to further consult systemd documents.

Software Developer

Developers need to know more details of systemd. For example, you plan to develop a new system services, we must learn how to make this service can be systemd management. This requires you to pay attention to the following points:

Background service process code is not required to achieve twice the derived background daemons, only we need to implement the main loop to the service itself.
Do not call setsid (), to deal with systemd
No longer need to maintain pid file.
Systemd provides log function, processes and services need only to stderr without the need to use syslog.
Processing signals SIGTERM, the only proper function of this signal is to stop the current service, do not do other things.
SIGHUP signal effect is to restart the service.
The service requires a socket, do not create your own socket, let systemd incoming socket.
Use sd_notify () function inform systemd service their status changed. Generally, when the service initialization is complete, ready to enter the service, you can call it.
Unit prepared documents

For developers, the biggest part of the work should be prepared hive file, define the unit needed.

For example, developers have developed a new service program, such as httpd, you need to prepare for a hive file so that the service can be managed systemd, UpStart similar work profile. Service startup command line syntax definitions, as well as other services and dependencies, etc. in the file.

In addition, we have previously learned, systemd's many functions, not only to manage the service, you can also manage mount points, the definition of regular tasks. These are done by editing the appropriate configuration file to complete the unit. I am here to give a few examples of the hive file.

Here is the hive file SSH service, service .service hive file to the file name suffix.

  #cat /etc/system/system/sshd.service
  [Unit]
  Description = OpenSSH server daemon
  [Service]
  EnvironmentFile = / etc / sysconfig / sshd
  ExecStartPre = / usr / sbin / sshd-keygen
  ExecStart = / usrsbin / sshd -D $ OPTIONS
  ExecReload = / bin / kill -HUP $ MAINPID
  KillMode = process
  Restart = on-failure
  RestartSec = 42s
  [Install]
  WantedBy = multi-user.target
File is divided into three sections. The first is [Unit] section, where there is only a description. The second part is defined Service, which command should run before defining ExecStartPre start the service; ExecStart specific command-line syntax is defined to start the service. The third part is the [Install], WangtedBy indicates that this service is in multi-user mode required.

Then we look at multi-user.target it:

  #cat multi-user.target
  [Unit]
  Description = Multi-User System
  Documentation = man.systemd.special (7)
  Requires = basic.target
  Conflicts = rescue.service rescure.target
  After = basic.target rescue.service rescue.target
  AllowIsolate = yes
  [Install]
  Alias = default.target
The first part of the show multi-user.target Requires defined start time basic.target must be activated; additional basic.target stop time, multi-user.target must also stop. If you then view basic.target file, you will find it specifies a different unit sysinit.target etc. must be launched subsequently. Similarly sysinit.target also contain other elements. With this link-layer structure, and ultimately all need to support multi-user mode service components are initialized good start.

In the [Install] section has Alias definitions that define an alias for this unit, so that when the running systemctl can use this alias to refer to this unit. Alias here is default.target, than multi-user.target simpler. . .

Also in / etc / systemd / system directory can also be seen, such as * .wants directory on the hive file in that directory is equivalent to [Unit] subsection wants keyword, that this unit starts, also these units need to start. For example, you can simply write your own foo.service under multi-user.target.wants file into the directory, so that each will be activated by default.

Finally, let's look at sys-kernel-debug.mout file that defines a mount point file:

#cat sys-kernel-debug.mount
[Unit]
Description = Debug File Syste
DefaultDependencies = no
ConditionPathExists = / sys / kernel / debug
Before = sysinit.target
[Mount]
What = debugfs
Where = / sys / kernel / debug
Type = debugfs
This hive file defines a mount point. Mount hive file has a [Mount] configuration section, which is configured with What, Where, and Type three data items. This is necessary for the mount command, the example configuration is equivalent to the following mount command:

mount -t debugfs / sys / kernel / debug debugfs

Prepared hive file requires a lot of learning, it must be included with reference to systemd man and other documents in-depth study. We hope that through a few small examples above, we have to understand the role hive file and the general wording.

System administrator

The main command-line tool systemd is systemctl.

Most administrators should have been very familiar with the system management services and init systems, such as service, chkconfig and using telinit command. systemd also perform the same management tasks, but Tools systemctl command syntax differs from mine, so use a table to compare systemctl and traditional systems management command is very clear.

Table 2. Systemd table commands and command sysvinit

Sysvinit command Systemd Command Notes
service foo start systemctl start foo.service used to start a service (and not reboot the existing)
service foo stop systemctl stop foo.service to stop a service (and not reboot the existing).
service foo restart systemctl restart foo.service used to stop and start a service.
service foo reload systemctl reload foo.service when supported, reload configuration files without interrupting the wait operation.
service foo condrestart systemctl condrestart foo.service If the service is running then restart it.
Are service foo status systemctl status foo.service reporting service is running.
ls /etc/rc.d/init.d/ systemctl list-unit-files --type = service can be used to list a list of services to start or stop.
Set chkconfig foo on systemctl enable foo.service next time you start or meet other conditions of service to enable the trigger
Set chkconfig foo off systemctl disable foo.service next time you start the trigger or meet other conditions of service for the disabled
chkconfig foo systemctl is-enabled foo.service used to check a service in the current environment is configured to enable or disable.
Enabling and disabling conditions chkconfig -list systemctl list-unit-files --type = service output at each level of service is running
chkconfig foo -list ls /etc/systemd/system/*.wants/foo.service used to list the services which enable and disable at run level.
chkconfig foo -add systemctl daemon-reload is used when you create a new service file or change settings.
telinit 3 systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) up to the user to change the run level.
In addition to Table 2 lists the common usage, system administrators need to know to change some other system configuration and management tasks.

First, we learn how to deal with systemd power management commands in the following table:

 

Table 3, systemd power management command

Command Operation
systemctl reboot reboot
systemctl poweroff shutdown
systemctl suspend standby
systemctl hibernate hibernation
systemctl hybrid-sleep hybrid sleep mode (suspend to hard disk at the same time and standby)
Log off not every user can execute in any case, generally only the administrator can shut down. Under normal circumstances, the system should not allow SSH remote login user executes the shutdown command. Otherwise, other users are working off a user of the system on the bad. To solve this problem, the traditional Linux system ConsoleKit track user logins, and decide whether to give its permission to shut down. Systemd ConsoleKit now been replaced by the logind.

logind not pid-1 init process. Its role and UpStart the session init similar, but the function is much rich, it is able to manage almost all user sessions (session) related things. logind ConsoleKit only alternative, it can:

Maintenance, track sessions and user logins. As described above, in order to determine the feasibility of a shutdown command, the system needs to know the current user login, if a user login from SSH, not allowed to execute the shutdown command; if ordinary users to log on locally, and that the system user is the only session, allowing it to execute the shutdown command; logind these judgments are required to maintain all user sessions and logins.
Logind also responsible for statistics user session if there is no operation for a long time, you can perform the operation Sleep / shutdown.
Create CGroup process for all user sessions. This is not only convenient statistical correlation process all user sessions, you can also achieve session-level control of system resources.
Responsible for handling power management key combinations, such as the user presses the power button, the system switches to the sleep state.
Multi-seat (multi-seat) management. Today's computers, even a laptop, but also can provide computing power than simultaneously. Multi-seat is a computer host to manage multiple peripherals, such as two screens and two mouse / keyboard. 1 and a seat using the onscreen keyboard 1; two seats 2 and using the onscreen keyboard 2, but they all share a single host. User session can freely switch between multiple seats. Or when inserting new keyboard, screen and other physical peripherals, automatically start gdm user login interface. Content All of these are multi-seat management. ConsoleKit never achieve this function, systemd's logind can support multiple seats.
These management functions described above are only some of the features systemd addition, systemd is also responsible for the management of other system configurations, such as network configuration, Locale, Management system kernel module is loaded like a complete description of them is beyond my ability.

systemd Summary

In the author's opinion Fucai, the system as a system initialization, systemd biggest feature has two:

It is the ability to launch concurrent radical surprise, greatly improve the system boot speed;
Statistics tracking with CGroup child, clean and reliable.
In addition, different places and its predecessor is that, systemd is not just a system of initialization.

Systemd excellent alternative to all the features of sysvinit, but it is not complacent. Because the init process is the parent process systems such particularity of all processes, systemd is excellent for once provided by other services, such as regular tasks (previously done by crond); Session Manager (formerly managed by ConsoleKit / PolKit etc.). Only from the perspective of this article describes the same fur, Systemd pipe was already a lot, it may be evolving. It will gradually become a versatile system environment, able to handle a lot of system administration tasks, and some even see it as an operating system.

Good thing is, it is very helpful standardized Linux management! In the past, different Linux distributions take individual actions, management systems using different methods, never will not compromise each other. Such as how the system into hibernation, different systems have different solutions, even with a Linux system, there are different methods, such as an interesting discussion: how to make ubuntu system sleep, you can use the underlying / sys / power / state interface can also be used as high-level interfaces pm-utility and the like. There are so many different ways to do a thing like me ordinary users, not an interesting thing. systemd provides a unified power-management command interface, the significance of this matter for similar people around the world say that a common language, we do not need to learn a foreign language, how beautiful!

If all Linux distributions have adopted systemd, the system administration tasks can be largely standardized. In addition systemd have a great commitment: the interface remains stable, will not easily change. For software developers, this is how thoughtful and committed people moving ah!

Conclusion

This series of articles from the ancient but simple and stable sysvinit talking about, then briefly describe the change UpStart bring fresh, and finally saw the new generation of ambitious and dynamic systemd system has come to rule the various versions of Linux. Just like we see in this world, a generation old, the new generation with the sweeping spirit on stage, yet the most powerful of them shouted slogans, more violent generation has put the spotlight and all eyes away. After Systemd perhaps updated init system appear, and let us continue to look forward. .
     
         
         
         
  More:      
 
- Android system source code and compile the kernel source code (Programming)
- To configure and use multiple Tomcat under Linux environment (Server)
- Cooling solutions Ubuntu system (Linux)
- iOS constants, variables, properties and characteristics (Programming)
- Single-node Hadoop environment to build (Server)
- MongoDB 3.2 to upgrade from 3.0.7 (Database)
- How to manage the time and date at systemd Linux systems (Linux)
- C # DateTime structure common method (Programming)
- Getting Started with Linux system to learn: how to check memory usage of Linux (Linux)
- Linux fixes fatal error: x264.h: No such file or directo (Linux)
- The Gitlab migrated to Docker container (Server)
- IOwait Linux system monitoring diagnostic tools (Linux)
- Ubuntu 14.04 LTS NTFS partition can not access solution (Linux)
- Safety testing Unix and Linux server entry succinctly (Linux)
- Linux rights management (Linux)
- OpenCV 3.0 + Python 2.7 installation and testing under Ubuntu 14.04 (Linux)
- Sublime Text 3 using summary (Linux)
- Management Linux Container with Docker in Ubuntu (Linux)
- Compression decompression command under Linux (Linux)
- Four Methods of Self - Learning Linux (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.