Troubleshooting Performance Issues:
Linux system has a performance problem, generally we can use top, iostat, free, vmstat and other commands to view the initial positioning problems.
Memory resource consumption: Free command
IO occupancy:
Iostat-d-K 1 #查看TPS和吞吐量信息
iostat-d-x-k 1 #查看设备使用率 (%util), Response time (await)
Iostat-c 1 #查看cpu状态
Disk usage Statistics:
Df-lh
Du-h/mnt/disk1/hdh/
Du-sh *
CPU, disk, network usage statistics:
Dstat
Current number of TCP connections view:
Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
Linux System Cache Release:
Echo 3 >/proc/sys/vm/drop_caches
To view the services installed under Linux:
Chkconfig--list
Close swap:
Swap is the virtual memory partition under Linux, which is used to virtualize disk space (that is, the swap partition) into memory after the physical memory is exhausted.
To turn off swap, perform the following steps.
1)
# Swapoff–a
# sysctl Vm.swappiness=0
2)
Edit/etc/sysctl.conf to add the following:
Vm.swappiness=0
3)
Re-execution:
Sysctl–p
To verify that swap is off. Execute the following command if swap is closed successfully, then return 0
Cat/proc/sys/vm/swappiness
Linux under. and.
. The dot number with a space is equivalent to the source command, which indicates that the command or script following the execution of the current shell environment (without adding a new shell is executed by default). For example. /home/test.sh is equivalent to source/home/test.sh.
Any changes made by the script executed with source will affect the current shell (such as a useful CD that changes the directory, the directory is changed after the script executes), and if the source is not used, it will not affect the current shell.
A child shell that runs with a. (space) and exits the parent shell when the exit command is executed in a child shell
. ./test.sh
Represents the test.sh script that executes the current directory in the current shell in source mode.
CPU Information view under Linux
# total number of cores = number of physical CPUs X number of cores per physical CPU
# Total Logical CPUs = number of physical CPUs x number of cores per physical CPU X number of hyper-threads
# View the number of physical CPUs
cat/proc/cpuinfo| grep "Physical ID" | Sort| uniq| Wc-l
# See the number of cores in each physical CPU (that is, the number of nuclei)
cat/proc/cpuinfo| grep "CPU Cores" | Uniq
# View the number of logical CPUs
cat/proc/cpuinfo| grep "Processor" | Wc-l
Remote script Execution
SSH [-P $port] [[email protected]] $ip ' cmd '
$port: SSH Connection port number
$user: SSH connection user name
$IP: The IP address of the SSH connection
CMD: What the remote server needs to do
The-t parameter of SSH
can provide a remote server virtual TTY terminal, plus this parameter we can be on the remote server's virtual terminal to enter their own access code, very safe
the meaning of shell variable $#,[email protected],$0,$1,$2 in Linux is explained:
Variable Description:
$$
The PID of the shell itself (ProcessID)
$!
PID of the Shell's last running background process
$?
End code of the last Run command (return value)
$-
Flag at a glance using the SET command
$*
All parameter lists. such as "$*" in the Case of "" ", in the form of" $ $ ... $n "output all parameters.
[Email protected]
All parameter lists. such as "[email protected]" with "" "in the case, with" $ "" $ "... All parameters are output in the form "$n".
$#
Number of arguments added to the shell
$
The name of the shell itself
$1~ $n
Each parameter value added to the shell. $ $ is the 1th parameter, and the $ = is the 2nd parameter ....
The meaning of the shell (. file.sh) equivalent to souce or include introducing functions (libraries)
Array Traversal:
array= (element1 element2 element3 .... elementn)
#echo ${array[0]}
For data in ${array[@]}
Do
Echo ${data}
Done
Script relative path
The relative path to the script execution is relative to the path of the current directory, not the directory where the script resides
Service path
/etc/rc.d/init.d/network restart
Replace
:%s/lark001/hadoop17/g
:%s/lark002/hadoop19/g
:%s/lark003/hadoop20/g
Exit command
Exit-cause the Shell to exit
Linux Learning Notes