In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Chapter 5: system Services
1. Service catalog
In the previous Redhat Linux5.x&6.x system, we know that the services of the system are stored in the / etc/init.d directory, but in the RHEL7.x system, it has changed as follows:
-- View the system service path before RHEL7--
[root@ freeit ~] # cd / etc/init.d/
[root@ freeit init.d] # ls
Abrt-ccpp iscsi restorecond
Abrtd iscsid rhnsd
Abrt-oops kdump rhsmcertd
Acpid killall rngd
Atd libvirt-guests rpcbind
Auditd lldpad rpcgssd
Autofs lvm2-lvmetad rpcidmapd
Blk-availability lvm2-monitor rpcsvcgssd
Bluetooth mdmonitor rsyslog
Certmonger messagebus sandbox
Cgconfig multipathd saslauthd
Cgred mysqld single
Cpuspeed named smartd
Crond netconsole snmpd
Cups netfs snmptrapd
Dhcpd network spice-vdagentd
Dhcpd6 NetworkManager sshd
Dhcrelay nfs sssd
Dnsmasq nfslock sysstat
Fcoe ntpd udev-post
Firstboot ntpdate vmware-tools
Functions oddjobd vmware-tools-thinprint
Haldaemon openct vncserver
Halt pcscd wdaemon
Htcacheclean portreserve winbind
Httpd postfix wpa_supplicant
Ip6tables psacct xinetd
Iptables quota_nld ypbind
Irqbalance rdisc
-- check the / etc/init.d/ directory of RHEL7--
[root@ freeit tmp] # cd / etc/init.d/
[root@ freeit init.d] # ls
Functions iprinit netconsole README
Iprdump iprupdate network rhnsd
/ / as above, this directory is no longer the path where the system service is located, so the restart service cannot be started using / etc/init.d servername restart
two。 Next startup status of the service
On systems before RHEL7.x, the command chkconfig-list can be used to view the next startup status of all services, but in RHEL7, this command is no longer available
[root@ freeit] # chkconfig-- list
Note: This output shows SysV services only and does not include native
Systemd services. SysV configuration data might be overridden by native
Systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
Iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Rhnsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
/ / this command lists only some basic services. To see all of them, follow the prompt (bold font)
-systemctl list-unit-files-
[root@ freeit ~] # systemctl list-unit-files
UNIT FILE STATE
Proc-sys-fs-binfmt_misc.automount static
Dev-hugepages.mount static
Dev-mqueue.mount static
Proc-fs-nfsd.mount static
Proc-sys-fs-binfmt_misc.mount static
Sys-fs-fuse-connections.mount static
Sys-kernel-config.mount static
Sys-kernel-debug.mount static
Tmp.mount disabled
Var-lib-nfs-rpc_pipefs.mount static
Brandbot.path disabled
Cups.path enabled
Systemd-ask-password-console.path static
Systemd-ask-password-plymouth.path static
... ..
3. System operation level
In RHEL7, the running level of the system is no longer 0-6. Run-level inittab files no longer contain 0-6 level descriptions. As follows:
[root@ freeit ~] # vim / etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by / etc/systemd/system/ctrl-alt-del.targe
T
#
# systemd uses' targets' instead of runlevels. By default, there are t
Wo main targets:
#
# multi-user.target: analogous to runlevel 3
/ / equivalent to runlevel 3, command line interface
# graphical.target: analogous to runlevel 5
/ / equivalent to runlevel 5, graphical interface
#
# To set a default target, run:
#
# ln-sf / lib/systemd/system/.target / etc/systemd/system/
Default.target
#
~
View the system default run level
[root@ freeit ~] # systemctl get-default
Graphical.target
/ / the default run level is graphical interface
Set the default run level
[root@ freeit ~] # systemctl set-default multi-user.target
[root@ freeit ~] # systemctl get-default
Multi-user.target
View the service status of the set runlevel (next startup status)
[root@ freeit ~] # systemctl list-unit-files | grep multi-user
Multi-user.target enabled
4. Next startup status of the service
We know that for the next restart to take effect after the service is started, the command chkconfig servername on is used before RHEL7, but it is no longer available in RHEL7. So how to set it up, look at the following example:
[root@ freeit ~] # systemctl restart postfix.service
/ / start the mail service
[root@ freeit ~] # systemctl status postfix.service
/ / View the running status of the mail service
Postfix.service-Postfix Mail Transport Agent
Loaded: loaded (/ usr/lib/systemd/system/postfix.service; enabled)
/ / enable the next startup
Active: active (running) since Mon 2015-05-04 11:03:42 CST; 14s ago
/ / currently running
Process: 4611 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
Process: 4626 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 4623 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 4621 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 4698 (master)
CGroup: / system.slice/postfix.service
├─ 4698 / usr/libexec/postfix/master-w
├─ 4699 pickup-l-t unix-u
└─ 4700 qmgr-l-t unix-u
May 04 11:03:42 localhost.localdomain systemd [1]: Starting Postfix Ma...
May 04 11:03:42 localhost.localdomain postfix/master [4698]: daemon st...
May 04 11:03:42 localhost.localdomain systemd [1]: Started Postfix Mai...
Hint: Some lines were ellipsized, use-l to show in full.
-turn it off and start it up next time-
[root@ freeit ~] # systemctl disable postfix.service
Rm'/ etc/systemd/system/multi-user.target.wants/postfix.service'
[root@ freeit ~] # systemctl status postfix.service
Postfix.service-Postfix Mail Transport Agent
Loaded: loaded (/ usr/lib/systemd/system/postfix.service; disabled)
Active: active (running) since Mon 2015-05-04 11:03:42 CST; 4min 30s ago
Main PID: 4698 (master)
CGroup: / system.slice/postfix.service
├─ 4698 / usr/libexec/postfix/master-w
├─ 4699 pickup-l-t unix-u
└─ 4700 qmgr-l-t unix-u
May 04 11:03:42 localhost.localdomain systemd [1]: Starting Postfix Ma...
May 04 11:03:42 localhost.localdomain postfix/master [4698]: daemon st...
May 04 11:03:42 localhost.localdomain systemd [1]: Started Postfix Mai...
Hint: Some lines were ellipsized, use-l to show in full.
/ / after the next restart takes effect, restart the system and the mail service will be turned off.
Restart verification after shutdown
[root@ freeit ~] # systemctl status postfix.service
Postfix.service-Postfix Mail Transport Agent
Loaded: loaded (/ usr/lib/systemd/system/postfix.service; disabled)
Active: inactive (dead)
/ / not started
Restart the mail service and set the next boot
[root@ freeit ~] # systemctl restart postfix
[root@localhost ~] # systemctl enable postfix.service
Ln-s'/ usr/lib/systemd/system/postfix.service''/ etc/systemd/system/multi-user.target.wants/postfix.service'
[root@ freeit ~] # systemctl status postfix.service
Postfix.service-Postfix Mail Transport Agent
Loaded: loaded (/ usr/lib/systemd/system/postfix.service; enabled)
Active: active (running) since Mon 2015-05-04 11:12:14 CST; 35s ago
Main PID: 2994 (master)
CGroup: / system.slice/postfix.service
├─ 2994 / usr/libexec/postfix/master-w
├─ 2995 pickup-l-t unix-u
└─ 2996 qmgr-l-t unix-u
May 04 11:12:14 localhost.localdomain systemd [1]: Starting Postfix Ma...
May 04 11:12:14 localhost.localdomain postfix/master [2994]: daemon st...
May 04 11:12:14 localhost.localdomain systemd [1]: Started Postfix Mai...
Hint: Some lines were ellipsized, use-l to show in full.
5. Service status related commands
View current startup status
[root@ freeit ~] # systemctl is-active postfix.service
Active
/ / currently running
Close the current running status and view it again
[root@ freeit ~] # systemctl stop postfix.service
[root@ freeit ~] # systemctl is-active postfix.service
Inactive
Check the next boot status
[root@ freeit ~] # systemctl is-enabled postfix.service
Enabled
/ / the next boot will start.
Turn off the next boot and check it again
[root@ freeit ~] # systemctl disable postfix.service
Rm'/ etc/systemd/system/multi-user.target.wants/postfix.service'
[root@localhost ~] # systemctl is-enabled postfix.service
Disabled
6. Locking Service (mask)
Example 1: perform a mask operation on the postfix service, and then perform a restart operation
[root@ freeit ~] # systemctl mask postfix
Ln-s'/ dev/null''/ etc/systemd/system/postfix.service'
[root@localhost ~] # systemctl restart postfix
Failed to issue method call: Unit postfix.service is masked.
/ / failed to restart the service
[root@ freeit ~] # systemctl status postfix
Postfix.service
Loaded: masked (/ dev/null)
Active: inactive (dead)
May 04 11:12:14 localhost.localdomain systemd [1]: Starting Postfix Ma...
May 04 11:12:14 localhost.localdomain postfix/master [2994]: daemon st...
May 04 11:12:14 localhost.localdomain systemd [1]: Started Postfix Mai...
May 04 11:18:39 localhost.localdomain systemd [1]: Stopping Postfix Ma...
May 04 11:18:39 localhost.localdomain systemd [1]: Stopped Postfix Mai...
Hint: Some lines were ellipsized, use-l to show in full.
Example 2: unlock the service and restart again
[root@ freeit ~] # systemctl unmask postfix
/ / unlock
Rm'/ etc/systemd/system/postfix.service'
[root@ freeit ~] # systemctl restart postfix
/ / restart successfully
[root@ freeit ~] # systemctl status postfix
Postfix.service-Postfix Mail Transport Agent
Loaded: loaded (/ usr/lib/systemd/system/postfix.service; disabled)
Active: active (running) since Mon 2015-05-04 11:29:36 CST; 3s ago
Process: 3529 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 3527 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 3524 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 3601 (master)
CGroup: / system.slice/postfix.service
├─ 3601 / usr/libexec/postfix/master-w
├─ 3602 pickup-l-t unix-u
└─ 3603 qmgr-l-t unix-u
May 04 11:29:36 localhost.localdomain postfix/master [3601]: daemon st...
May 04 11:29:36 localhost.localdomain systemd [1]: Started Postfix Mai...
Hint: Some lines were ellipsized, use-l to show in full.
7. System process 7.1. View the system process in real time
Top-11:34:23 up 25 min, 1 user, load average: 0.00,0.01,0.05
Tasks: 297 total, 4 running, 293 sleeping, 0 stopped, 0 zombie
% Cpu (s): 0.0 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem: 1010788 total, 306908 used, 703880 free, 1080 buffers
KiB Swap: 2097148 total, 0 used, 2097148 free. 110788 cached Mem
PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND
3651 root 20 0 123788 1772 1148 R 0.3 0.2 0:00.03 top
1 root 20 0 53948 7808 2548 S 0.0 0.8 0:05.08 systemd
2 root 20 00 00 S 0.0 0.00: 00.00 kthreadd
3 root 20 00 00 R 0.0 0.0 0:00.04 ksoftirqd/0
5 root 0-20 000 S 0.0 0.00: 00.00 kworker/0:0H
7 root rt 00 00 S 0.0 0.00: 00.00 migration/0
8 root 20 00 00 S 0.0 0.00: 00.00 rcu_bh
... ..
-for a more detailed view, press 1muri-
Top-11:35:00 up 25 min, 1 user, load average: 0.00,0.01,0.05
Tasks: 297 total, 2 running, 295 sleeping, 0 stopped, 0 zombie
% Cpu0: 0.7 us, 0.7 sy, 0.0 ni, 98.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 1010788 total, 307172 used, 703616 free, 1080 buffers
KiB Swap: 2097148 total, 0 used, 2097148 free. 110788 cached Mem
PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND
879 root 20 0 193424 4168 3344 S 1.0 0.4 0:02.80 vmtoolsd
3651 root 20 0 123788 1772 1148 R 0.7 0.20: 00.20 top
1 root 20 0 53948 7808 2548 S 0.0 0.8 0:05.08 systemd
2 root 20 00 00 S 0.0 0.00: 00.00 kthreadd
3 root 20 00 00 S 0.0 0.0 0:00.04 ksoftirqd/0
5 root 0-20 000 S 0.0 0.00: 00.00 kworker/0:0H
7 root rt 00 00 S 0.0 0.00: 00.00 migration/0
8 root 20 00 00 S 0.0 0.00: 00.00 rcu_bh
Press Q key to exit the process
The first 5 lines say:
The first five lines are statistics of the system as a whole.
The first line is the task queue information, which is the same as the execution result of the uptime (View server startup time) command. The contents are as follows:
11:34:23: current time
Up 1:13: system run time, format: hours: minutes
1 user: number of currently logged in users
Load average: 0.00,0.01,0.05: system load, that is, the average length of the task queue. The three values are the average values from 1 minute, 5 minutes and 15 minutes ago to the present.
Second, third behavior process and CPU information. When there is more than one CPU, the content may be more than two lines, as follows:
Tasks: 297 total: total number of processes
4 running: number of processes running
293 sleeping: number of sleep processes
0 stopped: number of stopped processes
0 zombie: zombie process
% Cpu (s): 0.0 us: percentage of CPU occupied by user space
0.0 sy: percentage of CPU occupied by kernel space
0.0 ni: percentage of CPU occupied by processes that have changed priorities in the user's process space
99.7% id:id idle CPU
0.0 percentage of CPU time wa:wa waits for input and output
0.0 hi 0.3 si, 0.0 st
The last two behaviors are memory information. The contents are as follows:
KiB Mem: 1010788 total: total physical memory
306908 used: total amount of physical memory used
703880 free: total amount of physical memory free
1080 buffers: amount of physical memory used as kernel cache
KiB Swap: 2097148 total: total exchange area
0 used: the total number of swap partitions used
2097148 free: total number of swap areas free
110788 cached Mem: the total number of swap areas buffered.
Process area information description:
PID: process ID
USER: process owner
PR: process priority
NI: nice value. Negative values indicate high priority; positive values indicate low priority
VIRT: the total amount of virtual memory used by the process, in Kb,VITR=SWAP+RES
RES: the amount of physical memory used by the process that has not been swapped out, in KB,RES=CODE+DATA
SHR: shared memory size (in Kb)
S: process statu
% CPU: percentage of CPU time war since last update
% MEM: percentage of physical memory used by the process
Total CPU time used by the TIME+: process (in 100 seconds)
COMMAND: command name / command line
7.2. Statically view the current process status
[root@ freeit ~] # ps aux
USER PID CPU MEM VSZ RSS TTY STAT START TIME COMMAND
Root 1 0.3 0.7 53948 7808? Ss 11:09 0:05 / usr/lib/systemd/systemd-s
Root 2 0.0 0.0 0 0? S 11:09 0:00 [kthreadd]
Root 3 0.0 0.0 0 0? S 11:09 0:00 [ksoftirqd/0]
Root 5 0.0 0.0 0 0? S < 11:09 0:00 [kworker/0:0H]
Root 7 0.0 0.0 0 0? S 11:09 0:00 [migration/0]
Root 8 0.0 0.0 0 0? S 11:09 0:00 [rcu_bh]
Root 9 0.0 0.0 0 0? S 11:09 0:00 [rcuob/0]
Root 10 0.0 0.0 0 0? S 11:09 0:00 [rcuob/1]
Root 11 0.0 0.0 0 0? S 11:09 0:00 [rcuob/2]
Root 12 0.0 0.0 0 0? S 11:09 0:00 [rcuob/3]
... .
Common parameters:
-a: a process that contains all terminals
-u: displays the owner of the process
-x: displays processes that do not belong to any terminal
-f: displays the parent-child relationship of the process
7.3. View the process tree
[root@ freeit ~] # pstree
Systemd ─┬─ ModemManager ─── 2 * [{ModemManager}]
├─ NetworkManager ─── 2 * [{NetworkManager}]
├─ 2 * [abrt-watch-log]
├─ abrtd
├─ agetty
├─ alsactl
├─ atd
├─ auditd ─┬─ audispd ─┬─ sedispatch
│ │ └─ {audispd}
│ └─ {auditd}
├─ avahi-daemon ─── avahi-daemon
├─ bluetoothd
├─ chronyd
├─ crond
├─ dbus-daemon ─── {dbus-daemon}
├─ firewalld ─── {firewalld}
├─ iprdump
├─ iprinit
├─ iprupdate
├─ ksmtuned ─── sleep
├─ libvirtd ─── 10 * [{libvirtd}]
├─ lsmd
├─ lvmetad
├─ master ─┬─ pickup
│ └─ qmgr
├─ packagekitd ─── 2 * [{packagekitd}]
├─ polkitd ─── 5 * [{polkitd}]
├─ rhsmcertd
├─ rngd
├─ rpc.statd
├─ rpcbind
├─ rsyslogd ─── 2 * [{rsyslogd}]
├─ smartd
├─ sshd ─── sshd ─── bash ─── pstree
├─ systemd-journal
├─ systemd-logind
├─ systemd-udevd
├─ tuned ─── 4 * [{tuned}]
└─ vmtoolsd
8. Foreground and backstage (fg&bg)
Example: copy / usr to / tmp, because it takes a long time to copy, call to the background to copy. And then call it to the front desk. Pause again during the period, call to the background, and finally kill the process.
[root@ freeit] # cp-r / usr / tmp/ &
[1] 3991
/ / start replication, & execute for the background
[root@ freeit ~] # jobs
[1] + Running cp-I-r / usr / tmp/ &
/ / View the actions performed in the background
[root@ freeit ~] # fg 1
Cp-I-r / usr / tmp/
/ / call to the foreground to execute the process
^ Z
[1] + Stopped cp-I-r / usr / tmp
/ / Press ctrl+z to stop the process
[root@ freeit ~] # bg 1
[1] + cp-I-r / usr / tmp/ &
/ / continue to call to the background for execution
[root@ freeit ~] # jobs
[1] + Running cp-I-r / usr / tmp/ &
[root@ freeit ~] # kill 1
/ / end this process
[root@ freeit ~] # jobs
[1] + Terminated cp-I-r / usr / tmp/
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.