linux 服务器 基本系统性能分析 整理

Linux服务器基本信息通常包括如下几方面:

1CPU信息
2内存使用信息
3硬盘使用情况
4服务器负载状况
5.查看系统信息
6.查看系统已经载入的相关模块
7.查看PCI设备信息

1.获取CPU的详细情况

 [root@ck /]# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
stepping	: 10
microcode	: 0x84
cpu MHz		: 1800.000
cache size	: 6144 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp arch_capabilities
bogomips	: 3600.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management:

判断依据:

具有相同core id的CPU是同一个core的超线程
具有相同"physical id"的CPU是同一个CPU封装的线程或核心

   a. 显示物理CPU个数
    cat /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l

  b.   显示每个物理CPU的个数(核数)

     cat /proc/cpuinfo |grep "cpu cores"|uniq

  c.    显示逻辑CPU个数

    cat /proc/cpuinfo|grep "processor"|wc -l
    

理论上不使用超线程技术的前提下有如下结论:

物理CPU个数*核数=逻辑CPU个数

配置服务器的应用时,以逻辑CPU个数为准

监控CPU使用情况----uptime命令

[root@ck /]# uptime
 13:52:41 up  3:35,  1 user,  load average: 0.00, 0.01, 0.05
当前系统时间  系统已经运行了多久  当前一个用户在登陆
CPU负载分别显示的是最近一分钟 五分钟 十五分钟的负载情况 需要说明的是 这里显示的是单位时间段内CPU等待队列中平均有多少进程在等待 等待的进程个数越多 说明cpu越忙 

2.获得服务器内存使用情况

[root@ck /]# free -h
              total        used        free      shared  buff/cache   available
Mem:           972M        547M         99M        5.1M        326M        219M
Swap:          2.0G         63M        1.9G

mem一行的total代表内存   第二行是交换分区的使用情况

total: 内存总量
used: 已使用
free: 未使用
shared: 多进程共享的内存总量
-buffers/cache: 已使用内存
+buffers/cache: 可用内存
  可用内存=free+buffers+cached

3.查看服务器硬盘使用情况

查看硬盘以及分区信息: fdisk -l
查看文件系统的磁盘空间占用情况: df -h

[root@ck /]# df -hT
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        17G  7.8G  9.3G   46% /
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.4M  478M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/sr0                iso9660   4.3G  4.3G     0  100% /media
/dev/sda1               xfs      1014M  166M  849M   17% /boot
tmpfs                   tmpfs      98M   12K   98M    1% /run/user/42
tmpfs                   tmpfs      98M  4.0K   98M    1% /run/user/0
/dev/loop0              iso9660    11G   11G     0  100% /var/www/html/rhel7dvd
-h人性化显示容量信息
-i 显示磁盘inode使用量信息
-T 显示文件系统类型

[root@ck /]# df -i
文件系统                  Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/mapper/centos-root 8910848  152117 8758731       2% /
devtmpfs                 120209     408  119801       1% /dev
tmpfs                    124487       1  124486       1% /dev/shm
tmpfs                    124487     935  123552       1% /run
tmpfs                    124487      16  124471       1% /sys/fs/cgroup
/dev/sr0                      0       0       0        - /media
/dev/sda1                524288     340  523948       1% /boot
tmpfs                    124487       9  124478       1% /run/user/42
tmpfs                    124487       5  124482       1% /run/user/0
/dev/loop0                    0       0       0        - /var/www/html/rhel7dvd
根分区总innode个数为8910848个 这决定了该分区你能创建文件的个数 有多少个inode节点 就可以在该分区创建多少个文件  如果inode节点耗尽 就算磁盘空间还有好多GB 也无法再创建文件 

查看硬盘的I/O性能:

 iostat -d -x -k 10 2
(-d显示磁盘状态,-x显示跟io相关的扩张数据,-k以KB为单位,10表示每隔10秒刷新一次,2表示刷新2次,默认一直刷新)

  [root@ck /]# iostat -d -x -k 10 2
Linux 3.10.0-957.el7.x86_64 (ck) 	2019年07月29日 	_x86_64_	(1 CPU)

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
scd0              0.00     0.00    0.07    0.00     1.69     0.00    45.99     0.00    2.43    2.43    0.00   2.31   0.02
scd1              0.00     0.00    0.02    0.00     0.44     0.00    52.66     0.00    3.25    3.25    0.00   2.89   0.00
sda               0.21     1.36    3.21    0.98   170.14    20.93    91.28     0.01    2.20    2.70    0.60   0.85   0.36
dm-0              0.00     0.00    3.03    1.12   168.28    15.88    88.89     0.01    2.24    2.84    0.63   0.84   0.35
dm-1              0.00     0.00    0.25    1.22     1.14     4.90     8.21     0.00    1.55    0.25    1.81   0.03   0.00

参数说明:

