Linux-raid disk array, process management, log management, SYSTEMCTL control

Source: Internet
Author: User

RAID disk array

Inexpensive redundant disk array raid

–redundant Arrays of Inexpensive Disks

– Consolidate multiple small/low-speed disks into one large disk with hardware/software technology

– Value of the array: increased I/O efficiency, hardware-level data redundancy

– Different RAID level features and features vary


RAID 0, stripe mode (at least two disks)

– the same document is distributed across different disks

– Parallel writes for increased efficiency


RAID 1, mirroring mode (at least two disks)

– One document is copied into multiple copies and written to different disks

– Multiple copies for increased reliability and no improvement in efficiency


RAID5, cost-effective mode (at least three disks)

– a compromise equivalent to RAID0 and RAID1

– The capacity of at least one disk is required to hold the checksum data



RAID6, cost-effective/reliable mode (at least four disks)

– Equivalent to an extended RAID5 array with 2 independent calibration schemes

– The capacity of at least two disks is required to hold the checksum data


RAID 0+1/raid 1+0 (at least four disks)

– Benefits of consolidating RAID 0, RAID 1

– Parallel access improves efficiency, mirroring writes improve reliability



Hard raid: Managed array by raid control card

– Motherboard----> Array card----> Disk----> Operating system----> data


--------------------------------------------------------------------------------------------------------------- ---------------------------

Process Management


Program: Static code, occupy the space of the hard disk


Process: Dynamic code that takes up memory, CPU space


Parent process/child process

Identification of the process: PID


Killing a parent process can be killed together with all the sub-processes underneath it


View Process

Pstree-processes Tree

– Format: pstree [options] [PID or user name]


Common Command Options

–-a: Displays the full command line

–-p: List the corresponding PID number


SYSTEMD: Parent process for all processes

N

Re-open a svr7 virtual machine on the real machine

Create Lisi User

Switch to Lisi user Su-lisi

[Email protected] ~]# Pstree


[Email protected] ~]# Pstree Lisi

Bash───vim #显示lisi正在进入vim文本编辑

[Email protected] ~]# pstree-p Lisi

Bash (20356) ───vim (20387)

[Email protected] ~]# Pstree-ap Lisi

bash,20356

└─vim,20387 1.txt

--------------------------------------------------------------------------------------------------------------- ----------------------------


PS aux operation

– List all processes that are running


Ps-elf operation

– List all processes that are running


[[Email protected] ~]# PS aux | Wc-l

131

[Email protected] ~]# Ps-elf | Wc-l

131

[[Email protected] ~]# PS aux


[Email protected] ~]# ps-elf



Process Dynamic Ranking

Top Interactive tools

– Format: Top [-D refresh seconds] [-u user Name]


[Email protected] ~]# top-d 1 #每隔一秒刷新

Enter uppercase p to sort by CPU

Enter uppercase M sorted by memory

Enter Q to exit



--------------------------------------------------------------------------------------------------------------- ---------------------------------

Retrieval process

Pgrep-process Grep

– Purpose: pgrep [options] ... Query criteria

Common Command Options

–-l: Output process name, not just PID

–-u: Retrieving the process for a specified user

–-T: Retrieving the process for the specified terminal

–-x: Exact match to Full process name


[Email protected] ~]# Pstree-ap Lisi

bash,22636

└─vim,22669 1.txt

[Email protected] ~]# Pgrep-lu Lisi

22636 Bash

22669 vim


[Email protected] ~]# pgrep-l Crond

[Email protected] ~]# pgrep-l sshd

[Email protected] ~]# pgrep-l log


--------------------------------------------------------------------------------------------------------------- -------------------------

Front and back scheduling of processes

Background boot

– Add the "&" symbol at the end of the command line without occupying the current terminal


Ctrl + Z key combination

– Suspends the current process (pauses and goes back into the background)

Jobs command

– View Background Task List

FG Command

– Restore background tasks to foreground run

BG Command

– Activate a task that is suspended from the background



--------------------------------------------------------------------------------------------------------------- --------------------------


[Email protected] ~]# Sleep & #正在运行放入后台

[1] 23304

[[email protected] ~]# jobs


[[email protected] ~]# jobs-l #查看后台进程信息, and output PID


[[email protected] ~]# sleep #按Ctrl +z pause into the background

^z

[2]+ has stopped sleep 700

[Email protected] ~]# jobs-l


[[email protected] ~]# BG 2 #将后台暂停的进程, continue running


[[email protected] ~]# FG 2 #将后台的进程, back to the front desk

[[email protected] ~]# FG 1



--------------------------------------------------------------------------------------------------------------- ---------------------------------


Please write the shell script:

The user enters an integer within 10

The computer randomly generates an integer within 10

