Linux entry fourth day-service management

Source: Internet
Author: User
Tags safe mode

The following are based on CentOS6.3, where some of the commands are obsolete and are no longer used in CentOS7, please note

  "Update": CentOS7 change:

Centos7one of the major changes in. 0 is the switch to SYSTEMD. It is used to replace SYSV and upstart in previous versions of Red Hat Enterprise Linux and to manage systems and services. SYSTEMD is compatible with startup scripts for SYSV and Linux standard groups. SYSTEMD is a system and service Manager under a Linux operating system. It is designed to be backwards compatible with SYSV startup scripts and provides a number of features, such as starting system services in parallel when booting, starting daemons on demand, supporting system state snapshots, or relying on dependent service control logic. In a previous Red Hat Enterprise Linux version using SYSV initialization or upstart, use theThe bash initialization script in the/etc/rc.d/init.d/directory is managed. And in Rhel7/in CentOS 7, these startup scripts are replaced by service units. The service unit ends with a. service file extension, providing the same purpose as the initialization script. To view, start, stop, restart, enable, or disable system services, you use SYSTEMCTL instead of the old service commands. Note: For backwards compatibility, the old service command is still available in CentOS 7, which redirects all commands to the new systemctl Tool-the explorer. Use Systemctl to startStopRestart service to start a service, you need to use the following command: # Systemctl start Httpd.service This will start the httpd service, as far as we are concerned, the Apache HTTP server. To stop it, you need to use the command as root: # Systemctl stop Httpd.service to restart, you can use the Restart option if the service is running, it will restart the service, and if the service is not running, it will start.
You can also use the try-start option, which restarts the service only when the service is already running. Also, the reload option you can have, it will reload the configuration file. # systemctl Restart httpd.service# systemctl try-Restart httpd.service# systemctl Reload Httpd.service The commands in our example will look like this: Check service status to check the status of the service, you can use the status option, see here: # The Systemctl status Httpd.service output is like this: it tells you all the aspects of the service in operation. Use the Enable/Disable the service to control boot boot You can also use the Enable/Disable option to control whether a service starts up, the command is as follows: # Systemctl enable httpd.service# systemctl disable Httpd.service

  For more information about SYSTEMD, refer to : http://blog.51cto.com/xiaoli110/1629533

For more commands and other differences, refer to : https://www.cnblogs.com/bethal/p/5945026.html

One, outline

   

II. Introduction and classification

  1. Operating level

0-6 altogether 6 operating levels

 #  stop, The machine shuts down. #  1 - single-user mode.  Just like the safe mode under Win9x #  2 - multi-user, but no NFS Enter multi-user mode without Network Service #    3-  < Span style= "color: #ff0000;" >  full multi-user mode, is the standard run level.   #  4 - No, not normally, In some special cases you can use it to do something. For example, when the laptop battery is exhausted, you can switch to this mode to #  5 - X11, go to X Window System. #  6 - restart, run Init 6 The machine restarts. Init is typically run automatically at system startup, or it can be called by the root user. Its role is to switch the operating state of the system. Its command format is: Init num〈 carriage return, where NUM represents any number from 1 to 6   

Level 3 is our usual character interface (the default level), and level 7 is our standard graphical interface .

Of course, the default level can be set, the specific configuration of CentOS7 is not listed (modify the relevant configuration file can be)

  2. Classification of services

  The vast majority of services are independent services, XINETD is a super Daemon (CentOS7 has been largely deprecated)

  Classification of SYSTEMD service types in Centos7:

The Extension primary service feature. Service unit: Mainly system services, including the server itself needs native services and network services are! Most of the services that are often used are this type! So, this is also the most common type of!.socket internal program data Exchange Socket Service (socket unit): mainly IPC (Inter-process Communication) The transmit message slot file (socketfile) function. This type of service is usually in the monitoring of the transmission of the slot file, when there is a message through this slot to link the service, according to the current state of the user's request to the corresponding daemon, if the daemon has not been started, then the user's request after the launch of the daemon. A service that uses a socket type is typically a service that is not used by comparison, so it is usually slightly delayed when booting (because comparisons are not so common!). )。 Generally used for a lot of native services, for example, our graphical interface of many software is through the socket to the local program data exchange behavior. (This is a partial similarity to the Super daemon of the early xinetd!) ). Target execution Environment type (target unit): is actually a collection of unit, such as the multi mentioned in the table above-User.target is actually a collection of services-that is, choosing to execute Multi-user.target is the execution of a bunch of other. Service or/and. Socket services like that!.Mountthe. automount file system mounts the associated service (automount unit/Mountunit): such as automatic mounts from the network, NFS file system mounts, and other file system-related program management. Path detects a specific file or directory type (path unit): Some services need to detect certain directories to provide queue services, such as the most common print services, is to start the print function by detecting the print queue directory! Then you have to. The service type of path supports!.timer Loop Execution Service (timer unit): This thing is a bit like anacrontab! But it is offered by SYSTEMD, more flexible than anacrontab! 
View Code

  To view the installed services:

  RPM Package and source package installation location is different, so it is best to separate treatment

  3. Services and Ports

  The concept of port:

  To view the services that are turned on in the system:

  You can use Netstjart-a to view all

