RAID Array Overview
? 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
? 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
? 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
? 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
? RAID 0+1/raid 1+0
– Benefits of consolidating RAID 0, RAID 1
– Parallel access improves efficiency, mirroring writes improve reliability
#####################################################
Process Management
Program: Static code that takes up disk space
Process: Dynamic code that consumes CPU memory
父进程与子进程
#################################################
? 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 :所有进程的父进程
[Email protected]/]# Useradd Lisi
[Email protected]/]# Pstree Lisi
No process was found.
[Email protected]/]# Pstree Lisi
Bash───vim
[Email protected]/]# pstree-p Lisi
Bash (11715) ───vim (11838)
[Email protected]/]# Pstree-ap Lisi
[Email protected]/]# Pstree #查看整个进程数
#####################################################
? Ps-processes Snapshot
– Format: PS [options] ...
? Common Command Options
–aux: Displays all processes of the current terminal (a), the current user at all
Process under terminal (x), output in user format (U)
–-elf: Displays all processes within the system (-e), output in long format (-L)
Information, including the most complete process information (-f)
? PS aux operation
– List all processes that are running
? Ps-elf operation
– List all processes that are running
PPID: PID number of the parent process
###########################################
? Top Interactive tools
– Format: Top [-D refresh seconds] [-u user Name]
–p, M: Descending order According to%CPU,%MEM
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] ~]# who #查询当前那个用户正在登陆信息
[Email protected] ~]# pgrep-l log
[Email protected] ~]# Pgrep-l a
######################################################
Background boot
– Add the "&" symbol at the end of the command line without occupying the current terminal in the running state
? 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] 15343
[email protected]/]# jobs #查看后台进程信息
[1]+ Run in Sleep &
[Email protected]/]# jobs-l #查看后台进程详细信息
[1]+ 15343 running in Sleep &
[[email protected]/]# sleep 900
^z #按Ctrl +z pause into the background
[2]+ has stopped sleep 900
[[email protected]/]# jobs
[1]-Run in Sleep &
[2]+ has stopped sleep 900
[Email protected]/]# BG 2 #将后台编号为2的继续运行
[2]+ Sleep &
[[email protected]/]# FG 2 #将后台进程编号为2的恢复到前台
#######################################################
Kill process
? Different ways to kill a process
–ctrl+c key combination to interrupt the current command program
–kill [-9] PID ..., kill [-9]% background task number
–killall [-9] Process name ...
–pkill Find Criteria
-9 : 强制杀死
[Email protected]/]# sleep &
[1] 22924
[Email protected]/]# sleep &
[2] 22925
[Email protected]/]# sleep &
[3] 22926
[Email protected]/]# jobs-l
[[email protected]/]# kill 22926
[Email protected]/]# jobs-l
[Email protected]/]# Killall sleep #杀死所有sleep进程
[Email protected]/]# jobs-l
Force kick out a user: killall-9-u Lisi
##################################################
Log Management
? "Journal" of Systems and programs
– Record the various events that occur in the system and program operations
– Understand and troubleshoot by viewing logs
– The basis for information security control
/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
Log analysis
? General analysis Tools
–tail, Tailf, less, grep and other text browse/retrieve commands
–awk, sed and other format filtering tools
tailf : 实时跟踪日志消息
? 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
[Email protected]/]# LASTB
#################################################
Event urgency defined by the Linux kernel
– Divided into 0~7 a total of 8 priority levels
– The smaller the value, the more urgent/important the corresponding event
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
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]/]# yum-y install httpd
[Email protected]/]# systemctl restart httpd
[Email protected]/]# journalctl-u httpd
[Email protected]/]# Journalctl-n 10
[Email protected]/]# journalctl-u httpd-p 6 #查看6级别以上日志
#######################################################
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
? Linux system and Service Manager
– is the first initialization process loaded after kernel boot (pid=1)
– Responsible for controlling the entire Linux run/Service resource Mix
? Control Service Status
–systemctl Start|stop|restart Service Name ...
? To view the health status of a service
–systemctl status|is-active Service Name ...
Managing Run Levels
RHEL6
0: 关机 1: 单用户 2: 多用户的字符终端(不支持网络) 3: 多用户的字符终端(支持网络) 4: 未定义 5: 图形
Commands for switching runlevel: Init 0 init 6
####################################################
RHEL7
Multi-user.target #多用户的字符模式
Graphical.target #图形模式
Current switching mode:
[Email protected]/]# Systemctl isolate Graphical.target
[Email protected]/]# Systemctl isolate Multi-user.target
To permanently switch modes:
[Email protected]/]# Systemctl get-default #查看默认的模式
Multi-user.target
[Email protected]/]# Systemctl set-default graphical.target
[Email protected]/]# Systemctl Get-default
#######################################################
Path variable action: Provides a search path for the command program
[Email protected] ~]# Vim/opt/hello
#!/bin/bash
Echo Hahaxixi
[Email protected] ~]# chmod +x/opt/hello
[Email protected] ~]#/opt/hello
Hahaxixi
[email protected] ~]# Hello
Bash:hello: Command not found ...
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] ~]# cp/opt/hello/usr/bin/
[email protected] ~]# Hello
Hahaxixi
Why can't I find the prompt command?
1. Wrong order
2. Command not installed
3. The program that corresponds to the command is not in the path value
Write recurring Scheduled tasks: All commands are written in absolute paths
Find the program file that corresponds to the command: which date
##################################################
Netstat command: View network connection Information
-a:显示所有网络接口 -n:以数字的方式显示 -p:显示进程信息 -t:tcp协议连接
Established: Accessing
Listen: Listening
Linux Basic Operations 2