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

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

There are two ways to connect to sqlplus using a preliminary connection.

sqlplus -prelim / as sysdba
 
sqlplus /nolog
set _prelim on
connect / as sysdba

用sysdba登录到数据库上:

$sqlplus / as sysdba

或者

$sqlplus -prelim / as sysdba <==当数据库已经很慢或者hang到无法连接

下面是在metalink上的介绍如何在单机或RAC环境下做Systemstate或Hanganalyze(详细信息,请见下面参考资料)

Collection commands for Hanganalyze and Systemstate: Non-RAC:
Sometimes, database may actually just be very slow and not actually hanging. It is therefore recommended,  where possible to get 2 hanganalyze and 2 systemstate dumps in order to determine whether processes are moving at all or whether they are "frozen".

Hanganalyze
sqlplus '/ as sysdba'
oradebug setmypid
oradebug unlimit
oradebug hanganalyze 3
-- Wait one minute before getting the second hanganalyze
oradebug hanganalyze 3
oradebug tracefile_name
exit

Systemstate
sqlplus '/ as sysdba'
oradebug setmypid
oradebug unlimit
oradebug dump systemstate 266
oradebug dump systemstate 266
oradebug tracefile_name
exit

Collection commands for Hanganalyze and Systemstate: RAC
There are 2 bugs affecting RAC that without the relevant patches being applied on your system, make using level 266 or 267 very costly. Therefore without these fixes in place it highly unadvisable to use these level

For information on these patches see:
Document 11800959.8 Bug 11800959 - A SYSTEMSTATE dump with level >= 10 in RAC dumps huge BUSY GLOBAL CACHE ELEMENTS - can hang/crash instances
Document 11827088.8 Bug 11827088 - Latch 'gc element' contention, LMHB terminates the instance
 
Note:  both bugs are fixed in 11.2.0.3.
 
Collection commands for Hanganalyze and Systemstate: RAC with fixes for bug 11800959 and bug 11827088
For 11g:
sqlplus '/ as sysdba'
oradebug setorapname reco
oradebug  unlimit
oradebug -g all hanganalyze 3
oradebug -g all hanganalyze 3
oradebug -g all dump systemstate 266
oradebug -g all dump systemstate 266
exit
Collection commands for Hanganalyze and Systemstate: RAC without fixes for Bug 11800959 and Bug 11827088
sqlplus '/ as sysdba'
oradebug setorapname reco
oradebug unlimit
oradebug -g all hanganalyze 3
oradebug -g all hanganalyze 3
oradebug -g all dump systemstate 258
oradebug -g all dump systemstate 258
exit
For 10g, run oradebug setmypid instead of oradebug setorapname reco:
sqlplus '/ as sysdba'
oradebug setmypid
oradebug unlimit
oradebug -g all hanganalyze 3
oradebug -g all hanganalyze 3
oradebug -g all dump systemstate 258
oradebug -g all dump systemstate 258
exit
In RAC environment, a dump will be created for all RAC instances in the DIAG trace file for each instance.

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

[oracle@DB-Server ~]$ sqlplus -prelim / as sysdba
 
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Mar 2 16:31:03 2016
 
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
 
SQL> oradebug setmypid
Statement processed.
SQL> oradebug unlimit
Statement processed.
SQL> oradebug dump systemstate 266
Statement processed.
SQL> oradebug dump systemstate 266
Statement processed.
SQL> oradebug tracefile_name
/u01/app/oracle/admin/SCM2/udump/scm2_ora_13598.trc
SQL> exit
Disconnected from ORACLE

告警日志里面会看到类似这样的信息:

Wed Mar 02 16:32:08 CST 2016

System State dumped to trace file

Wed Mar 02 16:32:48 CST 2016

System State dumped to trace file /u01/app/oracle/admin/xxx/udump/scm2_ora_13598.trc

$ORACLE_BASE/admin/ORACLE_SID/udump/ 下找到对应的trc文件,如下所示,你会看到大量系统中所有进程的进程状态等信息。每个进程对应跟踪文件中的一段内容,反映该进程的状态信息,包括进程信 息,会话信息,enqueues信息(主要是lock的信息)等等。

systemstate dump有多个级别:

2: dump (不包括lock element)

10: dump

11: dump + global cache of RAC

256: short stack (函数堆栈)

258: 256+2 -->short stack +dump(不包括lock element)

266: 256+10 -->short stack+ dump

267: 256+11 -->short stack+ dump + global cache of RAC

level 11和 267会 dump global cache, 会生成较大的trace 文件,一般情况下不推荐。一般情况下,如果进程不是太多,推荐用266,因为这样可以dump出来进程的函数堆栈,可以用来分析进程在执行什么操作。但 是生成short stack比较耗时,如果进程非常多,比如2000个进程,那么可能耗时30分钟以上。这种情况下,可以生成level 10 或者 level 258, level 258 比 level 10会多收集short short stack, 但比level 10少收集一些lock element data.

