Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1103161
  • 博文数量: 276
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-24 20:31
文章分类

全部博文(276)

文章存档

2020年(1)

2015年(5)

2012年(2)

2011年(6)

2010年(7)

2009年(224)

2008年(31)

我的朋友

分类: Oracle

2009-07-15 14:41:35

在数据库挂起时,需要进行以下操作:

1. 在现有的SQLPLUS连接中产生HANGANALYZE trace 文件:
SQL> oradebug setmypid
SQL> oradebug unlimit
SQL> oradebug tracefile_name
SQL> oradebug hanganalyze 3
等待3分钟 (如果时间不允许,至少要做一次)
SQL> oradebug hanganalyze 3
等待3分钟
SQL> oradebug hanganalyze 3

2. 在另外一个现有的SQLPLUS连接中产生SYSTEMSTATE DUMP文件:
SQL> oradebug setmypid
SQL> oradebug unlimit
SQL> oradebug dump systemstate 10
等待3分钟 (如果时间不允许,至少要做一次。而且要注意USER_DUMP_DEST目录所在文件系统的剩余空间大小是否足够,如果剩余空间不足200MB时,应立即中断systemstate的dump操作)
SQL> oradebug dump systemstate 10
等待3分钟
SQL> oradebug dump systemstate 10

3. truss出新的sqlplus连接进程:
$ truss sqlplus ‘/ as sysdba’
将屏幕输出记录下来。

4. truss出所有的后台关键进程:(以下以SZDB2数据库主机为例:注意修改目录名称)
$ cd /oracle/audit_sz2
$ mkdir truss_log
$ cd truss_log
$ ps -ef|grep ora_|grep -v ora_q0|grep -v ora_pz|grep -v grep | awk ‘{print ” nohup truss -aefo “$9″.log -p “$2″ &”}’|sh
过3分钟或更长时间,再执行以下命令:
$ ps -ef|grep truss|grep -v grep |awk ‘{print “kill -9 “$2}’|sh

如果第1、2操作产生不出trace文件,就采用以下方式生成systemstate dump:
$ ps -ef|grep LOCAL=NO
随便选一个SERVER PROCESS的进程号。假如是:123456
$ dbx -a 123456
(dbx) print ksudss(10)
(dbx) detach
相应的trace文件产生在user_dump_dest目录下,文件名包含了进程号。

说明:
1. 步骤1基本上会在1分钟内就出结果的。建议先做这个步骤。
2. 步骤2可能需要较长时间。有可能是10分钟以上。
3. 步骤3应该在数据库不能登录时执行。
4. 在数据库不能登录时,步骤4最好能够持续至少1分钟。
5.大型数据库hang住的情况下,sqlplus基本上不能灯录,只能靠dump操作系统进程来获取有此信息

metalink docs id: 359536.1

介绍了更详细的在sqlplus无法登录情况下的分析方法

Solution
There are several ways of getting more information when connection to an instance is not possible by sqlplus. It is useful to collect as much information about a hang before clearing the instance.

1.) Using OS debuggers like dbx or gdb.
For example:

$ps -ef |grep $ORACLE_SID ## Use PID of any User Process instead of BG Process
$gdb $ORACLE_HOME/bin/oracle print ksudss(10)
The systemstate dump will be in the bdump or udump depending on the PID chosen

2.) Using the new 10.1 sqlplus -prelim option.
For example:

export ORACLE_SID=PROD ## Replace PROD with the SID you want to trace
sqlplus -prelim / as sysdba
oradebug setmypid
oradebug unlimit;
oradebug dump systemstate 10

3.) Finally if either option (1) or (2) is not doable, please remember to take stacks of all the Oracle Background process using pstack or gdb

For example:

script stack.log
pstack pstack

4.) Finally you may also want to collect some truss, tusc or strace of sqlplus

阅读(1093) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~