Oracle hang 之sqlplus -prelim使用方法

來源:互聯網
上載者:User

Oracle hang 之sqlplus -prelim使用方法

很多情況下,Oracle hang導致sqlplus無法串連,從而無法獲得Oracle系統和進程狀態,使得定位問題缺少強有力的依據。所幸的是Oracle 10g推出了sqlplus -prelim選項,在Oracle掛起時依然能使用sqlplus,從而能獲得資料庫狀態。
使用方法如下

引用
$ sqlplus -prelim "/as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Mar 28 06:40:21 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

在prelim模式下,不可以查詢資料字典,但可以關閉資料庫

引用
SQL> select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01012: not logged on


引用
SQL> shutdown abort
ORACLE instance shut down.

但可以使用oradebug,但對於系統診斷,已經足夠了
dump系統狀態

引用
SQL> oradebug setmypid                                           
Statement processed.
SQL> oradebug unlimit
Statement processed.
SQL> oradebug dump systemstate 266
Statement processed.

或者dump hanganalyze

引用
SQL> oradebug  hanganalyze 3
Hang Analysis in /oracle/app/oracle/admin/ora10g/udump/ora10g_ora_52642.trc

對於rac


引用
SQLPLUS> oradebug setmypid

SQLPLUS>oradebug setinst all

SQLPLUS>oradebug -g def hanganalyze 3


或者dump 進程狀態

引用
SQL> oradebug dump processstate 10
Statement processed.


進一步,如果有10g用戶端,資料庫是9i,依然可以用-prelim

引用
$ sqlplus -prelim /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Mar 28 06:50:19 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn sys/oracle@ora9i as sysdba
Prelim connection established
SQL>  oradebug setmypid
Statement processed.
SQL> oradebug unlimit
Statement processed.
SQL>  oradebug dump systemstate 266
Statement processed.
0

sqlplus -prelim/ as sysdba用法 2009-02-03 14:20:47
分類: Oracle


原文見:eygle部落格
在某些情況下,資料庫失去響應,sqlplus也無法串連,此時通常只能通過殺掉進程來解決。

但是我們仍然希望能夠獲得此時的資料庫狀態資訊,以便用於事後診斷。
從Oracle10g開始,sqlplus提供了一個參數選項-prelim,可以在通常sqlplus無法串連的情況下進行串連。
通過以下步驟可以擷取系統資訊:

sqlplus -prelim / as sysdba
oradebug setmypid
oradebug unlimit;
oradebug dump systemstate 10

這種方法非常有用:

$ sqlplus -prelim / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 25 09:42:20 2007

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

SQL>


但是需要注意的是,在Oracle 10.2.0.1中,使用如上方法會出現一個錯誤:

$ sqlplus -prelim / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 25 09:38:14 2007

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

SQL> oradebug setmypid
Statement processed.
SQL> oradebug unlimit
Statement processed.
SQL> oradebug dump systemstate 10
ORA-03113: end-of-file on communication channel
ORA-24323: value not allowed


此時在alert檔案中會記錄如下錯誤提示:

Thu Oct 25 09:38:32 2007
System State dumped to trace file
Thu Oct 25 09:38:32 2007
Errors in file /opt/oracle/admin/test201/udump/test201_ora_1402.trc:
ORA-07445: exception encountered: core dump [kgldmp()+1360] [SIGSEGV] [Address not mapped to object] [0x000000030] [] []

這是由於一個Bug導致的,Bug號為5730231,該Bug在10.2.0.3中修正。

對於9i也有變通的方法使用

-prelim is feature of Sql*Plus 10g and latter.

So as long you have any Sql*Plus 10g or latter version (ex. from client installation) and a valid net service name to connect to your 9i database you should be able to establish a "backdoor" connection.

You can do the following:

$sqlplus -prelim /nolog

and once you are in, just connect to the database using SYSDBA account

SQL> connect sys/password@net_service_name as sysdba
Prelim connection established

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.