使用systemstate dump生成的trace文件可能会非常大,一般都会几百兆甚至更大,虽然通过system state dump收集了进程的相关,但是如何有效的解读相关信息,并诊断问题是一个不小的难题和挑战!

Oracle systemstate dump介绍相关推荐

  1. systemstate dump 介绍

    当数据库出现严重的性能问题或者hang了的时候,我们非常需要通过systemstate dump来知道进程在做什么,在等待什么,谁是资源的持有者,谁阻塞了别人.在出现上述问题时,及时收集systems ...

  2. 中亦安图oracle培训,【中亦安图】Systemstate Dump分析经典案例(8)

    第一章技术人生系列·我和数据中心的故事(第八期)Systemstate Dump分析经典案例(下) 中亦安图 | 2016-03-08 21:45 前言 接上一期:(上一期的阅读方法:关注" ...

  3. 【中亦安图】Systemstate Dump分析经典案例(7)

    第一章 技术人生系列 · 我和数据中心的故事(第七期)Systemstate Dump分析经典案例(上) 中亦安图 | 2016-03-03 21:42 前言 本期我们邀请中亦科技的另外一位Oracl ...

  4. 1.oracle的dump理解一 BH buffer header

    1.oracle的dump理解一 BH buffer header 欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/5122844 ...

  5. Oracle常用dump命令

    导读: Oracle常用dump命令,记录一下备查 一.Memory Dumps 1).Global Area ALTER SESSION SET EVENTS 'immediate trace na ...

  6. oracle 查看数据泵,1.Oracle数据泵介绍

    1. Oracle 数据泵介绍 Oracle数据泵是用来替换原始的export和import工具(exp,imp) 它从Oracle 10g开始提供 它可以快速和高效的将数据从一个数据库移动到另一个数 ...

  7. Systemstate Dump分析经典案例

    Systemstate Dump分析经典案例 第一章 技术人生系列 · 我和数据中心的故事(第八期)Systemstate Dump分析经典案例(下) 中亦安图 | 2016-03-08 21:45 ...

  8. 【中亦安图】Systemstate Dump分析经典案例(8)

    第一章 技术人生系列 · 我和数据中心的故事(第八期)Systemstate Dump分析经典案例(下) 中亦安图 | 2016-03-08 21:45 前言 接上一期:(上一期的阅读方法:关注&qu ...

  9. Java命令学习系列(零)——常见命令及Java Dump介绍

    Java命令学习系列(零)--常见命令及Java Dump介绍 一.常用命令: 在JDK的bin目彔下,包含了java命令及其他实用工具.  jps:查看本机的Java中进程信息.  jstack ...

最新文章

  1. python生成器和装饰器_python三大法器:生成器、装饰器、迭代器
  2. matplotlib错误:from matplotlib import afm, cbook, ft2font, rcParams, get_cachedirImportError: DLL load
  3. 【Linux】服务器常用命令
  4. 将某内存单元数据做乘法 + 内存间数据的复制
  5. 六月计划#2B(6.10-6.16)
  6. linux reboot命 过程,IDRAC安装dell服务器操作系统(linux or windows),用到生命周期管理器...
  7. 处理字符集中的算式问题
  8. VGG19续读【精细】,为什么叫做VGG19?==>【每一层可以看做是很多个局部特征的提取器,可以用作局部特征提取】
  9. 向服务器上传文件的命令,上传文件到远程服务器的命令
  10. js学习总结----深入扩展-js同步与异步编程
  11. vue3.0新特性及用法
  12. java 数组转化为arraylist_在Java中怎样把数组转换为ArrayList?
  13. Spring Security OAuth2实现单点登录
  14. CS231N课程笔记学习一——图像分类
  15. mysql decimal 18 2_sql语句 decimal(18,0)什么意思
  16. 用LNMP+wordpress搭了一个网站
  17. 1.firefox缺少flash插件
  18. JDK8之ConcurrentHashMap源码解读
  19. 一叶知秋,很多IT“专家”其实都只是“砖家”
  20. 数据格式:大端模式(Big-endian)和小端模式(Little-endian)

热门文章

  1. php包括web前端,web前端包括什么技术?
  2. java自定义findbugs规则_静态代码扫描 (三)——FindBugs 自定义规则入门
  3. ajax局部刷新_web前端入门到实战:实现html页面自动刷新
  4. html使div内部元素水平排列_元素周期表探讨
  5. pb公共变量怎么找_阿迪达斯的4D怎么就火不起来呢?
  6. ajax中提交属性table,wicket 6.0.0-beta2在使用AjaxButton提交表单时更新DataTable的内容...
  7. python seek tell_PYTHON学习14.09:Python seek()和tell()函数详解
  8. 零基础学HTML5和CSS3前端开发第一课
  9. python新手如何度过小白期,不再当菜鸟程序员?
  10. 重磅:JDK11正式发布!史上最全所有特性完整解读!