If two integers are the same, the output is "congratulations, winning."

If two integers are not the same, the output "Congratulations, thank you for your review"


#!/bin/bash

Read-p ' Please enter an integer within 10: ' NUM1

num2=$ (expr $RANDOM%) #RANDOM: a random number; "% 10": Remainder less than 10

If [$num 1-eq $num 2];then

Echo, Congratulations, you won the lottery.

Else

Echo Congratulations, thank you for your review

echo the correct number for $num2

Fi



--------------------------------------------------------------------------------------------------------------- ---------------------------------


Kill process

Different ways to kill a process

–ctrl+c key combination to interrupt the current command program

–kill [-9] PID ...

–killall [-9] Process name ...

–pkill Find Criteria



[Email protected]/]# sleep &

[Email protected]/]# sleep &

[Email protected]/]# sleep &


[Email protected]/]# jobs-l


[[email protected]/]# kill 301127

[Email protected]/]# jobs-l


[[email protected]/]# Killall sleep

[Email protected]/]# jobs-l


To force a user to kick out:

[Email protected]/]# killall-9-u Lisi



--------------------------------------------------------------------------------------------------------------- ---------------------------------

Features of the log

"Journal" of Systems and programs

– Record the various events that occur in the system and program operations

– Understand and troubleshoot by viewing logs

– "Basis" for information security control


Common Log files

Log file

/var/log/messages record kernel messages, public messages for various services

/VAR/LOG/DMESG recording the various messages of the system startup process

/var/log/cron record messages related to cron scheduled tasks

/var/log/maillog record messages related to sending and receiving mail

/var/log/secure record security messages related to access restrictions



Real-time tracking of new log messages

TAILF (TAIL-F)


User Login Analysis

Users, who, W commands

– View logged-in user information with varying degrees of detail

Last, Lastb command

– View user information for recent login success/failure


[[email protected]/]# users


[email protected]/]# who

[Email protected]/]# W


[Email protected]/]# last-2

[Email protected]/]# lastb-2


--------------------------------------------------------------------------------------------------------------- -------------------------------

Log Message priority:

0 Emerg (Emergency) causes the host system to become unusable

1 alert (warning) must take immediate action to solve the problem

2 crit (severe) more serious situation

3 Err (Error) Run error

4 WARNING (Reminder) events that may affect system functionality

5 NOTICE (note) does not affect the system but is worth noting

6 info (info) General Information

7 Debug (Debug) program or system debug information, etc.

--------------------------------------------------------------------------------------------------------------- ------------------------------


Using the Journalctl tool

Extracting logs collected by the Systemd-journal service

– Mainly includes kernel/system logs, service logs

Common usage

–journalctl | grep keyword

–journalctl-u service name [-p priority]

–journalctl-n Number of message bars

–journalctl--since= "Yyyy-mm-dd HH:MM:SS"

--until= "Yyyy-mm-dd HH:MM:SS"

[Email protected]/]# journalctl--since= "9:00am"--until= "9:30"


[Email protected]/]# yum-y install httpd

[Email protected]/]# systemctl restart httpd

[Email protected]/]# journalctl-u httpd


[Email protected]/]# Journalctl-n 10


--------------------------------------------------------------------------------------------------------------- --------------------------------

Systemctl Control


Systemd

A more efficient system & Service Manager

– Start-up service in parallel, precise dependencies between system services

– Configuration directory:/etc/systemd/system/

– Service Catalog:/lib/systemd/system/


– Primary management tool: Systemctl



Control Service Status

–systemctl Start|stop|restart Service Name ...


To view the health status of a service

–systemctl status|is-active Service Name ...


Configuring power-on self-booting

See if the service is self-starting

–systemctl is-enabled Service Name ...

Set whether the service is booted

–systemctl enable|disable Service Name ...


[Email protected]/]# systemctl status Crond

[Email protected]/]# Systemctl is-active Crond

[Email protected]/]# systemctl restart Crond


[Email protected]/]# Systemctl stop Crond

[Email protected]/]# systemctl status Crond

[Email protected]/]# Systemctl is-active Crond


[Email protected]/]# Systemctl is-enabled Crond


Manage RunLevel (run mode)

Character mode: Multi-user.target

Graphics mode: Graphical.target


View the default run mode

[Email protected]/]# Systemctl Get-default


Set the default run mode

[Email protected]/]# Systemctl set-default graphical.target


[Email protected]/]# Systemctl Get-default


[email protected]/]# reboot

Now enter the appropriate mode immediately

[Email protected]/]# Systemctl isolate Multi-user.target


[Email protected]/]# Systemctl isolate Graphical.target

Linux-raid disk array, process management, log management, SYSTEMCTL control

Related Article

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.