?
RAID disk array
? Redundant array of Inexpensive disks
–redundant Arrays of Inexpensive Disks
– Through hardware/software technology, multiple small/low-speed disks are integrated into one
A large disk
– Value of the array: increased I/O efficiency, hardware-level data redundancy
– Different RAID level features and features vary
? RAID 0, stripe mode
– the same document is distributed across different disks
– Parallel writes for increased efficiency
Note: At least two disks are required. Divide the data into two pieces and deposit them separately. Read at the same time, so improve efficiency, but low reliability.
? RAID 1, mirroring mode
– One document is copied into multiple copies and written to different disks
– Multiple copies for increased reliability and no improvement in efficiency
Note: At least two disks are required. A copy of the data, deposited on two disks, increases reliability, but does not increase efficiency.
? RAID5, cost-effective mode
– a compromise equivalent to RAID0 and RAID1
– The capacity of at least one disk is required to hold the checksum data
Note: A minimum of three disks is required, at least one of which is used to store the checksum data, which can be repaired by part of the data and checksum data when one of the pieces is damaged. There are many applications in the enterprise, and hot backups of the disks are made in the enterprise, and when one of the disks is about to be damaged, the backup disk works to write the disk data that is about to be damaged.
? RAID6, cost-effective/Reliable mode
– 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
Note: At least four disks are required, at least two of which hold the checksum data, and can be repaired with partial data and checksum data when two disks are damaged. High cost
? RAID 0+1/raid 1+0
– Benefits of consolidating RAID 0, RAID 1
– Parallel access improves efficiency, mirroring writes improve reliability
Note: ratd 0+1 first in stripe mode and then mirror mode. The RAID 1+0 first takes the mirroring mode and then does the stripe mode. There are few applications in the enterprise.
? Hard raid: Managed array by raid control card
– Motherboard----> Array card----> Disk----> Operating system----> data
? Soft raid: Array managed by the operating system
– Motherboard----> Disk----> Operating system---->raid software-----> data
Note: The common way for enterprises is hard raid, because of the hard raid mode, high stability. Soft RAID Mode: When the operating system crashes, data is lost because the data is processed by the RAID software.
##################################################
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
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
[Email protected] ~]# Pstree
[Email protected] ~]# Pstree Lisi
Bash───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//can view the parent process (PPID) of the process, Pri/ni: Process priority, the smaller the value, the higher the priority.
[[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//view user's process
22636 Bash
22669 VIM//We generally use PSTREE-AP, because the structure is more obvious, we can clearly see the process of the parent process
[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% 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//through PID to kill process cannot pass process name
[Email protected]/]# jobs-l
[[email protected]/]# Killall sleep//Just terminate the process
[1]+ has terminated sleep 500
[Email protected]/]# jobs-l
[[email protected] ~]# killall-9 sleep//kill the process directly
[1]+ has killed sleep 400
To force a user to kick out:
[[email protected] ~]# killall-u Lisi//user is still in the login interface, but the process is all terminated.
[[email protected]/]# killall-9-u Lisi//user directly logged out.
####################################################
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 equivalent to Tail-f
1. Create a file in the current terminal and track it with TAILF
Terminal One:
[[email protected] ~]# Touch 1.txt
[Email protected] ~]# TAILF 1.txt
123
Terminal two:
2. Reopen a terminal, when we use echo to write to the 1.txt, terminal one on the screen will be real-time output, terminal two write content.
[Email protected] ~]# echo 123 > 1.txt
[Email protected] ~]#
#######################################################################################
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
################################################
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.
Note: We typically listen for events that are 4 and over 4.
###################################################
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"//View the information from 9:00 to 9:30, it is recommended to add date
[Email protected] ~]# Journalctl | grep Apache
November 01:24:46 svr7.tedu.cn systemd[1]: Starting the Apache HTTP Server ...
November 01:24:47 svr7.tedu.cn systemd[1]: Started the Apache HTTP Server.
When we query the HTTP service, enter Journalctl | grep httpd is not a query, because in the log information, there is no httpd this character.
[Email protected]/]# yum-y install httpd
[Email protected]/]# systemctl restart httpd
[[email protected]/]# journalctl-u httpd//Search by service name
[[email protected]/]# journalctl-n 10//show the last 10 messages
#########################################################
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 ...//start/stop/restart of service
? To view the health status of a service
–systemctl status|is-active Service Name ...//Query service status/active
Configuring power-on self-booting
? See if the service is self-starting
–systemctl is-enabled Service Name ...//query service is random self-booting
? Set whether the service is booted
–systemctl enable|disable Service Name ...//Set up service Random self-start/not self-starting
[Email protected]/]# systemctl status Crond
[Email protected]/]# Systemctl is-active Crond
Active
[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
Enabled
Manage RunLevel (run mode)
Character mode: Multi-user.target
Graphics mode: Graphical.target
View the default run mode
[Email protected]/]# Systemctl Get-default
Graphical.target//Current graphics mode
Set the default run mode
[[email protected]/]# systemctl set-default graphical.target//Set the default operating mode to graphical mode
[Email protected]/]# Systemctl Get-default
[[email protected]/]# reboot//Setup requires a reboot to take effect
Now enter the appropriate mode immediately
[[email protected]/]# Systemctl isolate multi-user.target//Enter command line mode now Multi-user.target
[[email protected]/]# Systemctl isolate graphical.target//Enter graphics mode now Graphical.target
######################################################
RAID disk array, process management, log management, SYSTEMCTL control