Performance optimizations for Linux

Source: Internet
Author: User
Tags ssh server virtual environment

Turn the notes of a great God.

Linux performance optimization: 1, CPU,MEM2, DISK--RAID3, network-related peripherals, NIC Linux system performance analysis: Top:linux system load, Cpu,mem,swap, CPU-and memory-intensive processes, killing high-performance processes. [[email protected] ~]# toptop-22:45:24 up 22:53, 5 users, Load average:0.00, 0.00, 0.00 Current time, boot time 22 hours 53 minutes, 5 users in Line, Linux system load (CPU Cores), last 1 minutes, last 5 minutes, last 15 minutes. tasks:151 Total, 1 running, sleeping, 0 stopped, 0 zombie the number of open processes is 151, 1 is running, 150 sleeps, 0 stops, and 0 blocks.  Cpu0:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stcpu1:0.0%us, 0.3%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stcpu2:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stcpu3:0 .0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Press 1 (123 of 1) to display all cores of the CPU. id,wa:id=100%,wa=0% indicates a very low system load. id=0%,wa=100% indicates that the system I carry is very high. id=100%,wa=100% indicates low CPU pressure, disk, network may be high pressure, possibly deadlock. id=0%,wa=0% indicates that CPU pressure is high, and processes are taking up CPU. mem:1914488k Total, 468192k used, 1446296k free, 73692k buffersswap:835576k total, 0k used, 835576k F REE, 240788k Cached physical memory is 2G, planning memory is 4Around 68M, the remaining memory is 1.44G, the shared cache is 73M, and the cache is 240M. Virtual memory is 835M, not used, remaining 835M. Using Memory: Cache + shared cache =320m[[email protected] ~]# cat/proc/meminfomemtotal:1914488 kbmemfree:1446568 kBBuff    ers:73940 KB shared Cache cached:240792 KB cache swapcached:0 kbactive:142040 kb Active cache inactive:196632 KB Inactive cache Active (anon): 24120 kbinactive (anon): kbactive (file): 117920 K Binactive (file): 196504 kbunevictable:0 KBL (lowercase) displays or shuts down the Linux system load line t to display or close processes and CPU lines. M displays or closes the memory line. 1 Displays or turns off multi-core CPU display. Z Displays or turns off color B to show or turn off high-load processes. K kills the process R to adjust the priority of the process, the default priority is 0, 20~-19-19 the highest priority. H View Help. The SAR shows CPU performance, disk, page, IO information. [[email protected] ~]# SAR 1 10[[email protected] ~]# SAR 1 10Linux 2.6.32-431.20.3.el6.x86_64 (asianux4) 20     September 18, 15 _x86_64_ (4 CPU) 23:14 13 seconds CPU%user%nice%system%iowait%steal%idle23 14 minutes 14 seconds  All 0.00 0.00 0.25 0.00 0.00 99.7523 Time 14 minute 15 seconds all    0.00 0.00 0.00 0.00 0.00 100.0023 Hours 14 minutes 16 seconds All 0.00 0.00 0.25 0.00 0      .00 99.7523 hours 14 minutes 17 seconds All 0.00 0.00 0.00 0.00 0.00 100.0023 Hours 14 minutes 18 seconds all 0.00 0.00 0.25 0.00 0.00 99.7523 Hours 14 minutes 19 seconds All 0.00 0.00 0.00 0.00 0.00 100.00 23:14 20 sec All 0.00 0.00 0.00 0.00 0.00 100.0023 Time 14 minutes 21 seconds All 0.00 0.00 0.     25 0.00 0.00 99.7523 Hours 14 minutes 22 seconds All 0.00 0.00 0.00 0.00 0.00 100.0023 14 minutes 23 seconds      All 0.00 0.00 0.00 0.00 0.00 100.00 Average Time: All 0.00 0.00 0.10 0.00      0.00 99.9023 hours 20 minutes 35 seconds CPU%user%nice%system%iowait%steal%idle23 20 minutes 36 seconds all 0.00 0.00 11.95 0.00 0.00 88.0523 Hours 20 minutes 38 seconds All 0.00 0.00 32.70 3.77 0.00 63.     5223 hours, 20 minutes, 39 seconds all 0.00 0.00 23.08 38.06 0.00 38.8723 hours 20 minutes 40 seconds All 0.00 0.00 7.02 26.32 0.00 66.6723 hours 20 minutes 41 seconds All 0.00 0.00 10.81 40.54 0.00 48.6523 20 minutes 42 seconds all 0.00 0. 20.49 42.62 0.00 36.89[[email protected] ~]# sar-d 1 scans per second.      23:23 07 sec DEV TPs rd_sec/s wr_sec/s avgrq-sz avgqu-sz await SVCTM%util23 23 minutes 08 seconds dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0023 Hours 23 minutes 08 Seconds dev8-16 0.00 0.00 0      .00 0.00 0.00 0.00 0.00 0.0023 Hours 23 minutes 08 seconds dev8-0 256.45 65651.61 0.00 256.00 2.60    10.16 6.18 158.3923 23 minutes 08 seconds dev8-32 143.55 12.90 102812.90 716.31 3.53 24.60 10.57 151.7723 23 minutes 08 seconds dev8-64 109.68 0.00 101161.29 922.35 3.07 25.90 14.74 161.6123 hours 23 minutes 08 seconds dev8 -80 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0023 23 minutes 08 seconds dev8-48 108.06 0.00 101161.29 936.12 2.86 24.33 13.60 146.94      23:23 08 sec dev253-0 254.84 65238.71 0.00 256.00 2.59 10.18 6.21 158.2323 hours 23 minutes 08 seconds dev253-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0023 Hours 23 minutes 08 seconds dev9-0 24879.03 12.90 199019      .35 8.00 0.00 0.00 0.00 0.0023 Hours 23 minutes 08 seconds dev253-2 24879.03 12.90 199019.35 8.00 829.52      28.60 0.07 175.0023 23 minutes 08 Seconds dev253-3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00vmstat shows the status of virtual memory.    [[email protected] ~]# vmstat 1procs-----------memory-------------Swap-------io------System-------CPU-----R B     SWPD free buff cache si so bi bo in CS us sy ID WA St 0 0 0 77268 21360 1652176 0 0  4 6 4 5 0 0 100 0 0 1 0 0 77260 21360 1652192 0 0 0 0 20 19 0 0 100 0 0 0 0     0 77244 21368 1652200 0 0 0 72 43 48 0 0 100 0 0 0 0 0 77244 21368 1652204 0 0  0 0 15 17 0 0 100 0 0 0 0 0 77244 21368 1652208 0 0 0 0 14 21 0 0 100 0 0 0      0 0 77244 21368 1652208 0 0 0 0 16 19 0 0 100 0 0 0 0 0 77244 21368 1652208 0 0 0 0 0 0 0 0 0 0 0 77244 21368 1652208 0 0 0 0 0 0 + 0 0io STAT Displays disk IO status.    [[email protected] ~]# iostat 1avg-cpu:%user%nice%system%iowait%steal%idle 0.00 0.00 28.04         10.14 0.00 61.82device:tps blk_read/s blk_wrtn/s blk_read blk_wrtnscd0 0.00               0.00 0.00 0 0SDB 0.00 0.00 0.00 0 0SDA      3.96 0.00 55.45 0 56SDC 121.78 182.18 51169.31 184 51681sdE 122.77 150.50 49347.52 49841sdf 0.00 0.00 0.00        0 0SDD 116.83 332.67 51232.67 336 51745dm-0 6.93 0.00 55.45 0 56dm-1 0.00 0.00 0.00 0 0MD0 1280 0.99 15.84 102392.08 103416dm-2 0.00 0.00 0.00 0 0 Dm-3 12801.98 15.84 102400.00 103424avg-cpu:%user%nice%system%iowait%steal%i Dle 0.00 0.00 13.83 16.60 0.00 69.57device:tps blk_read/s blk_wrtn/s blk_read Bl K_WRTNSCD0 0.00 0.00 0.00 0 0SDB 0.00 0.00 0.        0 0SDA 0.00 0.00 0.00 0 0SDC 78.00    24.00 40680.00     40680SDE 80.00 40.00 41680.00 41680sdf 0.00 0.0              0 0.00 0 0SDD 79.00 328.00 40680.00 328 40680dm-0          0.00 0.00 0.00 0 0dm-1 0.00 0.00 0.00 0          0md0 10136.00 0.00 81088.00 0 81088dm-2 0.00 0.00 0.00 0 0dm-3 10136.00 0.00 81088.00 0 81088PS display process [[email protected ] ~]# ps-ef shows all processes [[email protected] ~]# Ps-aux Displays details of all processes in the system. Pstree show Process tree [[email protected] ~]# Pstreeinit┬─networkmanager├─abrtd├─acpid├─atd├─auditd───{a uditd}├─automount───4*[{automount}]├─certmonger├─console-kit-dae───63*[{console-kit-da}]├─crond├─    Cupsd├─dbus-daemon├─hald─┬─hald-runner─┬─hald-addon-acpi ││└─hald-addon-inpu│└─{hald}├─httpd───8*[httpd]├─irqbalance├─4*[login─     ──bash]├─master─┬─pickup│└─qmgr├─mcelog├─2*[mingetty]├─modem-manager├─rpc.statd     ├─rpcbind├─rsyslogd───4*[{rsyslogd}]├─sshd───bash───pstree├─sshd├─udevd───2*[udevd]├─vsftpd └─wpa_supplicant[[email protected] ~] #显示系统运行的时间.  [[email protected] ~]# uptime 23:43:23 up 23:51, 5 users, Load average:0.03, 0.09, 0.10[[email protected] ~]# cat/proc/uptime85901.05 341926.67[[email protected] ~] #显示内存的情况: [[email protected] ~]# free-m Tota       L used free shared buffers cachedmem:1869 1800 68 0 21 1636-/+ buffers/cache:142 1727swap:815 0 815 Real use memory: 142+21=163m 1800-1636-1= 163M showing the status of multicore CPUs: mpstat[[email protected] ~]# mpstat-p all 123 49 minutes 44 seconds CPU%usr%Nice%sys%iowait%irq%soft%steal%guest%idle23 49 minutes 45 seconds All 0.00 0.00 0.00 0.00 0.00 0.00    0.00 0.00 100.0023 49 minutes 45 seconds 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.0023 Hours 49 minutes 45 seconds    1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.0023 Hours 49 minutes 45 seconds 2 0.00 0.00 0.97 0.00 0.00 0.00 0.00 0.00 99.0323 Hours 49 minutes 45 seconds 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100. 00 first column: Time second column: CPU and CPU number of cores third column: Percentage of CPU occupied by the user Fourth column: Percentage of CPU occupied by Priority Tuning Fifth column: System sixth column: Iowait IO waits for seventh column: Hard interrupt eighth column: Soft interrupt nineth column: percent of CPU in virtual CPU (used in virtual Environment) Tenth column: Percentage of CPU occupied by VM 11th column: Idle percentage of CPU displays the dynamic-link library file for the process and the size of the memory occupied. [[email protected] ~]# pmap-x 76527652:/usr/sbin/sshdaddress kbytes RSS Dirty Mode Mapping00007 f8ad1bf1000 0 0 r-x--libnss_files-2.12.so00007f8ad1bfd000 2048 0 0-----Libnss_file  s-2.12.so00007f8ad1dfd000 4 4 4 R----libnss_files-2.12.so00007f8ad1dfe000     4 4 4 rw---libnss_files-2.12.so00007f8ad1dff000 0 0 r-x--librt-2.12.so00007f8ad1e 06000 2044 0 0-----librt-2.12.so00007f8ad2005000 4 4 4 R----LIBRT-2.12.SO00007F8AD20 06000 4 4 4 rw---librt-2.12.so00007f8ad2007000 228 0 0 r-x--libnspr4.so00007f8ad2040       2048 0 0-----libnspr4.so00007f8ad2240000 4 4 4 R----libnspr4.so00007f8ad2241000 8 8 8 RW---libnspr4.so view the dynamic memory of processes in the system. [[email protected] ~]# cat while.sh#!/bin/bashwhile truedopmap-d 7652|tail-1sleep 2done[[email protected] ~ ]# chmod +x while.sh[[email protected] ~]# sh while.shmapped:66616k writeable/private:808k shared:0kmapped: 66616K writeable/private:808k shared:0kmapped:66616k writeable/private:808k shared:0k process debug: strace[[email& Nbsp;protected] ~]# strace-c-P 6610Process 6610 attached-interrupt to quitprocess 6610 detached% time seconds Usecs/call calls errors syscall------------------------------------------------------ ---------nan 0.000000 0 select-nan 0.000000 0 wait4- -------------------------------------------------------------100.00 0.000000 Displays a dynamic-link library of all processes in the current system.          [[email protected] ~]# lsof |grep vsftpdvsftpd 3788 root cwd DIR 253,0 4096               2/VSFTPD 3788 root RTD DIR 253,0 4096 2/vsftpd 3788 root txt REG 253,0 159568 176841/usr/sbin/vsftpdvsftpd 3788 root mem REG 253,0 12462 4 176040/lib64/libselinux.so.1vsftpd 3788 root mem REG 253,0 472064 163188/lib64/l Ibfreebl3.so ... After you have omitted to find the dynamic link library file, go to rpmfind.net or the shutdown URL to see/lib64/libpthread-2.12.so View the port of the native monitor. [[email protected] ~]# Lsof-icommand   PID USER FD TYPE DEVICE size/off NODE namerpcbind 1330 RPC 6u IPv4 10522 0t0 UDP *:sunrpcrpcbin D 1330 RPC 7u IPv4 10524 0t0 UDP *:rmcrpcbind 1330 RPC 8u IPv4 10525 0t0 TCP *:sunrpc (L  Isten) rpcbind 1330 RPC 9u IPv6 10527 0t0 UDP *:sunrpcrpcbind 1330 RPC 10u IPv6 10529 0t0 UDP *:rmcrpcbind 1330 RPC 11u IPv6 10530 0t0 TCP *:sunrpc (LISTEN) rpc.statd 1459 Rpcuser 5u IPv4 1080 8 0t0 UDP *:787rpc.statd 1459 rpcuser 8u IPv4 10816 0t0 UDP *:37593rpc.statd 1459 Rpcuser 9u IPv4 10   820 0t0 TCP *:58964 (LISTEN) rpc.statd 1459 Rpcuser 10u IPv6 10824 0t0 UDP *:59776rpc.statd 1459 Rpcuser 11u IPv6 10828 0t0 tcp *:39172 (LISTEN) cupsd 1494 root 6u IPv6 11113 0t0 TCP Localhost:ipp (LIST       EN) cupsd 1494 root 7u IPv4 11114 0t0 TCP Localhost:ipp (LISTEN) cupsd 1494 root 9u IPv4 11117 0t0 UDP *:ippmastEr 1753 root 12u IPv4 12026 0t0 TCP localhost:smtp (LISTEN) master 1753 root 13u IPv6 12028 0t0 TCP Localhost:smtp (LISTEN) vsftpd 3788 root 3u IPv4 17645 0t0 TCP *:ftp (LISTEN) sshd 5402 ro OT 3u IPv4 20693 0t0 TCP Asianux4:ethernet/ip-1->192.168.232.1:ndsconnect (established) rsyslogd 5880 Roo    T 3u IPv4 22305 0t0 UDP *:syslogrsyslogd 5880 root 4u IPv6 22306 0t0 UDP *:sysloghttpd 6610 Root 4u IPv6 23365 0t0 TCP *:http (LISTEN) httpd 6613 Apache 4u IPv6 23365 0t0 TCP *:http (LI      STEN) httpd 6614 Apache 4u IPv6 23365 0t0 TCP *:http (LISTEN) httpd 6615 Apache 4u IPv6 23365    0t0 TCP *:http (LISTEN) httpd 6616 Apache 4u IPv6 23365 0t0 TCP *:http (LISTEN) httpd 6617 Apache     4u IPv6 23365 0t0 TCP *:http (LISTEN) httpd 6618 Apache 4u IPv6 23365 0t0 TCP *:http (LISTEN) httpd  6619 Apache 4uIPV6 23365 0t0 TCP *:http (LISTEN) httpd 6620 Apache 4u IPv6 23365 0t0 TCP *:http (LISTEN) sshd 7652 root 3u IPv4 26541 0t0 tcp *:ssh (LISTEN) sshd 7652 Root 4u IPv6 26543 0t0 TCP *:ssh (LISTEN) sshd 7654 root 3r IPv4 26547 0t0 TCP Asianux4:ssh->192.168.232.1:solid-e-engine (established ) [[[email protected] ~]#[[email protected] ~]# netstat-atnupactive Internet connections (servers and        Established) Proto recv-q send-q Local address Foreign address State Pid/program NAMETCP 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1330/rpcbindtcp 0 0 0.0.0.0:                  58964 0.0.0.0:* LISTEN 1459/rpc.statdtcp 0 0 0.0.0.0:21                   0.0.0.0:* LISTEN 3788/vsftpdtcp 0 0 0.0.0.0:22 0.0.0.0:*      LISTEN 7652/sshdtcp  0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1494/cupsd view open ports and operating systems for remote hosts.  [[email protected] ~]# nmap 10.6.65.181Starting nmap 5.51 (http://nmap.org) at 2015-09-19 00:46 cstnmap Scan Report The For Client (10.6.65.181) Host was up (0.00086s latency). Not shown:997 filtered portsport state service21/tcp closed ftp22/tcp open ssh443/tcp closed Httpsmac address:00 : 0c:29:8c:61:1f (VMware) Nmap done:1 IP address (1 host up) scanned in 31.43 seconds[[email protected] ~]# nmap-o 10  .6.65.181Starting Nmap 5.51 (http://nmap.org) at 2015-09-19 00:47 cstnmap Scan report for client (10.6.65.181) Host was up (0.00079s latency). Not shown:997 filtered portsport state service21/tcp closed ftp22/tcp open ssh443/tcp closed Httpsmac address:00 : 0c:29:8c:61:1f (VMware) Device type:general purpose| Wap|specializedrunning (JUST guessing): Linux 2.6.x|2.4.x (89%), Netgear Embedded (89%), Linksys Linux 2.4.X (87%), Asus L Inux 2.6.X (87%), Crestron 2-serieS (86%) aggressive OS guesses:linux 2.6.23-2.6.33 (89%), Linux 2.6.31-2.6.34 (89%), Linux 2.6.9-2.6.27 (89%), Netgea  R dg834g WAP (89%), Linux 2.6.27 (Ubuntu 8.10) (88%), Linux 2.6.22 (Fedora Core 6) (88%), Linux 2.6.32 (88%), Linux 2.6.34 (88%), OpenWrt White Russian 0.9 (Linux 2.4.30) (87%), OpenWrt 0.9-7.09 (Linux 2.4.30-2.4.34) (87%) No exact OS Matche S for host (test conditions non-ideal). Network distance:1 hop[[email protected] ~]# telnet 10.6.65.181 22Trying 10.6.65.181...Connected to 10.6.65.181. Escape character is ' ^] '. Ssh-2.0-openssh_5.3connection closed by foreign host. [[email protected] ~] #查看主机的socket连接信息.                    SS and netstat command similar [[email protected] ~]# netstat-atnup|grep:21tcp 0 0 0.0.0.0:21 0.0.0.0:*                     LISTEN 3788/vsftpd[[email protected] ~]# ss-antup|grep:21tcp LISTEN 0 32 *:21 *:* Users: (("vsftpd", 3788,3)) [[email protected] ~] #抓包工具: tcpdump SnatchUser name and password for the FTP server. [[email protected] ~]# tcpdump-i eth0-nn-x ' Port 21 ' captures the communication packet of the SSH server. [[email protected] ~]# tcpdump-i eth0 host 192.168.232.1 and port 22 monitor network traffic iptraf[[email protected] ~]# Yum Inst All Iptraf-y[[email protected] ~]# unset lang[[email protected] ~]# Iptraf View network traffic

Performance optimizations for Linux

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.