Linux Learning Notes (+) Linux service Management

Source: Internet
Author: User
Tags rsync fully qualified domain name

1. Classification of services

Linux services can be divided into RPM packages by default installed services and source package installed services . The former can be subdivided into separate services (directly acting in memory) and based on XINETD services . The xinetd itself is a standalone service, and its only function is to manage other services . The advantage is that the managed service does not consume memory, and the disadvantage is slow response.

(1) Start-up and self-start

Service startup is to let the service run in the current system and provide its functionality. A service's self-priming means that the service starts automatically as the system starts or restarts after the system is powered on or restarted.

(2) Query the installed services

RPM Package-installed services are available through C The Hkconfig--list command looks at , which is to view the service self-starting state . The command can be See all RPM package installed services, but not see the service for source package installation.

 [[email protected] sh ]# chkconfig--  LISTABRT -ccpp 0 : Off 1 : Off 2 : Off 3 : On 4 : Off 5 : On 6  :OFFABRTD  0 : Off 1 : Off 2 : Off 3 : On 4 : Off 5 : On 6  :off ... 

By viewing the service installation location (typically in the/usr/local directory), you can view the services installed by the source package. The difference between the services installed with the RPM package is that the source package is installed in the specified location, and the RPM package is installed in the default location .

2. Management of independent services

The default location for RPM package installation is:

/etc/init.d/-----Start Script Location

/etc/sysconfig/-----Initialize the location of the environment configuration file

/etc/-----The location of the configuration file

/etc/xinetd.con-----xinetd configuration file

/etc/xinetd.d/-----XINETD Service-based startup scripts

/var/lib/the data generated by the-----service is placed here

/var/log/-----Log

(1) There are two ways to start a standalone service :

 (1 )/etc/init.d/stand-alone service name start|stop|restart| status# queries the status of Apache [[email protected]  sh ]#/etc/init.d/httpd statushttpd (PID   1514  ) is running ... ( status# restart apache[[email protected]  sh  ]# service httpd restartstopping httpd: [OK]starting httpd:httpd:Could not Reli Ably determine the server   " s fully Qualified domain name, using Localhost.localdomain for ServerName  [OK] 

Note:service commands are Red Hat proprietary commands that can be executed using the first method in other Unix systems. Second, the Service--status-all command can list the status of all RPM package installation Services.

(2) Self-starting of independent service

There are three ways to do this, and the second method is recommended.

①chkconfig [--level RunLevel] [standalone service name] [On|off]

Example: Setting up Apache self-boot

[[Email protected]SH]# Chkconfig--list |grephttpdhttpd0: Off1: Off2: Off3: Off4: Off5: Off6: Off[[email protected]SH]# Chkconfig--level2345httpd on[[email protected]SH]# Chkconfig--list |grephttpdhttpd0: Off1: Off2: On3: On4: On5: On6: Off

② Modify the/etc/rc.local file, before you enter the account at boot, the file will be checked for self-booting.

Example: Setting up Apache services in this file

SH] # vim/etc/rc.local #!/bin/sh# each time the file is modified, you can query the startup time of the system touch /var/lock/ subsys/local# Apache self-starting /etc/rc.d/init.d/httpd start

③ using the NTSYSV command to manage self-booting (Red Hat proprietary)

Ntsysv1.3.49.3-(C) --2001Red Hat, Inc.               ┌──────────────────┤services├──────────────────┐││ │what services should be automatically started?││││[*] Abrt-ccpp↑││[*] ABRTD? ││[*] acpid? ││[*] ATD? ││[*] AUDITD? ││[*] AutoFS? ││[*] blk-availability? ││[*] Certmonger↓││││               ┌────┐┌────────┐│││ok││cancel││               │└────┘└────────┘│││ ││└─────────────────────────────────────────── ─────┘

The advantage of this command is that not only can you set up standalone services, but you can also manage xinetd services.

3. Management based on XINETD services

In addition to insecure Telnet is still being managed using the XINETD service, the use of xinetd services is getting less, so understand.

(1) Installing xinetd and Telnet

[[Email protected]SH]#Yum-YInstallXinetd[[email protected]SH]#Yum-YInstalltelnet-server ... [[Email protected]SH]# Chkconfig--list......xinetd0: Off1: Off2: Off3: On4: On5: On6: offxinetd based Services:chargen-dgram:off rsync:off telnet:off ...

When a user accesses the Rsync service, the XINETD service is accessed first, then the Rsync service is called by the xinetd Service, the Rsync service responds to the XINETD service, and the XINETD responds to the client.

(2) Start of xinetd service

start Telnet. change the "Didable=yes" in/etc/xinetd.d/telnet to "Disable=no", then restart the xinetd service. When you see that port 23 is present, the Telnet service is started.

[[Email protected]SH]# vim/etc/xinetd.d/Telnet # default:on# description:the telnet Server serves Telnet sessions; it uses # unencrypted username/password pairs forauthentication.service telnet #服务的名称为telnet {disable=No #服务不启动 flags= reuse # flag bit reuse, set tcp/IP Socket Reuse Socket_type=Stream #使用TCP协议数据包wait=No #允许多个连接同时连接 user=root #启动服务的用户为root Server=/usr/sbin/inch. telnetd #服务的请程序 log_on_failure+=USERID #登录失败后, record the user's ID} [[Email protected]SH]# Service xinetd restartstopping xinetd: [OK]starting xinetd: [OK][[email protected]SH]# Netstat-tlun |grep  atTCP0      0::: at:::* LISTEN

(3) Self-start of xinetd service

Note: The start and start-up of the xinetd service is generic, that is, the boot is performed, which means that self-booting is also performed.

# (1) chkconfig telnet on|  shsh grep # (2) Ntsysv
4. Management of source package installation Services

(1) Startup of source package installation Service

use an absolute path to invoke the startup script to start . Different source packages have different startup scripts. You can view the installation instructions for the source package to see how to start the script .

Example: How to start the Apache service:

/usr/local/apache2/bin/apachectl Start|stop

When you use the RPM package to install Apache again, the 80 port conflict error is displayed.

(2) Self-priming of source package service

Vi/etc/rc.d/rc.local

/usr/local/apache2/bin/apachectl start

(3) Let the source package service be recognized by the Service Management command

Allow the Apache service of the source bundle to be started by service command management

LN –s/usr/local/apache2/bin/apachectl/etc/init.d/apache

Allow the Apache service of the source package to be chkconfig and NTSYSV command Management self-initiated

VI /etc/init.d/apache #指定httpd脚本可以被chkconfig命令管理, format chkconfig: Run-level boot order Close Order # cannot conflict with existing script's boot order and shutdown Order # CHK Config:  * Description, free content # Description:source package Apache   

Then execute: Chkconfig–add Apache

Note: It is not recommended to do such an operation, easy to confuse

Linux Learning Notes (+) Linux 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.