Oracle systemstate dump介绍
2016-03-02 23:16
489 查看
当数据库出现严重的性能问题或者hang起的时候,那么我们非常需要通过systemstatedump来知道进程在做什么,在等待什么,谁是资源的持有者,谁阻塞了别人。在出现上述问题时,及时收集systemstatedump非常有助于问题原因的分析。一般OracleSupport工程是也是需要你提供systemstatedump生成的trace文件做分析,关于systemstatedump的资料,其实没有非常详细的官方介绍资料,都是一些零零散散的介绍。
当数据库出现严重性能问题或hang起的时候,服务器端sqlplus连接数据库要么非常慢,要么根本无法连接。ORACLE10g开始,sqlplus提供了这么一个功能参数-prelim,在sqlplus无法连接的情况下,连接登录到数据库。下面关于这些知识点的一个总结
Therearetwowaystoconnecttosqlplususingapreliminaryconnection.
用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.
那么我们现在来看一个例子吧:
告警日志里面会看到类似这样的信息:
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
当数据库出现严重性能问题或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收集了进程的相关,但是如何有效的解读相关信息,并诊断问题是一个不小的难题和挑战!
参考资料:
相关文章推荐
- ORACLE 表类型变量使用总结
- 彻底弄懂oracle硬解析、软解析、软软解析
- Mybatis批量增加,删除,更新Oracle
- oracle数据库的导出exp与导入imp
- 从Oracle数据库中查询前几个月数据时需要注意的一些问题
- ORACLE SPATIAL介绍
- jdbc连接oracle的方法
- oracle trunc函数
- oracle的练习
- INS-20802 Oracle Cluster Verification 实用程序失败
- centos 5.4 上安装 Oracle11g R2 RAC (ASM)
- oracle11g 修改字符集
- Oracle 10g 11g 单机环境的安装
- RHEL 5 ORACLE Linux 5.9 配置YUM源 5配置yum
- m1上 配置OEM 怎样配置oracle oem
- 解决oracle客户端可以连接11g rac vip,但是不能连接scan ip问题
- Oracle 11g中recyclebin参数的微小变化
- Configure Oracle GoldenGate for Oracle to Oracle Database Synchronization
- RHEL 4.7下的Oracle 10g RAC到单实例的单向同步
- Oracle RAC CRS-0184 --Cannot communicate with the CRS daemon