Linux運維必須知道的幾個命令

1、查看物理CPU個數
[root@easfin bin]# cat /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l
2

  1. [root@easfin bin]# cat /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l 

2、每個物理CPU中core的個數(即核數)

  1. [root@easfin bin]# cat /proc/cpuinfo |grep "cpu cores"|uniq 
  2. cpu cores : 8 

3、查看邏輯CPU的個數
 

  1. [root@easfin bin]# cat /proc/cpuinfo |grep "processor" |wc -l 
  2. 32 


按理說物理CPU個數×核數=邏輯CPU的個數,如果不等,說明服務器支持超線程技術。

4、查看硬盤及分區信息

  1. [root@easfin logs]# fdisk -l 
  2.  
  3. Disk /dev/sda: 299.4 GB, 299439751168 bytes 
  4. 255 heads, 63 sectors/track, 36404 cylinders 
  5. Units = cylinders of 16065 * 512 = 8225280 bytes 
  6.  
  7.    Device Boot      Start         End      Blocks   Id  System 
  8. /dev/sda1   *           1        3916    31455238+  83  Linux 
  9. /dev/sda2            3917        8093    33551752+  82  Linux swap / Solaris 
  10. /dev/sda3            8094       36404   227408107+  8e  Linux LVM 

5、查看硬盤空間使用情況
 

  1. [root@easfin logs]# df -h 
  2. Filesystem            Size  Used Avail Use% Mounted on 
  3. /dev/sda1              30G   22G  6.2G  78% / 
  4. tmpfs                  32G     0   32G   0% /dev/shm 
  5. /dev/mapper/finance-fin 
  6.                        50G   39G  8.7G  82% /EAS70 
  7. /dev/mapper/finance-easweb 
  8.                        50G   19G   29G  40% /EASweb 

6、查看磁盤I/O性能

  1. [root@easfin logs]#iostat -x 1 1 
  2. Linux 2.6.18-194.el5 (easfin)  12/07/2011 
  3.  
  4. avg-cpu:  %user   %nice %system %iowait  %steal   %idle 
  5.            3.85    0.00    0.93    0.05    0.00   95.16 
  6.  
  7. Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util 
  8. sda               0.03    32.97  0.09  6.57     8.45   316.35    48.80     0.32   48.40   3.02   2.01 
  9. sda1              0.00    17.91  0.01  1.85     0.31   158.14    84.93     0.08   43.77   3.63   0.68 
  10. sda2              0.00     0.00  0.00  0.00     0.00     0.00    43.07     0.00   18.44  17.73   0.00 
  11. sda3              0.02    15.06  0.07  4.72     8.14   158.21    34.73     0.24   50.20   3.21   1.54 
  12. dm-0              0.00     0.00  0.10 17.06     8.13   136.48     8.43     0.07    3.85   0.84   1.44 
  13. dm-1              0.00     0.00  0.00  2.72     0.01    21.73     8.00     0.01    4.55   0.48   0.13 

如果 %util接近100%,說明產生的I/O請求太多,I/O已經滿負荷,該磁盤可能存在瓶頸。
如果%idle小於70%,I/O的壓力就比較大了,說明讀取進程有較多的wait。同時還可以結合vmstat查看b參數(等待資源的進程數)和wa參數(I/O等待所佔用的CPU時間段百分比,

高過30%時I/O的壓力就比較高了)。
svctm應小於await

7、查看某個目錄的大小
 

  1. [root@easfin logs]# du -sh /EAS70/kingdee70 
  2. 29G /EAS70/kingdee70 

8、查看系統平均負載
 

  1. [root@easfin EAS70]# uptime 
  2.  09:38:17 up 101 days, 21:05, 13 users,  load average: 10.08, 9.69, 8.94 


load average後面的值分別表示過去1分鐘、5分鐘、15分鐘內進程隊列中的平均進程數量!

  1. [root@easfin opt]# vmstat 2 5 
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ 
  3.  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 
  4.  6  0    344 219428 1031552 45554592    0    0     0     5    0    0  4  1 95  0  0 
  5. 10  0    344 220048 1031552 45554740    0    0     0  2796 4923 23824 17  9 74  0  0 
  6.  9  0    344 217632 1031552 45554692    0    0     0  2532 4787 21799 13  9 78  1  0 
  7.  7  0    344 217024 1031552 45554736    0    0     0  1916 3780 25585 17  9 74  0  0 
  8. 10  0    344 214644 1031552 45554832    0    0     0    32 3143 19736 15  9 76  0  0 


》》如果每個CPU當前活動的進程數不大於3,表示系統性能良好,大於5,表示系統性能問題嚴重。
》》如果單個CPU的r大於3,並且id經常小於50,則表示CPU的負荷很重。
》》si、so長期不等於0,表示內存不足
【CPU核心數量=物理個數×核數,我這裏是2×8=16,r不大於48,系統CPU問題都不大】

9、查看系統內核
 

  1. [root@easfin /]# uname -a 
  2. Linux easfin 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux 

10、查看系統是32位還是64位

  1. [root@easfin /]# file /sbin/init 
  2. /sbin/init: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, 
  3.  
  4. stripped 

11、查看Linux發行版相關信息

  1. [root@easfin /]# lsb_release -a 
  2. LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch 
  3. Distributor ID: RedHatEnterpriseServer 
  4. Description: Red Hat Enterprise Linux Server release 5.5 (Tikanga) 
  5. Release: 5.5 
  6. Codename: Tikanga 

 呵呵,先來11個,多了一下子記不住。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章