oracle创建gdb数据库,【学习笔记】Oracle无法访问 通过gdb systemstate收集数据库会话hang信息...

天萃荷净

操作系统级别做systemstate,分享一篇关于Oracle数据库无法访问时诊断思路,通过gdb systemstate收集数据库会话hang信息

在有些时候,我们需要通过systemstate或者hanganalyze来收集数据库hang信息,但是当我们的数据库不能登录的时候,无法通过常规手段来使用该方法来收集信息。ORACLE的开发者也考虑到了类似情况,让我们可以通过dbx或者gdb来收集数据库信息.这里我通过在linux平台上模拟一个新会话,然后通过gdb直接对该会话进行做systemstate,然后操作该会话(证明gdb操作后正常),来实现类似系统hang住,无法登陆的时候怎么做systemstate.

1.模拟Oracle会话

就是假设我们hang住的系统中的数据库进程(为了后面gdb和验证对会话影响而使用,不然可以直接使用oracle 后台进程来完成该操作)

[oracle@oracleplus ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 17 18:28:30 2013

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

2.查找Oracle数据库进程

在另外一个shell窗口找出数据库进程

[root@oracleplus trace]# ps -ef|grep LOCAL

oracle 7476 7473 0 18:28 ? 00:00:00 oracleora11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

root 7487 7326 0 18:28 pts/2 00:00:00 grep LOCAL

3.使用gdb做systemstate诊断

[oracle@oracleplus trace]$ gdb $ORACLE_HOME/bin/oracle 7476

GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5)

Copyright (C) 2009 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. Type "show copying"

and "show warranty" for details.

This GDB was configured as "i386-redhat-linux-gnu".

…………

Reading symbols from /u01/oracle/oracle/product/11.2.0/db_1/lib/libnque11.so...

Loaded symbols for /u01/oracle/oracle/product/11.2.0/db_1/lib/libnque11.so

0xb789c424 in __kernel_vsyscall ()

(gdb) print ksudss(10)

$1 = 0

(gdb) quit

A debugging session is active.

Inferior 1 [process 7476] will be detached.

Quit anyway? (y or n) y

Detaching from program: /u01/oracle/oracle/product/11.2.0/db_1/bin/oracle, process 7476

查看trace文件

[oracle@oracleplus trace]$ ls -l *7476*.trc

-rw-r----- 1 oracle oinstall 742438 Jan 17 18:28 ora11g_ora_7476.trc

[oracle@oracleplus trace]$ more ora11g_ora_7476.trc

Trace file /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_7476.trc

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORACLE_HOME = /u01/oracle/oracle/product/11.2.0/db_1

System name: Linux

Node name: oracleplus

Release: 2.6.32-200.13.1.el5uek

Version: #1 SMP Wed Jul 27 20:21:26 EDT 2011

Machine: i686

VM name: VMWare Version: 6

Instance name: ora11g

Redo thread mounted by this instance: 1

Oracle process number: 21

Unix process pid: 7476, image: oracle@oracleplus (TNS V1-V3)

*** 2013-01-17 18:28:59.225

*** SESSION ID:(143.23) 2013-01-17 18:28:59.225

*** CLIENT ID:() 2013-01-17 18:28:59.225

*** SERVICE NAME:(SYS$USERS) 2013-01-17 18:28:59.225

*** MODULE NAME:(sqlplus@oracleplus (TNS V1-V3)) 2013-01-17 18:28:59.225

*** ACTION NAME:() 2013-01-17 18:28:59.225

===================================================

SYSTEM STATE (level=10)

------------

System global information:

processes: base 0x32bc5b38, size 150, cleanup 0x32bd5990

allocation: free sessions 0x32085b84, free calls (nil)

control alloc errors: 0 (process), 0 (session), 0 (call)

PMON latch cleanup depth: 0

seconds since PMON's last scan for dead processes: 693

system statistics:

这里证明使用gdb–>print ksudss(10)对数据库做的是systemstate level 10

4.验证做gdb的进程

SQL> select * from dual;

D

-

X

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

证明被gdb处理过的进程还是正常(未收到额外破坏),所以我们可以确定在系统hang住,而且新会话不能正常建立连接的时候,我们可以尝试着使用ksudss(10)来对系统做systemstate然后分析

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之【学习笔记】Oracle无法访问 通过gdb systemstate收集数据库会话hang信息

你可能感兴趣的:(oracle创建gdb数据库)