zoukankan      html  css  js  c++  java
  • vmstat

    命令简介

    vmstat是Virtual Memory Statistics,是对系统整体情况进行统计,不足之处无法对某个进程进行深入分析

    命令格式

    vmstat delay count

    vmstat 2 5:每隔2秒执行一次vmstat共执行5次

    命令输出字段意义:

    [root@xen-test-1d32 ~]# vmstat 2 5
    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
    r b swpd free buff cache si so bi bo in cs us sy id wa st
    0 0 67404 86908 134196 683876 0 0 0 2 2 1 0 0 99 0 0
    0 0 67404 86908 134196 683876 0 0 0 18 92 139 0 1 98 2 0
    0 0 67404 86908 134196 683876 0 0 0 0 57 110 0 0 99 0 0
    0 0 67404 86908 134196 683876 0 0 0 0 59 113 0 0 100 0 0
    0 0 67404 86908 134196 683876 0 0 0 18 81 134 0 0 99 1 0

    The first report produced gives averages since the last reboot

    第一行给出的是自系统上次重启后到现在的平均值

    procs:

    r:The number of processes waiting for run time.

    等待运行的进程数。如果等待运行的进程数越多,意味着CPU非常繁忙,若改参数长期大于或等于逻辑cpu个数,则CPU资源可能存在较大的瓶颈

    b:The number of processes in uninterruptible sleep.

    处于不可中断睡眠状态的进程数,意味着进程被阻塞。主要是指被资源阻塞的进程队列数(I/O资源,页面调度),这个值较大时,需要根据应用程序来分析,比如数据库产品,中间件应用等

    memory:

    swpd:the amount of virtual memory used.

    已使用的虚拟内存大小。若虚拟内存使用的较多,可能系统的物理内存比较吃紧,需要采取合适的方式来减少物理内存的使用。swapd不为0,并不意味这物理内存吃紧,若swapd没变化,si和so长期为0也是没有问题的

    free: the amount of idle memory.

    空闲的物理内存大小
    buff: the amount of memory used as buffers.

    用来作为buffer(缓存,主要用于块设备的缓存)内存数,单位:KB

    cache: the amount of memory used as cache.

    用来做cache(缓存,主要用于缓存文件)的内存数,单位:KB
    inact: the amount of inactive memory. (-a option)

    非活动内存的总量
    active: the amount of active memory. (-a option)

    活动内存的总量

    Swap
    si: Amount of memory swapped in from disk (/s).

    从磁盘交换到内存的交换页数量,单位KB/s
    so: Amount of memory swapped to disk (/s).

    从内存交换到磁盘的交换页数量,单位KB/s

      内存够用的时候,这两个值都为0,如果这2个值长期大于0,系统性能会收到影响,磁盘IO和CPU资源都会被消耗

      当空闲内存(free)很少或接近0是,就认为内存不够用了,这是不正确的,不能观看这一点还要结合si和so

      若free很少,但si和so也很少,不用担心,系统性能这时不受影响

      当内存的需求大于RAM的数量,服务器启动了虚拟内存机制,通过虚拟内存,可以将RAM段移到SWAP DISK的特殊磁盘段上

      这样会出现虚拟内存的页导入和导出现象,页面导出不能说明RAM瓶颈,虚拟内存系统经常会对内存段进行页面导出

      当页面导入导入操作表明服务器需要更多的内存了,页导入需要从SWAP DISK商江内存段副指挥RAM,导致服务器速度变慢

     

    IO
    bi: Blocks received from a block device (blocks/s).

    每秒从块设备接收到的块数,单位:块/秒,也就是读块设备

    bo: Blocks sent to a block device (blocks/s).

    每秒向块设备发送的块数,单位:块 /秒,也就是写块设备

    System
    in: The number of interrupts per second, including the clock.

    每秒发生的中断数,包括时钟中断
    cs: The number of context switches per second.

    每秒的环境(上下文)切换次数。调用系统函数,就要进行上下文切换,过多的上下文切换会浪费较多的CPU资源,这个数值越小越好

    CPU
    These are percentages of total CPU time.
    us: Time spent running non-kernel code. (user time, including nice time)

    用户CPU时间(非内核进程占用时间)(单位为百分比),us的值越高,说明用户进程消耗的CPU时间越多
    sy: Time spent running kernel code. (system time)

    系统CPU时间(单位为百分比),sy越高,说明系统内核消耗的CPU资源多,这不是良性表现,我们应该检查原因
    id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.

    空闲CPU的时间(百分比)
    wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.

    等待IO的CPU时间,这个指标意味着CPU在等待硬盘读写操作的时间,用百分比表示,wait越大机器io系ing能越差,说明IO等待比较严重,可能由于磁盘大量做随机访问造成,也有可能磁盘出项瓶颈
    st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

     

    参考文献:

    该文章参考:http://www.cnblogs.com/kerrycode/p/6208257.html

    物理CPU、核数、逻辑CPU的关系参考

    http://www.cnblogs.com/emanlee/p/3587571.html

  • 相关阅读:
    MySQL的存储引擎
    MySQL的索引及执行计划
    MySQL的SQL基础应用
    MySQL基础入门
    代码质量检测SonarQube
    Jenkins持续集成
    Git版本控制及gitlab私有仓库
    jumpserver跳板机
    Keepalived高可用服务
    well-known file is not secure
  • 原文地址:https://www.cnblogs.com/yangyangchunchun/p/7691560.html
Copyright © 2011-2022 走看看