您的位置:首页 > 数据库 > Oracle

Oracle systemstate dump介绍

2016-03-02 23:16 489 查看
当数据库出现严重的性能问题或者hang起的时候,那么我们非常需要通过systemstatedump来知道进程在做什么,在等待什么,谁是资源的持有者,谁阻塞了别人。在出现上述问题时,及时收集systemstatedump非常有助于问题原因的分析。一般OracleSupport工程是也是需要你提供systemstatedump生成的trace文件做分析,关于systemstatedump的资料,其实没有非常详细的官方介绍资料,都是一些零零散散的介绍。

当数据库出现严重性能问题或hang起的时候,服务器端sqlplus连接数据库要么非常慢,要么根本无法连接。ORACLE10g开始,sqlplus提供了这么一个功能参数-prelim,在sqlplus无法连接的情况下,连接登录到数据库。下面关于这些知识点的一个总结

Therearetwowaystoconnecttosqlplususingapreliminaryconnection.

sqlplus-prelim/assysdba
sqlplus/nolog
set_prelimon
connect/assysdba

用sysdba登录到数据库上:
$sqlplus/assysdba
或者
$sqlplus-prelim/assysdba<==当数据库已经很慢或者hang到无法连接
下面是在metalink上的介绍如何在单机或RAC环境下做Systemstate或Hanganalyze(详细信息,请见下面参考资料)
CollectioncommandsforHanganalyzeandSystemstate:Non-RAC:
Sometimes,databasemayactuallyjustbeveryslowandnotactuallyhanging.Itisthereforerecommended,wherepossibletoget2hanganalyzeand2systemstatedumpsinordertodeterminewhetherprocessesaremovingatallorwhethertheyare"frozen".

Hanganalyze
sqlplus'/assysdba'
oradebugsetmypid
oradebugunlimit
oradebughanganalyze3
--Waitoneminutebeforegettingthesecondhanganalyze
oradebughanganalyze3
oradebugtracefile_name
exit

Systemstate
sqlplus'/assysdba'
oradebugsetmypid
oradebugunlimit
oradebugdumpsystemstate266
oradebugdumpsystemstate266
oradebugtracefile_name
exit

CollectioncommandsforHanganalyzeandSystemstate:RAC
Thereare2bugsaffectingRACthatwithouttherelevantpatchesbeingappliedonyoursystem,makeusinglevel266or267verycostly.Thereforewithoutthesefixesinplaceithighlyunadvisabletousetheselevel

Forinformationonthesepatchessee:
Document11800959.8Bug11800959-ASYSTEMSTATEdumpwithlevel>=10inRACdumpshugeBUSYGLOBALCACHEELEMENTS-canhang/crashinstances
Document11827088.8Bug11827088-Latch'gcelement'contention,LMHBterminatestheinstance

Note:bothbugsarefixedin11.2.0.3.

CollectioncommandsforHanganalyzeandSystemstate:RACwithfixesforbug11800959andbug11827088
For11g:
sqlplus'/assysdba'
oradebugsetorapnamereco
oradebugunlimit
oradebug-gallhanganalyze3
oradebug-gallhanganalyze3
oradebug-galldumpsystemstate266
oradebug-galldumpsystemstate266
exit
CollectioncommandsforHanganalyzeandSystemstate:RACwithoutfixesforBug11800959andBug11827088
sqlplus'/assysdba'
oradebugsetorapnamereco
oradebugunlimit
oradebug-gallhanganalyze3
oradebug-gallhanganalyze3
oradebug-galldumpsystemstate258
oradebug-galldumpsystemstate258
exit
For10g,runoradebugsetmypidinsteadoforadebugsetorapnamereco:
sqlplus'/assysdba'
oradebugsetmypid
oradebugunlimit
oradebug-gallhanganalyze3
oradebug-gallhanganalyze3
oradebug-galldumpsystemstate258
oradebug-galldumpsystemstate258
exit
InRACenvironment,adumpwillbecreatedforallRACinstancesintheDIAGtracefileforeachinstance.

那么我们现在来看一个例子吧:

[oracle@DB-Server~]$sqlplus-prelim/assysdba
SQL*Plus:Release10.2.0.5.0-ProductiononWedMar216:31:032016
Copyright(c)1982,2010,Oracle.AllRightsReserved.
SQL>oradebugsetmypid
Statementprocessed.
SQL>oradebugunlimit
Statementprocessed.
SQL>oradebugdumpsystemstate266
Statementprocessed.
SQL>oradebugdumpsystemstate266
Statementprocessed.
SQL>oradebugtracefile_name
/u01/app/oracle/admin/SCM2/udump/scm2_ora_13598.trc
SQL>exit
DisconnectedfromORACLE




告警日志里面会看到类似这样的信息:
WedMar0216:32:08CST2016
SystemStatedumpedtotracefile
WedMar0216:32:48CST2016
SystemStatedumpedtotracefile/u01/app/oracle/admin/xxx/udump/scm2_ora_13598.trc
$ORACLE_BASE/admin/ORACLE_SID/udump/下找到对应的trc文件,如下所示,你会看到大量系统中所有进程的进程状态等信息。每个进程对应跟踪文件中的一段内容,反映该进程的状态信息,包括进程信息,会话信息,enqueues信息(主要是lock的信息)等等。



systemstatedump有多个级别:


2:dump(不包括lockelement)
10:dump
11:dump+globalcacheofRAC
256:shortstack(函数堆栈)
258:256+2-->shortstack+dump(不包括lockelement)
266:256+10-->shortstack+dump
267:256+11-->shortstack+dump+globalcacheofRAC


level11和267会dumpglobalcache,会生成较大的trace文件,一般情况下不推荐。一般情况下,如果进程不是太多,推荐用266,因为这样可以dump出来进程的函数堆栈,可以用来分析进程在执行什么操作。但是生成shortstack比较耗时,如果进程非常多,比如2000个进程,那么可能耗时30分钟以上。这种情况下,可以生成level10或者level258,level258比level10会多收集shortshortstack,但比level10少收集一些lockelementdata.
使用systemstatedump生成的trace文件可能会非常大,一般都会几百兆甚至更大,虽然通过systemstatedump收集了进程的相关,但是如何有效的解读相关信息,并诊断问题是一个不小的难题和挑战!
参考资料:
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=352993211736965&parent=DOCUMENT&sourceId=68738.1&id=452358.1&_afrWindowMode=0&_adf.ctrl-state=z7hwh19s9_319
https://blogs.oracle.com/Database4CN/entry/systemstate_dump_%E4%BB%8B%E7%BB%8D
http://tech.e2sn.com/oracle/troubleshooting/hang/how-to-log-on-even-when-sysdba-can-t-do-so
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
章节导航