知识大全 如何解决CPU过度消耗问题
Posted 索引
篇首语:知识就像内裤,看不见但很重要。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 如何解决CPU过度消耗问题相关的知识,希望对你有一定的参考价值。
如何解决CPU过度消耗问题 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
问题描述: 开发人员报告系统运行缓慢 影响用户访问
登陆数据库主机
使用vmstat检查 发现CPU资源已经耗尽 大量任务位于运行队列: bash $ vmstat procs memory page disk faults cpu r b w swap free re mf pi po fr de sr s s s sd in sy cs us sy id
使用Top命令
观察进程CPU耗用 发现没有明显过高CPU使用的进程$ top
last pid: ; load averages: : : processes: sleeping running zombie on cpuCPU states: % idle % user % kernel % iowait %swapMemory: M real M free M swap in use M swap free
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU MAND oracle i M M run : % oracle oracle i M M sleep : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M cpu/ : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle oracle i M M run : % oracle
检查进程数量
bash $ ps ef|grep ora|wc l bash $ ps ef|grep ora|wc l bash $ ps ef|grep ora|wc l bash $ ps ef|grep ora|wc l bash $ ps ef|grep ora|wc l bash $ ps ef|grep ora|wc l
发现系统存在大量Oracle进程 大约在 左右 而正常情况下Oracle连接数应该在 左右
检查数据库
查询v$session_wait获取各进程等待事件SQL> select sid event p p text from v$session_wait;
SID EVENT P P TEXT latch free E+ address pmon timer duration rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout
SID EVENT P P TEXT rdbms ipc message timeout buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file# buffer busy waits file#
SID EVENT P P TEXT buffer busy waits file# buffer busy waits file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file# db file sequential read file#
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file#
SID EVENT P P TEXT db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# db file scattered read file# smon timer sleep time
SID EVENT P P TEXT SQL*Net message to client driver id SQL*Net message to client driver id SQL*Net more data from client driver id SQL*Net more data from client driver id
rows selected
发现存在大量db file scattered read及db file sequential read等待
捕获相关SQL
这里用到了我的以下脚本getsqlbysid sql:
SELECT sql_text FROM v$sqltext a WHERE a hash_value = (SELECT sql_hash_value FROM v$session b WHERE b SID = &sid )ORDER BY piece ASC/ SQL> @getsqlEnter value for sid: old : where b sid= &sid new : where b sid=
SQL_TEXT select i vc title i numinfoguid from hs_info i where i intenabledflag = and i intpublishstate = and i datpublishdate <=sysdate and i numcatalogguid = order by i datpublishdate desc i numorder desc
SQL> /Enter value for sid: old : where b sid= &sid new : where b sid=
SQL_TEXT select i vc title i numinfoguid from hs_info i where i intenabledflag = and i intpublishstate = and i datpublishdate <=sysdate and i numcatalogguid = order by i datpublishdate desc i numorder desc
SQL> /Enter value for sid: old : where b sid= &sid new : where b sid=
SQL_TEXT select i vc title i numinfoguidfrom hs_info i where i intenabledflag = and i intpublishstate = and i datpublishdate <=sysdate and i numcatalogguid = order by i datpublishdate desc i numorder desc
对几个全表扫描进程跟踪以后 得到以上SQL语句 以上语句如果良好编码应该使用绑定变量 但是现在这个不是我们关心的
使用该应用用户连接 检查其执行计划:
SQL> set autotrace trace explainSQL> select i vc title i numinfoguid from hs_info i where i intenabledflag = and i intpublishstate = and i datpublishdate <=sysdate and i numcatalogguid = order by i datpublishdate desc i numorder desc ;
Execution Plan SELECT STATEMENT Optimizer=CHOOSE (Cost= Card= Bytes= ) SORT (ORDER BY) (Cost= Card= Bytes= ) TABLE ACCESS (FULL) OF HS_INFO (Cost= Card= Bytes= )
SQL> select count(*) from hs_info;
COUNT(*)
该表这里有 万记录 全表扫描已经不再适合
检查该表 存在以下索引:
SQL> select index_name index_type from user_indexes where table_name= HS_INFO ;
INDEX_NAME INDEX_TYPE HSIDX_INFO FUNCTION BASED NORMALHSIDX_INFO_SEARCHKEY DOMAINPK_HS_INFO NORMAL
检查索引键值:
SQL> select index_name column_name from user_ind_columns where table_name = HS_INFO ;
INDEX_NAME COLUMN_NAME HSIDX_INFO NUMORDERHSIDX_INFO SYS_NC $HSIDX_INFO_SEARCHKEY VC INDEXWORDSPK_HS_INFO NUMINFOGUID
SQL> desc hs_info Name Null? Type NUMINFOGUID NOT NULL NUMBER( ) NUMCATALOGGUID NOT NULL NUMBER( ) INTTEXTTYPE NOT NULL NUMBER( ) VC TITLE NOT NULL VARCHAR ( ) VC AUTHOR VARCHAR ( ) NUMPREVINFOGUID NUMBER( ) NUMNEXTINFOGUID NUMBER( ) NUMORDER NOT NULL NUMBER( ) DATPUBLISHDATE NOT NULL DATE INTPUBLISHSTATE NOT NULL NUMBER( ) VC PUBLISHERID VARCHAR ( ) VC INDEXWORDS VARCHAR ( ) VC WAPPREVPATH VARCHAR ( ) VC WEBPREVPATH VARCHAR ( ) VC WAP PREVPATH VARCHAR ( ) NUMVISITED NOT NULL NUMBER( ) INTENABLEDFLAG NOT NULL NUMBER( ) DATCREATETIME NOT NULL DATE DATMODIFYTIME NOT NULL DATE VC NOTES VARCHAR ( ) INTINFOTYPE NOT NULL NUMBER( ) VC PRIZEFLAG VARCHAR ( ) VC DESC VARCHAR ( )
决定创建新的索引以消除全表扫描SQL> create index hs_info_NUMCATALOGGUID on hs_info(NUMCATALOGGUID);
Index created
SQL> set autotrace trace explainSQL> select i vc title i numinfoguid from hs_info i where i intenabledflag = and i intpublishstate = and i datpublishdate <=sysdate and i numcatalogguid = order by i datpublishdate desc i numorder desc ;
Execution Plan SELECT STATEMENT Optimizer=CHOOSE (Cost= Card= Bytes= ) SORT (ORDER BY) (Cost= Card= Bytes= ) TABLE ACCESS (BY INDEX ROWID) OF HS_INFO (Cost= Card= Bytes= ) INDEX (RANGE SCAN)OF HS_INFO_NUMCATALOGGUID (NON UNIQUE)(Cost= Card= )
观察系统状况
原大量等待消失
SQL> select sid event p p text from v$session_wait where event not like SQL% ;
SID EVENT P P TEXT pmon timer duration rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout rdbms ipc message timeout
SID EVENT P P TEXT db file sequential read file# db file sequential read file# db file scattered read file# smon timer sleep time
rows selected
持续观察的CPU使用情况 bash $ vmstat procs memory page disk faults cpu r b w swap free re mf pi po fr de sr s s s sd in sy cs us sy id 以上为创建索引之前部分 以下为创建索引之后部分 CPU使用率恢复正常 procs memory page disk faults cpu r b w swap free re mf pi po fr de sr s s s sd in sy cs us sy id
cha138/Article/program/SQL/201311/16417相关参考
知识大全 电脑总是自动关机。刚开机五分钟CPU风扇就很热,求高手帮忙解决问题阿
电脑总是自动关机。刚开机五分钟CPU风扇就很热,求高手帮忙解决问题阿! 以下文字资料是由(历史新知网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
要找出最耗资源的sql我们可以首先使用top等工具找到最好资源的进程(记住进程号)例如操作系统进程号为然后根据这个进程号(v$processspid)在v$process中找到进程地址(v$pro
公募增发的问题及解决1、过度筹资可能会摊薄发行人股票价值由于增发新股所引起的股本扩张是瞬间完成的,而募捐集资金投人直至产生效益需要一个过程,因此,发生发行人制定的增发新股募集资金投资计划如果存在过度筹
单亲家庭的孩子都有哪些心理问题怎么解决问题会有很多,而且都不一样,个体差异和环境的不同进而导致天差地别心理问题。恋父恋母过度依赖、对父母冷淡孤立缺乏感情都可能会发生。但是万变不离其宗——缺爱,进而无安
用第一个java虚拟机启动另一个虚拟机并用第一个虚拟机的java程序去测试另一个虚拟机上java程序运行时的内存CPU资源占用情况 解决问题的限制和条件 》两个虚拟机运行在同台Windows_
过度手淫与练肌肉有关系吗?手淫会减少人的肌肉吗?(好不容易我才把肌肉练出来。)没关系。但是,过度手淫会消耗精血,使肌肉松弛(尤其是小腿),严重者会造成阳痿早泄,甚至由于过度兴奋猝死手淫过度会关节肌肉响
近年来,我国光伏产业快速发展,已形成较为完整的光伏制造产业体系,但也面临产能严重过剩、市场过度依赖外需、企业普遍经营困难
近年来,我国光伏产业快速发展,已形成较为完整的光伏制造产业体系,但也面临产能严重过剩、市场过度依赖外需、企业普遍经营困难等问题。解决这些问题,要做到统筹兼顾、综合施策,着力提升产业竞争力。为此,我国光
那里出了问题,急!线上等你检查一下CPU的针脚,看有没有问题,因为你没有说是什么牌子的CPU,所以不知道具体的情况了。AMD的CPU,就容易出现针脚断裂情况肉眼看也不明显,症状和你的情况有点相同,你可
知识大全 开机10几分钟后,cpu很热,电源外壳也很烫,但cpu风扇转速正常,cpu风扇坏了还是电源风扇坏了呢
开机10几分钟后,cpu很热,电源外壳也很烫,但cpu风扇转速正常,cpu风扇坏了还是电源风扇坏了呢电源外壳热的话,肯定是电源有问题了,焦味一般都是电源质量不好,温度过高时候电源控制芯片板子过热发出的
发动机使用一定时间后,活塞环开口间隙与边间隙超过了使用极限,引起压缩不良,起动困难,同时机油消耗量显著增加,排气冒蓝烟,因此,必须及时更换活塞环。现介绍几种不拆卸检查查法。一看 当发动机运转时,打开曲