当数据库出现严重的性能问题或者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收集了进程的相关,但是如何有效的解读相关信息,并诊断问题是一个不小的难题和挑战!

 

参考资料:

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

Oracle systemstate dump介绍的更多相关文章

  1. systemstate dump 介绍

    systemstate dump 介绍 By Janezhang-Oracle on 十二月 13, 2012 当数据库出现严重的性能问题或者hang了的时候,我们非常需要通过systemstate ...

  2. Oracle下如何收集 Systemstate dump

    2: dump (不包括lock element) 10: dump 11: dump + global cache of RAC 256: short stack (函数堆栈) 258: 256+2 ...

  3. 针对某个数据库error做systemstate dump

    如果想对某个具体error做systemstate dump收集,可以借助event来实现. 例如想在数据库遇到ora-00054时,收集数据systemstate dump信息: 开启: sqlpl ...

  4. Oracle优化器介绍

    Oracle优化器介绍 本文讲述了Oracle优化器的概念.工作原理和使用方法,兼顾了Oracle8i.9i以及最新的10g三个版本.理解本文将有助于您更好的更有效的进行SQL优化工作. RBO优化器 ...

  5. oracle常用视图介绍

    oracle常用视图介绍---------------------2013/10/04(last updated) dba_开头:   dba_users     数据库用户信息   dba_segm ...

  6. oracle的回收站介绍

    昨天做的展示oracle表空间功能剩余空间的功能,发现查询表dba_free_space时特别慢,经网上搜索,说是由于表空间碎片和回收站(Oracle 10g以后才有)引起的,后来搜到一片介绍回收站的 ...

  7. oracle 锁的介绍 (转)

    本文转自:http://blog.csdn.net/gyb2013/article/details/6929697 一.什么是锁: Oracle的锁机制是一种轻量级的锁定机制,不是通过构建锁列表来进行 ...

  8. 【转】 Linux Core Dump 介绍

    ===============================================================  Linux core dump的祥细介绍和使用 =========== ...

  9. Oracle 学习笔记(一)Oracle的基本介绍与语法

    1.1 Oracle基础知识 1.1.1 介绍 Oracle数据库的主要特点: 支持多用户.大事务量的事务处理 在保持数据安全性和完整性方面性能优越 支持分布式数据处理 具有可移植性 1.1.2 Or ...

随机推荐

  1. 介绍开源的.net通信框架NetworkComms框架 源码分析(六)SendReceiveOptions

    原文网址: http://www.cnblogs.com/csdev Networkcomms 是一款C# 语言编写的TCP/UDP通信框架  作者是英国人  以前是收费的 目前作者已经开源  许可是 ...

  2. iOS阶段学习第28天笔记(UIView的介绍)

    iOS学习(UI)知识点整理 一.关于UIVIew 的介绍 1)概念:UIView 是用于装载并展示各类控件的大容器,是iOS中所有UI控件的基类 2)UIView  初始化实例代码 UIView * ...

  3. 为什么很多APP要有启动页面

    我们启动APP时,一般都会是一张含有LOGO的图片.这张图片叫做启动页面. 这个启动页面是必须.一定需要的吗?有什么作用?   这是苹果官方对于iOS启动页的设计说明:   为了增强应用程序启动时的用 ...

  4. 【C#】VS2015开发环境的安装和配置(二)2016-08-03更新

    分类:C#.VS2015.WPF.ASP.NET MVC.Android.iOS.Unity3D: 更新日期:2016-08-03 按下面介绍的步骤安装即可. 一.安装JDK和Android SDK ...

  5. Delegate

    public delegate void EventHandler(object sender, EventArgs e); pulic EventHandler HandleMapMessage; ...

  6. Mysql调试存储过程最简单的方法

    以前同事告诉我用临时表插入变量数据来查看,但是这种方法过于麻烦,而且Mysql没有比较好的调试存储过程的工具.今天google了下发现可以用select + 变量名的方法来调试...真是让我汗颜啊. ...

  7. Java基础复习笔记系列 三

    前几节都是基础中的基础,从第三讲的笔记开始,每次笔记针对Java的一个知识块儿.  Java异常处理 1.什么是异常? 异常是指运行期出的错误.比如说:除以一个0:数组越界:读取的文件不存在. 异常处 ...

  8. Scalaz(3)- 基础篇:函数概括化-Generalizing Functions

    Scalaz是个通用的函数式编程组件库.它提供的类型.函数组件都必须具有高度的概括性才能同时支持不同数据类型的操作.可以说,scalaz提供了一整套所有编程人员都需要的具有高度概括性的通用函数,它是通 ...

  9. (学习笔记)PHP的输出echo和print

    echo 和 print 之间的差异: echo - 能够输出一个以上的字符串 print - 只能输出一个字符串,并始终返回 1 echo语句 echo 或 echo()均可. 输出换行 echo ...

  10. ThinkCMF-幻灯片制作

    在后台的扩展工具 -> 幻灯片分类 添加分类标识为"portal_index"的分类,然后在此分类添加幻灯片. 个人认为,此处可以用于: 1. 门户网站的首页幻灯片播放功能: ...