Where:established, is already connected

Third, RPM package service Management

  1. Independent service Management

  RPM packages a common default directory (not absolutely, of course, is determined by the person writing this rpm where the reasonable place to put it):

    How to start a standalone service:

  Instance:

View All scripts:

    Start with an absolute path

+ The following option can start the restart and so on

There is a failure to resolve the native host error, does not affect the normal start

Example: Start with service (recommended)

Service httpd Start

It is important to note that this is only possible with the Redhat series through service launch, the standard Start command or the previous one.

  and the middle service name is called httpd, refers to this is a daemon process Deamon

Also, the service cannot start the source package (not the default location and the services script cannot be found correctly)

  " Update":

CentOS 7 after using Systemctl  start  httpd, systemctl instead of service and chkconfig, and the course is not the same, pay attention to Oh!

  There are a lot of commands that have been changed in CentOS7, and there is no way to list the commands that are self-starting (unlike CentOS6!). )

Systemctl See also: http://www.cnblogs.com/zhming26/p/6155201.html

For an encyclopedia of manuals, see: HTTP://MAN.LINUXDE.NET/PAR/5

  2.XINETD Service

  Basic has disappeared (not expanded here)

Iv. Source Package Service Management

  Due to the different installation location, the default source package is not able to use the RPM package management mode to start

  Start of service:

The installation instructions for the service have been explained in the script how to start (usually through the absolute path to find the startup script to start)

  Self-booting of the service:

  Example:

  How to forcibly let the source package let service (note is CENTOS6) identify

V. Summary

  Xmind Mind Map:

Vi. Supplementary Service management of CentOS7--systemctl

  Systemctl Syntax Introduction:

[[Email protected] ~]# systemctl [command] [Unit]command main: Start: Immediately start the back of the Unitstop: immediately close the back of the Unitrestart: immediately shut down after the start of the unit, that is, to perform stop and The meaning of start reload: Reload the configuration file without closing the unit after it, and let the settings take effect enable: Set the next time the unit is switched on, the disable: The next unit will not be started when the After the status of this unit, will be listed there is no execution, power on the default execution no, login and other information! is-Active: There is currently no running in is-Enable : There is no default when booting the unit example one: Look at the current ATD status of this service? [[Email protected]~]# systemctl Status Atd.serviceatd.service-Job spooling toolsloaded:loaded (/usr/lib/systemd/system/atd.service; enabled) active:active (running) since Mon -- ,-Ten  +: -: theCST 5h 42min agomain PID:1350(ATD) CGroup:/system.slice/atd.service└─1350/USR/SBIN/ATD-FaugTen  +: -: theStudy.centos.vbird systemd[1]: Started Job spooling tools.# focus on line second to third Oh ~# Loaded: This line in the description, power on when this unit will not start, enabled for boot, disabled boot will not start # Active: Now this The state of a unit is executing (running) or not executing (dead) # The next few lines indicate the PID state of the unit program and the last line shows the login file information for the service! # The login file Information format is: "Time" message to send the host "" which service message "" Actual message Content "# So the above display message is: This ATD default boot is started, and now is running the meaning! Example two: Normal shutdown of this ATD service [[email protected]~]# systemctl stop atd.service[[email protected]~]# systemctl Status Atd.serviceatd.service-Job spooling toolsloaded:loaded (/usr/lib/systemd/system/atd.service; enabled) Active:inactive (dead) since Tue -- ,- One  on:Geneva: -CST; 4s agoprocess:1350Execstart=/usr/sbin/atd-f $OPTS (code=exited, status=0/SUCCESS) Main PID:1350(Code=exited, status=0/SUCCESS)Ten  +: -: theStudy.centos.vbird systemd[1]: Started Job spooling tools. the One  on:Geneva: -Study.centos.vbird systemd[1]: Stopping Job spooling tools ... the One  on:Geneva: -Study.centos.vbird systemd[1]: Stopped Job spooling tools.# currently this unit will start the next boot, but it is not in the running state! At the same time, the last two behaviors of the newly added login message, tell us the current system status Oh! 

Linux entry fourth day-service management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.