Linux Service Management-Service Classification (Services installed by RPM packages and source code packages)

Preface

  • Services in Linux can be divided into two categories, one is the service installed by default in the RPM package (including independent services and xinetd services), and the other is the service installed by the source package. Service management is the start and self-start of the service. So I will learn these two types of startup and self-starting methods
    - what is a service? ? ? The .exe program seen in windows is a binary compiled package. The installation method is the same, but some of the installed programs are just the commonly used application software of the system, but some can be installed as system services. For example: qq is the application software, and the virtual machine is the service after installation.
    Insert picture description here
    Automatic: The service is automatically turned on with the power on or restart.
    Manual: This service does not start after booting, but when it is needed by other services, it is called. This service does not need the permission of the administrator and will be called directly by this service.

1. Classification of services

Insert picture description here
Description in the figure:

  • (1) Why is the default service installed by the RPM package? ? ? The entire Linux system is installed with rpm, and the service installed with the rmp package is the same as the default value of the system, so it is the default service.
  • (2) What is an independent service:? ? ? Most of the services in Linux are independent. The direct service is in the memory. When a user accesses it, the service directly responds to the user. The advantage is: the service access response is faster, the disadvantage: the more such independent services, the more memory resources are consumed.
  • (3) What is the service based on xinetd? ? ? Xinetd itself is independent, in the memory. Unlike the apache service, if someone visits, just respond with apache. Then I can open my web page. But the service of Xinetd is different. When you visit xinetd, xinetd itself has no function. Its only function is that there are a series of services managed by him behind him.
    Give a chestnut:If you want to access the service behind him, such as the rsync service, which is a network backup service in Linux, add access to it, and customers cannot find it directly, because this service is not in the memory, first find xinetd to access it through xinetd rsync, because this service is managed by the xinetd service, then srync responds to xinetd, and xinetd responds to the client. The Xinetd service itself is independent, but the services it manages in the background are called xinetd-based services.
    The advantage is: the latter xinetd-based services themselves do not take up memory, and the disadvantage: the response speed is slower than independent services.

2. Startup and self-startup

  • Service start: is to let the service run in the current system and provide functions.
  • Service self-starting: Self-starting refers to letting the service start automatically when the system is started after the system is turned on or restarted, and automatically start the service when the system is started.

hint:Service management, one of which is service startup and self-starting. This is how to start and self-start the three types of services I will learn next

3. Query installed services

3.1 RPM package installation service

  • Command: chkconfig --list
    Function: View the service self-starting status, you can see all the services installed by the RPM package
    Insert picture description here

hint:

  • (1) This command can only view the services installed by the rpm package. But with this command, you can see all the installed rpm packages in the system.
    (2) What do the numbers 0-6 in the above picture represent? ? ? Represents the run level: 0~6 represents the seven default run levels of Linux, 0 represents shutdown, 1 represents single user, 2 represents incomplete multi-user, 3 represents character interface, 4 represents unassigned, 5 represents graphical interface, 6 On behalf of restart
    (3) If the service 2345 is enabled, it means: when my computer restarts, if 2345 is entered in Linux, any one of the four run levels will follow the system. Start automatic operation. If the service written in 2345 is started, the service will start after entering the 2345 level.

Big tip:

  • The enablement written here does not mean that this service is already running in the current system, but it means that this service will run next time as the system starts.
  • But how to check that it is already running in the current system? ? ? One is for use ps aux: pipes ps aux | grep crondcan be used to netstat –tlunview all running processes in the system, and the other can be used to view, but there is a problem, like crond is a daemon process, this service is not started, and there is no port. So still use the ps command to view it more accurately.

3.2 Services for source package installation

  • Check the service installation location, generally under /usr/local
  • Just take a look at the INSTALL file before starting the installation. This file not only contains the installation process, but also the service startup method.

hint:
(1) It cannot be checked by commands, because the installation location is different.
(2) The rpm will be installed where the person who wrote this rpm package thinks is appropriate. Both are the system default locations. The configuration file will be installed in the /etc/ directory, and the startup script will be installed in /etc/rc.d/initd/ This is a convention.

3.3 The difference between RPM installation service and source package installation service is the installation location

  • The RPM package is installed in the default location
  • The source code package is installed in the specified location, usually /usr/local/

hint:

  • This is the difference after the installation is the different installation location, which brings about a different management method , service httpd startyou can start services such as apache. chkcongfig --listYou can view the self-starting status of the rpm package installation.
    But these commands cannot manage the services of the source package. The reason is that these commands search for the specified location. The service httpd startreason why the rpm package installed by apache can be started is because the search result is /etc/rc.d/init.dthat the apache startup script httpd is found in this directory. Therefore, by default, the service installed by the source package is started with an absolute path.

Is there a way to start the service installed by the source package using a command? ? ?

  • Answer: If you copy the service installed by the source package and copy its startup script to this /etc/rc.d/init.dpath, or make a connection, then the service can identify the service installed by the source package. But it is not recommended to turn the source package service into the same management method as rpm. The reason is: a mark that distinguishes the source package and the rpm package service. If the management method becomes the same, it will cause confusion for beginners. Because the installation location is different, the service startup and self-starting methods are different.

The difference between source code package and rpm package in deleting software:

  • (1) If you want to delete the rpm package, you must use the -e option to delete the package, because this file package is installed everywhere.
    (2) Source code package: Just delete the directory where the software is installed. For example, all files in /usr/local/apache are installed in the specified directory, so you only need to delete the directory.

4. Summary

  • Divide the services into the following three types. Each has different management methods. In the final analysis, the three types of services are installed at different locations, leading to different service management methods (service startup and self-starting, different opening methods).
    Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_46818279/article/details/107787733