`
ijavagos
  • 浏览: 1187376 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Oracle shutdown immediate hang住 现象分析

 
阅读更多

前几天群里的一个朋友说他的数据库shutdown immediate后不能关闭。 hang住了。 这种情况以前也遇到过一次,是测试库。 就直接shutdown abort了。 当然生产库不建议这么做。

Oracle metalink上搜了一些有关执行shutdown immedate 命令hang住或者slow的文章。 整理如下。

. BUG 导致shutdown immediate Hang

1.1 Bug 6512622SHUTDOWN IMMEDIATE hangs / OERI[3708]

This note gives a brief overview bug 6512622.
The content was last updated on: 18-NOV-2010
Click
here for details of each of the sections below.

Affects:

Product (Component)

Oracle Server (Rdbms)

Range of versions believed to be affected

Versions BELOW 11.1

Versions confirmed as being affected

10.2.0.4

10.2.0.3

Platforms affected

Generic (all / most platforms affected)

Fixed:

This issue is fixed in

11.1.0.6 (Base Release)

10.2.0.5 (Server Patch Set)

10.2.0.4.3 (Patch Set Update)

10.2.0.4 Patch 27 on Windows Platforms

1.2 Bug 5057695: Shutdown Immediate Very Slow To Close Database [ID 428688.1]

Apply one off Patch 5057695 available on My Oracle Support on top of 9.2.0.8, 10.2.0.2 or 10.2.0.3.

The fix is included as of the 10.2.0.4 patchset.

在这里就列举2个,貌似看到的bug不止这2个。 没有细数了。

. Shutdown immediate hang住的一般原因

Metalink 的说明如下:

Shutdown Immediate Hangs: Common Causes [ID 106474.1]

http://blog.csdn.net/tianlesoftware/archive/2011/01/03/6114029.aspx

在这篇文章里提到了2个因素:

1Rollbacks

2Temp segment cleanup

Rollbacks: If a large dml statement is in progress it must roll back before the shutdown completes. In pre 8.1 versions of Oracle this can be made to go faster with a higher cleanup_rollback_entries, but be careful because too high a setting can cause resource contention during normal database operation.

Temp segment cleanup: If your tablespace used for temp sort segments is of type temporary (as shown by the CONTENTS column of DBA_TABLESPACES) the extents, once allocated, are never deallocated until shutdown. Instead they are tracked in the SGA. This helps reduce dictionary cache contention during normal database operation. Unfortunately, when we shutdown these extents must all be deallocated at once which can lead to the dictionary cache contention we avoided while we were running. The tablespace of type temporary was introduced in 7.3.

These two problems can also combine to make things even slower as a rollback will also deallocate extents, leading to further contention on the parts of the dictionary cache that track used and free extents.

. 跟踪导致hang住的原因

Metalink 的文章:

How to Check Why Shutdown Immediate Hangs? [ID 164504.1]

http://blog.csdn.net/tianlesoftware/archive/2011/01/03/6114033.aspx

这篇文章提到了2种不同方法:

A. While shutdown immediate is hanging

Start Server Manager (or SQL*Plus for 8i or higher)

SVRMGRL> connect internal (or SYSDBA for 8i or higher)

SVRMGRL> select * from x$ktuxe where ktuxecfl = 'DEAD';

This shows dead transactions that smon is looking to rollback.

B. Plan to shutdown again and gather some information. Before issuing the

shutdown immediate command set some events as follows:

SVRMGRL> connect internal

SVRMGRL> alter session set events '10046 trace name context forever,level 12';

SVRMGRL> alter session set events '10400 trace name context forever, level 1';

SVRMGRL> shutdown immediate;

10046 turns on extended SQL_TRACE for the shutdown process.

10400 dumps a systemstate every 5 minutes.

Oracle 10g 11g的官方文档都没有搜到SVRMGRL命令的相关说明。 这个应该是8i版本里的命令。

以前整理过一篇在DB hang住情况下使用sqlplus的文章:

Oracle sqlplus prelim 参数介绍

http://blog.csdn.net/tianlesoftware/archive/2009/12/10/4980545.aspx

在系统已经hang的时, 可以在sqlplus命令中使用参数: -prelim来连接。这个时候连接到的是SGA而不是数据库。 因为也没有session被创建。

连接上之后我们就可以启动trace或者使用sql 来查看DB的相关信息。

. 关闭DBhang住该做些什么

官网上的一篇文章:

What To Do and Not To Do When 'shutdown immediate' Hangs [ID 375935.1]

http://blog.csdn.net/tianlesoftware/archive/2011/01/03/6114031.aspx

The big problem in these situations is that it is noticed only after the shutdown immediate has been issued.

This kind of situation is mostly caused by 2 things:

1. a large query running at the shutdown moment.

2. a large transaction running at the shutdown moment.

Both have to complete in order for the database to be brought down when shutdown immediate is issued.

Actually, the files cannot be closed consistently because of one of the 2 possibilities above and, as such, the transition from OPEN to MOUNT is postponed until the files are closed, which means that either the large query completes or the large transaction is rolled back. This is not a hang, it is the expected behavior.

-- 这段讲的很清楚。 DB dismount时需要做的2个操作。

So, before issuing the shutdown immediate, it would be recommended to check the following views, especially when the database needs to be brought down for a very short period of time:

1. for large queries:

select count(*) from v$session_longops where time_remaining>0;

2. for large transactions:

select sum(used_ublk) from v$transaction;

A result greater than 0 for the first query and a large value returned for the second one would mean a relatively long time to wait until the shutdown immediate completes.

1. For the large queries situation, when the shutdown immediate is hanging, you can just bring down the database using: shutdown abort, as the database could be easily brought to a consistent state by:

startup restrict followed by shutdown immediate.

One should take the backup and/or do whatever else need to be done after the shutdown immediate.

--对于大量查询的,我们可以使用shutdown abort来结束。

2. For the second situation, the workaround cannot be applied, especially when it's needed to take a cold backup. The database must be closed in a consistent state in order to do this and the consistent state cannot be achieved until all the transactions have completed one way or another (commit/rollback).

As such, it's up to the local personnel to decide what to do, depending on the local needs.

It is very important to realize that: by shutting down a database you do not solve a performance problem caused by a large transaction. You are only making things worse.

There are situations when the database is brought down even when a large transaction/large recovery is taking place. Then it's brought up again and a new shutodwn is tried. Again, the shutdown immediate is hanging, for a very simple reason - the large recovery is still going on.

At this moment, the v$transaction view is not displaying anything. However, it is still possible to check the recovery operation by checking the:

select * from v$fast_start_transactions;

and/or

select * from v$fast_start_servers;

views. They are the ones that display the recovery status.

As such, when a large transaction is taking place, do not try successive shutdown aborts, startups and shutdown immediate. The hang will reoccur. The database must be consistent when the database is dismounted - performing successive shutdowns/startups is not helping at all, it's only making the recovery even more lengthy.

--对于大量事务的情况下,不要强制关闭数据库。

You should prevent these situations by notifying the users a shutdown will be done and no large operations should be started.

If a large operation has already started at the moment when you want to shutdown immedate, assess what would be faster - rollback the current situation or allow it to complete.

另一篇文章:

Shutdown Normal or Shutdown Immediate Hangs. SMON disabling TX Recovery [ID 1076161.6]

http://blog.csdn.net/tianlesoftware/archive/2011/01/03/6114038.aspx

在这篇文章里提到了如下内容:

During a SHUTDOWN IMMEDIATE and SHUTDOWN NORMAL, SMON is cleaning up extents which are no longer needed and marking them as freed.

Either wait for SMON to clean up the free extents in the database as it shuts down or perform a SHUTDOWN ABORT to shutdown the instance. A SHUTDOWN ABORT will not perform a clean shutdown.

. 建议关闭DB的顺序

1. 停应用

2. 停监听

3. shutdown immediate

如果这样还是无法关闭的话,可以尝试手工提交(commit)和checkpointalter system checkpoint),如果还没有办法,就kill session 监听的进程(LOCAL=NO)。

Oracle 服务器 进程中的 LOCAL=NO LOCAL=YES

http://blog.csdn.net/tianlesoftware/archive/2010/06/17/5675404.aspx

在这篇文章里做了一点说明, 就是在服务器上连接数据库,它是不走监听的。 就是LOCAL=YES的进程。 对于非本地的连接,都是走监听。 在服务器上显示的是LOCAL=NO

注意:对于已经建立的非本地监听连接,即LOCAL=NO 关闭监听对它们是没有影响的。 相关进程仍然存在,通过它们与数据库连接的session仍然可以继续执行事务操作。

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

Blog http://blog.csdn.net/tianlesoftware

网上资源: http://tianlesoftware.download.csdn.net

相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx

DBA1 群:62697716(); DBA2 群:62697977()

DBA3 群:62697850 DBA 超级群:63306533;

聊天 群:40132017

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

分享到:
评论

相关推荐

    oracle 中shutdown命令的实用

    在oracle数据库中,关于shutdown命令的详解。对于新手很有帮助

    Oracle 10g启动后报ORA-16038错误的解决方法

    ORA-00312: online log 1 thread 1: '/oradata/10g/db/instant/redo01.log' SQL> ALTER SYSTEM SET...SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down.

    Oracle initialization or shutdown in progress 解决方法

    Oracle initialization or shutdown in progress 是oracle误删除文件所造成的sqlplus不能登陆的问题 正确,经验。

    ORACLE initialization or shutdown in process

    碎片处理工具,处理碎片至使oracle数据库不能启动, 解决方法: 进入dos: 以DBA用户登录,具体命令是 sqlplus /NOLOG SQL>connect sys/change_on_install as sysdba 提示:已成功 SQL>shutdown normal 提示:...

    Oracle数据库startup和shutdown方式

    Oracle数据库startup和shutdown方式

    ora-01033:oracle initialization or shutdown in progress 解决方法

    ora-01033:oracle initialization or shutdown in progress 解决方法 ora-01033:oracle initialization or shutdown in progress 解决方法 ora-01033:oracle initialization or shutdown in progress 解决方法 ora-...

    oracle关闭后无法startup

    oracle连接后,用shutdown immediate关闭数据库,再startup mount,出现“监听程序当前无法识别连接描述符中请求的服务”

    ora-01033 oracle initialization or shutdown in progress

    数据库导致连接出现异常的解决办法整理,这是 oracle连接问题的具体解决方案

    启动Oracle常见疑难问题分析

    如果用户已经进入了数据库,使用SHUTDOWN IMMEDIATE 或SHUTDOWN ABORT命令来执行关闭数据库,则用户将失去连接,直到数据库重新启动。经常关闭和启动会对数据库性能造成一定的影响,当然也会影响到用户对数据库的...

    睿备份-oracle备份工具.zip

    shutdown immediate; startup mount; restore database until time "to_date('2019-08-19 08:49:00','yyyy-mm-dd hh24:mi:ss')"; recover database until time "to_date('2019-08-19 08:49:00','yyyy-mm-dd hh24:mi:...

    服务器(ORACLE)启动与关闭.doc

    在SVRMGRL中执行shutdown immediate,数据库并不立即关闭,而是在Oracle执行某些清除工作后才关闭(终止会话 、释放会话资源),当使用shutdown不能关闭数据库时,shutdown immediate可以完成数据库关闭的操作。...

    oracle修改字符集

    SQL>shutdown immediate; 启动数据库到mount状态下 SQL> STARTUP MOUNT; Java代码 收藏代码 ORACLE instance started. Total System Global Area 76619308 bytes Fixed Size 454188 bytes Variable Size ...

    DBA_Oracle Startup / Shutdown启动和关闭过程详解(概念)(对数据库进行各种维护操作)

    1. Oracle启动需要经历四个状态:SHUTDOWN 、NOMOUNT 、MOUNT 、OPEN 2. Oracle关闭的四种方式:Normal, Immediate, Transactional, Abort 3. 启动和关闭过程详解   二、数据库启动过程 1.NoMount 模式(启动实例不...

    Centos7.0下安装oracle12cR2-v6.0全流程

    Oracle12c安装使用教程,包含各类资源下载链接。 1.启动 1.#su - oracle 切换到 oracle 用户且...4.SQL>SHUTDOWN IMMEDIATE 关闭 db 12C新特性:CDB与PDB,请见: http://www.cnblogs.com/kerrycode/p/3386917.html

    Linux系统怎么用命令重启oracle数据库.docx

    exit EOF $sh dbstop.sh 即可 =============================================== $ su - oracle $ lsnrctl stop $ sqlplus "/as sysdba" SQL> shutdown immediate; SQL> quit Linux系统怎么用命令重启oracle数据库...

    如何快速的杀掉Oracle的Session

     1、 一些时候,由于我们的数据量很大,相应的事务大并且多,在做shutdown immediate的时候会花费好多的时间,而我们却想用shutdown immediate的方式,而又要把数据库迅速的shutdown下来。  2、 我们的应用可能...

    oracle操作手册

    SVRMGR>shutdown immediate; 这种方式下关闭数据库并不等待用户断开连接,而是由系统断开与用户的连接,然后关闭数据库。 3. 异常关闭 SVRMGR>shutdown abort; 这种方式下关闭数据库系统不做任何的检查与回退操作而...

    oracle - answer

    SHUTDOWN IMMEDIATE; 在操作系统中重命名userdata03.dbf、example03.dbf分别为userdata04.dbf、example04.dbf STARTUP MOUNT; ALTER DATABASE RENAME FILE ‘D:\ORACLE\ORADATA\ORCL\userdata03.dbf’, ‘D:\ORACLE\...

    oracle——创建DB和表空间

    SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> conn/as sysdba Connected to an idle instance. SQL> startup nomount ORACLE instance started.

    Oracle sqlplus命令详解

    一、ORACLE的启动和关闭  1、在单机环境下要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下  su - oracle  a、启动ORACLE系统  oracle>svrmgrl  SVRMGR>connect internal  SVRMGR>startup  ...

Global site tag (gtag.js) - Google Analytics