Principles of control and management of Linux services

Source: Internet
Author: User
Tags rsync

System service Management--independent service, temporary service

One, independent service

1. Independent Service characteristics: The system time is fast, the system resources are occupied continuously

2. Standalone services are controlled by/etc/rc.d/init.d/* various service scripts.

3. Basic methods of independent service control: one is controlled by script: /etc/init.d/Service name + control parameters beginners are not so good at remembering. Second, through service management tools: Service+ services + control parameters

4, the main control parameters are: Status View state, start start, stop shutdown, reload reload, restart restart, etc.

Here is a demonstration example:


[Email protected] ~]# ls/etc/rc.d/init.d/ ----------See what services are available under/etc/rc.d/init.d/

Abrt-ccpp cpuspeed iptables NetworkManager quota_nld saslauthd Wdaemon

ABRTD Crond irqbalance NFS rawdevices single Winbind

Abrt-oops cups kdump nfslock rdisc smartd wpa_supplicant

Acpid dnsmasq killall NMB restorecond SMB xinetd

Apacheds-2.0.0_m23-default firstboot Lvm2-lvmetad ntpd rngd snmpd ypbind

ATD functions Lvm2-monitor ntpdate Rpcbind SNMPTRAPD

AUDITD Haldaemon mdmonitor oddjobd RPCGSSD spice-vdagentd

AutoFS Halt Messagebus Portreserve RPCIDMAPD sshd

Blk-availability htcacheclean netconsole postfix rpcsvcgssd SSSD

Bluetooth httpd netfs pppoe-server rsyslog sysstat

Certmonger ip6tables Network Psacct sandbox udev-post

[email protected] ~]# ls/etc/rc.d/init.d/|wc-l -----------------How many services there are in total.

71

[email protected] ~]#/etc/init.d/iptables status ----------------View the boot status of the firewall

Iptables:firewall is not running.

[email protected] ~]# service iptables Reload -- Reload service

[Email protected] ~]#

[[Email protected] ~]# service iptables start --- Open the firewall

iptables:applying firewall rules: [OK]

[[Email protected] ~]# service httpd stop ------------Turn off the HTTP service

Stop httpd: [OK]

[email protected] ~]# service httpd restart ---Restart the HTTP service

Stop httpd: [OK]

Start httpd: [OK]

Second, temporary services

1 Temporary service response time is slow, but save system resources, only when needed to open.

2. Temporary service requires a Super Manager xinet Service for Management,xinet to listen to the port number of various temporary services , only the response port number is opened when needed. There was a barber shop manager in the barber shop, used to manage the barbers, and only the barber he had arranged for the barber to give the customer a haircut. It is therefore necessary to install the xinet before managing the temporary service, which is generally easy to install with Yum . Of course, it is also possible to install with RPM.

3. temporary services are managed by the/etc/xinet.d/* script.

4. Temporary Service Control tool: Chkconfig

5.chkconfig Tool usage (1) chkconfig--list is used to enumerate all current services (including standalone and ad hoc services )

(2) chkconfig + service +on| off temporary service open and close

Here is a demonstration example

[[email protected] ~]# chkconfig--list------ used to enumerate all current services

NetworkManager 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Abrt-ccpp 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

ABRTD 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

Acpid 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

ATD 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

AUDITD 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

AutoFS 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Blk-availability 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Bluetooth 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Off 6: Off

Certmonger 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Cpuspeed 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Crond 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

XINETD-Based services:

Chargen-dgram: Off

Chargen-stream: Off

Daytime-dgram: Off

Daytime-stream: Off

Discard-dgram: Off

Discard-stream: Off

Echo-dgram: Off

Echo-stream: Off

Rsync: Off

Tcpmux-server: Off

Time-dgram: Off

Time-stream: Off

[[email protected] ~]# chkconfig rsync on -----Turn on rsync service

[[email protected] ~]# chkconfig rsync on --Turn off rsync service

Third, the self-starting control method of service

1. chkconfig + Service +on|off ----the machine restarts only take effect, and can only be the current runlevel.

You can view the current runlevel: RunLevel command.

2.Chkconfig--level Run level number (0-6) on |off you can specify which runlevel to take effect.

3. Sometimes we want to control the start and control of multiple services at the same time what to do, it is impossible to start a service. So we have a good tool for Linux:NTSYSV management Tools -graphical management tools, you can manage multiple services at the same time, select Open and close by space. Use the TAB key to toggle the options.

The following is a demo case:

[[Email protected] ~] # chkconfig--list ---Use this command to view the Crond at various operating levels

NetworkManager 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Abrt-ccpp 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

ABRTD 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

Acpid 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

ATD 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

AUDITD 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

AutoFS 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Blk-availability 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Bluetooth 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Off 6: Off

Certmonger 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Cpuspeed 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Crond 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off the--2345 are turned on

Now we turn off the 234 runlevel and then look at the

Time-stream: Off

[[email protected] ~]# chkconfig--level 234 crond off --------Turn off 234 of these runlevel

[Email protected] ~]# chkconfig--list

NetworkManager 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Abrt-ccpp 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

ABRTD 0: Off 1: Off 2: Off 3: Enable 4: Off 5: Enable 6: Off

Acpid 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

ATD 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

AUDITD 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

AutoFS 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Blk-availability 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Bluetooth 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Off 6: Off

Certmonger 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Cpuspeed 0: Off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Crond 0: Off 1: Off 2: Off 3: Off 4: Off 5: Enable 6: Off

If we manage multiple services right now, that's a direct knock NTSYSV command.

[Email protected] ~]# NTSYSV


Hat, Inc.

┌────────────┤ Service ├────────────┐

││

│ What services do you want to start automatically? │

││

│[*] Networkmanager↑│

│[*] Abrt-ccpp│

│[*] Abrtd│

│[*] Acpid│

│[*] Atd│

│[*] Auditd│

│[*] Autofs│

│[*] Blk-availability↓│

││

│┌──────┐┌──────┐│

││ OK ││ Cancel ││

│└──────┘└──────┘│

││

││

└────────────────────────────────┘

Click <F1> to get more information about a service.


The last is the basic management of service control, if there are some deficiencies, I hope that the bloggers can point out to me. We make progress together.

This article is from the Linux OPS blog, so be sure to keep this source http://dragon007.blog.51cto.com/7740555/1872590

Principles of control and management of Linux services

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.