First, the basic
The commands that display the number of physical CPUs are as follows:
Cat/proc/cpuinfo | grep "Physical ID" | Sort | Uniq | Wc-l
The commands that show the number of cores in each physical CPU (that is, the number of nuclei) are as follows:
Cat/proc/cpuinfo | grep "CPU Cores" |uniq
The commands that display the number of logical CPUs are as follows:
Cat/proc/cpuinfo | grep "Processor" | Wc-l
Viewing the I/O performance of a hard disk
Iostat–d-x–k 1 15
If%util is close to 100%, it indicates that there are too many I/O requests, the I/O system is full, and the disk may have bottlenecks.
The size of the await generally depends on the service time (SVCTM), and the length of the I/O queue and the emit mode of I/O requests. This response time should be less than 5ms, if more than 5ms means that the disk I/O pressure is very large, then you can consider replacing the faster response disk, adjust the kernel elevator algorithm, optimize the application or upgrade the CPU.
Find the top 10 files or directories in the system that occupy the most space:
Du-cks * | Sort-rn | Head-n 10
SED search IP
Ifconfig eth0 | grep ' inet addr ' |sed ' s/^.*addr://g ' | Sed ' s/bcast.*$//g '
Ifconfig eth0 | grep "inet addr:" |awk-f[: ""]+ ' {print $4} '
SED replacement
To change the Zhangsan in all files below the directory/modules to list
Sed-i ' s/zhangsan/list/g ' grep zhangsan-rl/modules '
View time period logs
Cat/var/log/secure | Sed-n '/12:48:48/,/12:48:55/p '
Find command
In the/logs directory, look for files that change time before 5th and delete them
How do I view the load?
Load average output value, the size of these three values can not be larger than the system logical CPU
, for example, the system in this output has 4 logical CPUs, if the load average three values longer than 4, the description
CPU is busy, high load, may affect the performance of the system, but occasionally more than 4 o'clock, do not worry, generally do not shadow
System performance. Conversely, if the output value of the load average is less than the number of CPUs, it means that the CPU is idle,
For example, the output in this example, the CPU is relatively idle.
This time can be combined with the Vmstat command to determine whether our system is too busy, if determined to be busy, it is necessary to test
Whether to replace the server or increase the number of CPUs. Summarized as follows:
If R is often greater than 3 or 4, and the ID is often less than 50, it means that the CPU is heavily loaded.
Vmstat 1 4
user%+sys%<70% indicates a better system performance, if user%+sys%>=85% or more, this
Indicates that the system performance is poor, then the system should be checked all aspects.
Linux View network connection status
Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
Linux Configuration Routing Route add-net 10.2.1.0 netmask 255.255.255.0 GW 10.2.1.253
Linux system View the method of public network IP exit
1. Add DNS echo "nameserver 202.96.64.68" >>/etc/resolv.conf ping www.baidu.com test
2. wget Http://members.3322.org/dyndns/getip
3. Cat GetIP
Nginx Log Analysis
Yum-y Install glib2 glib2-devel ncurses ncurses-devel GeoIP geoip-devel
Goaccess-f Access.log-c-A
If you need to analyze a day's logs, such as those on the October 5, we have Linux pipeline commands to ^_^.
Sed-n '/05\/dec\/2010/,$ p ' access.log | Goaccess-s–b
Analyze logs from November 5 to December 5 in one months
Sed-n '/5\/nov\/2010/,/5\/dec\/2010/p ' Access.log | Goaccess-s–b
Nginx Traffic Statistics
1. Statistics UV based on Access IP
awk ' {print '} ' Access.log|sort | Uniq-c |wc-l
2. Statistics Access URL Statistics PV
awk ' {print $7} ' access.log|wc-l
3. Query for the most frequently accessed URLs
awk ' {print $7} ' Access.log|sort | Uniq-c |sort-n-K 1-r|more
4. Querying the most frequently accessed IP
awk ' {print '} ' Access.log|sort | Uniq-c |sort-n-K 1-r|more
5. View logs based on time period statistics
Cat Access.log| Sed-n '/14\/mar\/2015:21/,/14\/mar\/2015:22/p ' |more
This article is from the "MJ Notes and summaries" blog, so be sure to keep this source http://024mj.blog.51cto.com/10252785/1720508
"Building a highly available Linux server" reading notes