0

0

Oracle hang 之sqlplus -prelim使用方法

php中文网

php中文网

发布时间:2016-06-07 17:34:07

|

1388人浏览过

|

来源于php中文网

原创

很多情况下,Oracle hang导致sqlplus无法连接,从而无法获得Oracle系统和进程状态,使得定位问题缺少强有力的依据。所幸的是Orac

很多情况下,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也无法连接,此时通常只能通过杀掉进程来解决。

AutoDraw
AutoDraw

AutoDraw是一个绘图工具,可以将草图转换成现成的模型图片

下载

但是我们仍然希望能够获得此时的数据库状态信息,以便用于事后诊断。
从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

linux

相关专题

更多
漫蛙2入口地址合集
漫蛙2入口地址合集

本专题整合了漫蛙2入口汇总,阅读专题下面的文章了解更多详细内容。

13

2026.01.06

AO3中文版地址汇总
AO3中文版地址汇总

本专题整合了AO3中文版地址合集,阅读专题下面的文章了解更多详细内容。

5

2026.01.06

python cv2模块教程大全
python cv2模块教程大全

本专题整合了python cv2模块相关教程,阅读专题下面的文章了解更多详细教程。

10

2026.01.06

python创建txt文件教程大全
python创建txt文件教程大全

本专题整合了python创建txt文件相关教程,阅读专题下面的文章了解更多详细内容。

13

2026.01.06

python去掉字符串空格教程大全
python去掉字符串空格教程大全

本专题整合了python去掉字符串空格教程大全,阅读专题下面的文章了解更多详细内容。

2

2026.01.06

Python /与// 教程大全
Python /与// 教程大全

本专题整合了python的/和//的相关内容大全,阅读下面的文章了解更多详细内容。

13

2026.01.06

Python /与// 教程大全
Python /与// 教程大全

本专题整合了python的/和//的相关内容大全,阅读下面的文章了解更多详细内容。

0

2026.01.06

Python /与// 教程大全
Python /与// 教程大全

本专题整合了python的/和//的相关内容大全,阅读下面的文章了解更多详细内容。

0

2026.01.06

python func函数合集
python func函数合集

本专题整合了python func函数相关教程,阅读专题下面的文章了解更多详细内容。

0

2026.01.06

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
SQL 教程
SQL 教程

共61课时 | 3.3万人学习

Java 教程
Java 教程

共578课时 | 42.8万人学习

oracle知识库
oracle知识库

共0课时 | 0人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号