用 w 命令查看系统的负载,当系统的负载值偏高时,mysql
vmstat 命令,能够查看到CPU、内存、虚拟磁盘交换分区、I/O(就是你的磁盘)、系统进程等sql
[root@localhost ~]# 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 0 681860 692 164808 0 0 7 0 13 15 0 0 100 0 0 [root@localhost ~]# vmstat 1 //表示每一秒动态显示一次 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 0 681860 692 164840 0 0 7 0 13 15 0 0 100 0 0 0 0 0 681836 692 164840 0 0 0 0 19 22 0 0 100 0 0 0 0 0 681836 692 164840 0 0 0 0 16 15 0 0 100 0 0 0 0 0 681836 692 164840 0 0 0 0 14 12 0 0 100 0 0 ^C [root@localhost ~]# vmstat 1 5 //表示每一秒显示一次,只需显示五次 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 0 681836 692 164840 0 0 7 0 13 15 0 0 100 0 0 0 0 0 681812 692 164840 0 0 0 0 19 23 0 0 100 0 0 0 0 0 681812 692 164840 0 0 0 0 15 12 0 0 100 0 0 0 0 0 681812 692 164840 0 0 0 0 14 15 0 0 100 0 0 0 0 0 681812 692 164840 0 0 0 0 15 13 0 0 100 0 0 [root@localhost ~]#
这里的信息只须要关注这几列,r列,b列,swpd列,si列,so列,bi列,bo列,us列,wa列操作系统
咱们能够经过vmstat 命令,判断出系统的瓶颈在哪里,是CPU不够,仍是内存不够,仍是磁盘i/o太大,均可以断定出来。code