当前位置:网站首页>【StoneDB故障诊断】系统资源瓶颈诊断
【StoneDB故障诊断】系统资源瓶颈诊断
2022-07-27 19:19:00 【51CTO】
当操作系统的资源出现瓶颈时,不仅操作系统上的应用服务受到影响,而且在操作系统执行简单的命令可能都无法返回结果。在操作系统尚未完全夯死前,可以使用相关命令对CPU、内存、IO和网络资源的使用情况进行信息的收集,然后分析确认这些资源是否被合理利用,是否存在瓶颈。
CPUtop、vmstat都可以检查CPU的使用情况,但top的结果显示的更全面。top返回的结果有两层,上层是系统性能的统计信息,下层是进程的统计信息,默认按照CPU的使用率排序。 top返回结果示例如下:
第一行
10:12:21:当前系统时间 up 5 days:自上一次系统启动后到现在的运行天数 4 user:登录到系统的用户数 load average:过去1分钟、5分钟、15分钟,系统负载的平均值
第二行
total:系统进程总数 running:处于运行状态的进程数 sleeping:处于休眠状态的进程数 stopped:处于被停止状态的进程数 zombie:处于僵尸状态进程数
第三行
us:用户进程占用CPU的百分比 sy:系统进程占用CPU的百分比 ni:优先级被改变过的进程占用CPU的百分比 id:空闲CPU占用的百分比 wa:IO等待占用CPU的百分比 hi:硬件中断占用CPU的百分比 si:软件中断占用CPU的百分比 st:虚拟化环境占用CPU的百分比 需要重点关注CPU的使用率,当us值较高时,说明用户进程消耗CPU时间较多,如果长时间超过50%时,应尽快优化应用服务。当sy值较高时,说明系统进程消耗CPU时间较多,比如可能是操作系统配置不合理或者出现操作系统的Bug。当wa值较高时,说明系统IO等待比较严重,比如可能是发生了大量的随机IO访问,IO带宽出现瓶颈。
第四行
total:物理内存总大小,单位为M free:空闲的内存大小 used:已使用的内存大小 buff/cache:已缓存的内存大小
第五行
total:Swap大小 free:空闲的Swap大小 used:已使用的Swap大小 avail Mem:已缓存的Swap大小
进程列表
PID:进程的id USER:进程的拥有者 PR:进程的优先级,值越小越优先执行 NI:进程nice值,正值表示降低进程优先级,负值表示提高进程优先级,nice取值范围为(-20,19),默认情况下,进程的nice值为0 VIRT:进程占用的虚拟内存大小 RES:进程占用的物理内存大小 SHR:进程占用的共享内存大小 S:进程状态,其中S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值为负数 %CPU:进程CPU使用率 %MEM:进程内存使用率 TIME+:进程启动后占用CPU的总时间,即占用CPU使用时间的累加值 COMMAND:进程启动命令名称 出现CPU使用率高诊断方法: 1)找出调用的函数
注:xxx为top -H返回最消耗CPU的进程。 2)找出消耗CPU的SQL
注:xxx为pidstat返回最消耗CPU的线程。
内存top、vmstat、free都可以检查内存的使用情况。 free返回结果示例如下:
total:物理内存总大小,total = used + free + buff/cache used:已使用的内存大小 free:空闲的内存大小 shared:共享内存大小 buff/cache:缓存内存大小 available:可用物理内存大小,available = free + buff/cache 出现内存使用率高诊断方法: 1)检查配置是否合理,例如:操作系统物理内存128G,而分配给数据库实例110G,由于操作系统进程和其它应用程序也需要内存,很容易导致内存被消耗光; 2)检查并发连接数是否过高,read_buffer_size、read_rnd_buffer_size、sort_buffer_size、thread_stack、join_buffer_size、binlog_cache_size都是session级别的,连接数越多,需要的内存就越多,因此这些参数也不能设置太大; 3)检查是否有不合理的join,例如:多表关联时,执行计划中驱动表的结果集比较大,需要循环多次执行,容易导致内存泄漏; 4)检查打开文件数是否过多和table_open_cache是否设置合理,访问一个表时,会将该表放入缓存区table_open_cache,目的是下次可以更快的访问,但如果table_open_cache设置太大,且打开的表又多的情况下,是很消耗内存的。
IOiostat、dstat、pidstat都可以检查IO的使用情况。 iostat返回结果示例如下:
rrqm/s: 每秒进行merge的读操作数 wrqm/s: 每秒进行merge的写操作数 r/s:每秒读IO次数 w/s:每秒写IO次数 rkB/s:每秒读IO大小,单位为KB wkB/s:每秒写IO大小,单位为KB avgrq-sz:平均请求大小,单位为扇区(512B) avgqu-sz:在驱动请求队列和在设备中活跃的平均请求数 await:平均IO响应时间,包括在驱动请求队列里的等待和设备的IO响应时间 r_await:每次读操作IO响应时间 w_await:每次写操作IO响应时间 svctm:磁盘设备的IO平均响应时间 %util:设备忙处理IO请求的百分比(使用率),磁盘的繁忙程度 r/s + w/s:IOPS 出现IO使用率高诊断方法: 1)找出使用率最高的磁盘设备
2)找出占用IO高的应用程序
3)找出占用IO高的线程
4)找出占用IO高的SQL
注:xxx为pidstat返回最消耗IO的线程。
本文由博客一文多发平台 OpenWrite 发布!
边栏推荐
- 一口气学完 Redis 集群方案
- UNITY--读取Excel
- The design idea of relational database is obvious to you in 20 pictures
- 对象在内存中存在形式&内存分配机制
- It seems to be a bug of thread pool, but I think the source code design is unreasonable.
- 内部类(四种内部类详解)
- Why do server programs need to listen first
- 2021-11-05 understand main method syntax, code block and final keyword
- 2019q4 memory manufacturers' revenue ranking: Samsung fell 5%, only SK Hynix and micron maintained growth
- Technology Management - we must focus on the big and let go of the small
猜你喜欢