rrqm/s: 每秒这个设备相关的读取请求有多少被Merge了(当系统调用需要读取数据的时候,VFS将请求发到各个FS,如果FS发现不同的读取请求读取的是相同Block的数据,FS会将这个请求合并Merge)
wrqm/s: 每秒进行merge的写操作数
r/s: 每秒完成的读I/O设备的次数
w/s: 每秒完成的写I/O设备的次数
rkB/s: 每秒读取多少KB
wkB/s: 每秒写多上KB
avgrq-sz: 平均每次设备I/O操作的数据大小(扇区)
avgqu-sz: 平均I/O队列长度
await: 平均每次设备I/O操作的等待时间ms
svctm: 平均每次设备I/O操作时间ms
%util: 一秒钟有百分之多上时间用于I/O操作
平时只要关注%util,await两个参数即可
%util越接近100%,说明产生的I/O请求越多,越容易满负荷
await 取决于svctm,最好低于5ms,如果大于5ms说明I/O压力大,可以考虑更换响应速度更快的硬盘.

4.查看服务器平均负载

概念: 特定时间间隔内运行队列中的平均进程数可以反映系统繁忙程度

[root@ck /]# uptime
 14:08:20 up  3:51,  1 user,  load average: 0.00, 0.01, 0.05
[root@ck /]# w
 14:09:14 up  3:52,  1 user,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.112.1    10:36    2.00s  0.20s  0.03s w

load average: 0.01, 0.03, 0.02表示过去1分钟,5分钟,15分钟进程队列中的平均进程数量
当这三个数长期大于逻辑CPU个数时说明负载过大

   top - 14:10:43 up  3:53,  1 user,  load average: 0.00, 0.01, 0.05
Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   995896 total,   100284 free,   561284 used,   334328 buff/cache
KiB Swap:  2097148 total,  2031868 free,    65280 used.   224276 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                         
  8905 root      20   0  160848   5612   4252 S  0.3  0.6   0:00.78 sshd                                                            
     1 root      20   0  194076   5628   3072 S  0.0  0.6   0:03.87 systemd                                                         
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd                                                        
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.28 ksoftirqd/0                                                     
     5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H                                                    
     7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0  

vmstat监控Linux系统的整体性能

[root@ck /]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0  65280 100928   4688 329616    1    5   169    20   46  105  0  0 99  0  0
 看一个线上的,cpu部分已经处于饱和状态了。

[root@ck /]# vmstat 1 8
持续输出8秒

参数介绍:

procs:

r: 等待运行的进程数
b: 处于非中断睡眠状态的进程数    
 memory:

swpd: 虚拟内存使用情况(KB)
free: 空闲内存(KB)
 swap:

si: 从磁盘交换到内存的交换页数量
so: 从内存交换到磁盘的交换页数量
io:

bi: 发送到设备的块数(块/s)
bo: 从块设备接收到的块数(块/s)
 system:

in: 每秒中断数
cs: 每秒的环境上下文切换数
cpu:(cpu总使用的百分比)

us: cpu使用时间
sy: cpu系统使用时间
id: 闲置时间

标准情况下r和b的值应为:r<5,b约为0.

如果us+sy<70%,系统性能较好

如果us+sy>85,系统性能糟糕.

5.查看系统信息

查看系统32、64位

[root@ck /]# getconf LONG_BIT
64

查看服务器发行版相关信息

[root@ck /]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core)

查看主机名

[root@ck /]# hostname
ck

6.查看系统已经载入的相关模块

[root@ck /]# lsmod
Module                  Size  Used by
loop                   28072  2 
tcp_diag               12591  0 
udp_diag               12801  0 
inet_diag              18949  2 tcp_diag,udp_diag
tcp_lp                 12663  0 
fuse                   91880  1 
xt_CHECKSUM            12549  1 
ipt_MASQUERADE         12678  3 
nf_nat_masquerade_ipv4    13412  1 ipt_MASQUERADE



modprobe ip_vs #动态加载ip_vs模块

lsmod | grep ip_vs #查看模块是否加载成功

modprobe -r ip_vs #动态卸载ip_vs模块

modinfo ip_vs #命令可以查看内核模块信息

上述modprobe方式加载的内核模块仅在当前有效,计算机重启后并不会再次加载该模块,如果希望系统开机自动挂载内核模块,则需要将modprobe命令写入/etc/rc.d/rc.local文件中,或者通过修改/etc/modprobe.d/目录下相关配置文件实现:
echo "modeprobe ip_vs" >> /etc/rc.d/rc.local
当内核模块不再需要时,可以通过将/etc/rc.d/rc.local文件中对应的modprobe命令删除,但需要重启计算机才生效,此时。可以通过modprobe-r命令来立刻删除内核模块:
modprobe -r ip_vs

7.查看PCI设备信息

[root@ck /]# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值