项目分析(哪些是it培训给不了)

What is eplato cast by Plato farm on elephant swap? Why is there a high premium?

Implementation of arbitrary code execution based on.Net dynamic compilation technology

Exception -exception
![[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)](/img/c4/71a9933a3a1fdd14f84a41b640f5b5.jpg)
[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)

LVS+Keepalived高可用群集

Lvs+kept highly available cluster

对象在内存中存在形式&内存分配机制

关系型数据库的设计思想,20张图给你看的明明白白

深入理解递归的方法调用(含实例迷宫问题、汉诺塔、猴子吃桃、斐波拉契、阶乘))
随机推荐
@RequestParam注解的详细介绍
Pytoch distributed training
2021-11-05 understand main method syntax, code block and final keyword
Common shortcut keys and setting methods of idea
What is eplato cast by Plato farm on elephant swap? Why is there a high premium?
Why do server programs need to listen first
腾讯云[HiFlow】| 自动化 -------HiFlow:还在复制粘贴?
Import word document pictures blocking and non blocking IO operations
How to realize a good knowledge management system?
Will the United States prohibit all Chinese enterprises from purchasing American chips? Trump responded like this
[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
@Autowired注解与@Resource注解的区别
The design idea of relational database is obvious to you in 20 pictures
Read Plato farm's eplato and the reason for its high premium
单核CPU, 1G内存,也能做JVM调优吗?
Samsung's most advanced EUV production line has been put into operation: the 7Nm capacity this year will be three times that of last year
In depth understanding of recursive method calls (including instance maze problem, tower of Hanoi, monkey eating peach, fiboracci, factorial))
Exception -exception
First zhanrui 5g chip! Exposure of Hisense F50, a pure domestic 5g mobile phone: equipped with Huben T710 + chunteng 510
8000字讲透OBSA原理与应用实践