shutdown immediate 
经常关库时hang住,在alert中有

License high water mark = 4
All dispatchers and shared servers shutdown

多等一会会出现
SHUTDOWN: Active processes prevent shutdown operation

造成这个现象的原因是(也可能是em的原因,这篇与em无关):

之前的session没有断开,而后又使用了host切换到OS提示符下,导致数据库无法正常关闭

[oracle@localhost ~]$ sqlplus scott/tiger

SQL> show user
USER is "SCOTT"
SQL> !
[oracle@localhost ~]$ echo $$
3897
[oracle@localhost ~]$ sqlplus / as sysdba

SQL> select pid,spid,p.pname,p.program from v$process p,v$session s where p.addr=s.paddr and s.sid=userenv('sid');

PID SPID                     PNAME PROGRAM
---------- ------------------------ ----- ------------------------------------------------
        27 3911                           oracle@localhost.myrh6 (TNS V1-V3)

SQL> shutdown immediate

hang住

alert内容:

Sat Jan 04 17:41:53 2014
Shutting down instance (immediate)
Stopping background process SMCO
Shutting down instance: further logons disabled
Sat Jan 04 17:41:53 2014
Stopping background process CJQ0
Stopping background process QMNC
Stopping background process MMNL
Stopping background process MMON
License high water mark = 4
All dispatchers and shared servers shutdown

Sat Jan 04 17:46:58 2014
SHUTDOWN: Active processes prevent shutdown operation

Sat Jan 04 17:52:00 2014
SHUTDOWN: Active processes prevent shutdown operation

另一终端
$ pstree -p

├─sshd(1668)─┬─sshd(1838)───sshd(1840)─┬─bash(3067)───tail(3095)
│            │                         └─bash(3106)───rlwrap(3893)───sqlplus(3894)─┬─bash(3897)───sqlplus(3910)───oracle(3911)
│            │                                                                     └─oracle(3895)

[oracle@localhost ~]$ ps -ef |grep oracle
可以发现
oracle    3895  3894  0 17:34 ?        00:00:00 [oracle]

一个fg process变成了僵尸进程

[oracle@localhost ~]$ ps -o pid,ppid,state -p 3895 
  PID  PPID S
 3895  3894 Z

kill -9 3895 是杀不掉僵尸进程的

解决办法:

1.可以再等会,会自动结束
SQL> shutdown immediate

SQL> Error 45 initializing SQL*Plus
Internal error
Hangup
[oracle@localhost ~]$ [oracle@localhost ~]$

2.kill父进程,子进程(即使是zombie)也会一起结束
ps -Al 或 ps -o pid,ppid -p pid
ppid是3894

kill -9 3894

3.hang住的终端尝试ctrl+c,或ctrl+z,或直接关了, 重新sqlplus / as sysdba
shutdown abort
startup restrict 
shutdown normal

ctrl-c 是发送 SIGINT 信号,终止一个进程
ctrl-z 是发送 SIGSTOP信号,挂起一个进程

ctrl-d不发送信号. 如果ctrl-d时当前行没有输入字符, bash把它当作EOF字符, 结束/退出.
如果ctrl-d时当前行有输入, 删除光标后的字符. 这是readline的特性, 不发送信号.

/* 以下引用 http://blog.csdn.net/leshami/article/details/9466559 */

Oracle对此给出的说明是这不是一个Oracle bug,而是使用了一个非正常的数据库关闭顺序。
建议先断开所有连接再关闭数据库,如先关闭db control,具体见下面的Oracle 文档及示例。

Doc ID 416658.1

Shutdown Immediate Hangs / Active Processes Prevent Shutdown (Doc ID 416658.1)

Applies to: 
Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.2.0.2 - Release: 10.1 to 11.2
Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.2.0.2   [Release: 10.1 to 11.2]
Information in this document applies to any platform.

Symptoms
The 'shutdown immediate' command hangs or is very slow

The alert log lists messages like:

SHUTDOWN: waiting for active calls to complete.ACTIVE PROCESSES PREVENT SHUTDOWN OPERATION

Cause
This is not a bug.

If the DB Control repository is running on the database target against which shutdown immediate was attempted then an incorrect 
order of events seems used.

You should stop DB Control first to get rid of all connections between DB Control and the repository database and then shutdown
the database with 'shutdown immediate'.

Current database sessions may show:

SQL> select SID, USERNAME, PROGRAM from v$session;
SID   USERNAME               PROGRAM
----- ---------------------- ----------------------------------
  243 SYSTEM                 SQL Developer
  246 SYSMAN                 OMS
  247                        oracle@lgiora09 (q001)
  248                        oracle@lgiora09 (q000)
  251 DBSNMP                 emagent@lgiora09 (TNS V1-V3)
  252 SYSMAN                 OMS
  253 SYSMAN                 OMS
  254 DBSNMP                 emagent@lgiora09 (TNS V1-V3)
  255 SYSTEM                 java.exe
  256 SYSMAN                 OMS

Clearly OMS and OEM are connected (Oracle Enterprise Manager Grid Control or DBConsole) via users SYSMAN and DBSNMP.
These sessions should be de-activated (that is to log off any OEM, OMS, SYSMAN and DBSNMP) before the shutdown immediate is attempted.

Oracle Enterprise Manager, Grid Control, Dbconsole and agents keep doing internal processing.
This may include a few PLSQL notification procedures running on the database by database control like
BEGIN EMD_NOTIFICATION.QUEUE_READY(:1, :2, :3); END;

As per internal documentation of the shutdown immediate, if there are active calls then it would wait for all the active calls to finish.

Solution
To implement the solution:

1. Given OEM connections are active (SYSMAN and DBSNMP), de-activate these sessions, i.e. by stopping the agent/DBConsole

2. Then shutdown immediate as normal

- OR -

There may be processes still running and holding locks at the time a shutdown is issued. 
Sometimes these are failed jobs or transactions, which are effectively 'zombies', which are not able to receive a signal from Oracle.

If this occurs, the only way to shutdown the database is by doing:

sql> 
shutdown abort 
startup restrict 
shutdown normal

The startup does any necessary recovery and cleanup, so that a valid cold backup can be taken afterward.

If this issue occurs frequently, it would be a good practice to see if there are any active user processes running in v$session or
v$process before shutting down the instance.

If the problem persists, and no apparent user processes are active, you can set this event prior to issuing the shutdown command 
in order to see what is happening. This will dump a systemstate every 5 minutes while shutdown is hanging

SQL> 
connect / as sysdba 
alter session set events '10400 trace name context forever, level 1'

http://blog.itpub.net/28859270/viewspace-1067155/

shutdown immediate时 hang住 (转载)的更多相关文章

  1. Oracle数据库shutdown immediate被hang住的几个原因

    实验操作环境:         操作系统:Red Hat Enterprise Linux ES release 4 (Nahant Update 6)                         ...

  2. 【翻译自mos文章】当指定asm disk 为FRA时,11.2.0.3的dbua hang住

    当指定asm disk 为FRA时.11.2.0.3的dbua hang住 来源于: 11.2.0.3 DBUA Hangs While Specifying ASM Disk To FRA (文档 ...

  3. 【转载】MySQL被慢sql hang住了,用shell脚本快速清除不断增长的慢sql的办法

    原文地址:MySQL被慢sql hang住了,用shell脚本快速清除不断增长的慢sql的办法 作者:mchdba 某个初级dba误删index,mysql漫山遍野全是10S以上的慢sql,mysql ...

  4. NDMCDB数据库hang住故障分析 - cursor: pin S wait on X

    问题描写叙述: 上午刚刚到办公室,就有监控人员邮件反馈,昨晚NDMCDB407数据库被重新启动过,让我分析一下数据库重新启动的原因.因为昨晚业务有版本号上线,所以短信警告关闭了,所以没有短信下发到我手 ...

  5. 一次进程hang住问题分析。。。

    这两天有同学使用数据校验工具时发现进程hang住了,也不知道什么原因,我简单看了看进程堆栈,问题虽然很简单,但能导致程序hang住,也一定不是小问题.简单说明下程序组件的结构,程序由两部分构成,dbc ...

  6. truncate表hang住(等待时间较长),出现enq:RO fast object reuse等待事件

    有一个应用truncate表等待了一晚上,一个定时任务,跑了几年了,今天早上来发现昨晚没有执行完成,hang住了,查询发现等待事件 fast object reuse. 10.2.0.4的库 Bug ...

  7. 一次数据库hang住的分析过程

    现象: 普通用户和sysdba都无法登陆,业务中断 分析过程: 1.先做hanganalyze和systemstate dump $sqlplus -prelim "/as sysdba&q ...

  8. 如何诊断oracle数据库运行缓慢或hang住的问题

    为了诊断oracle运行缓慢的问题首先要决定收集哪些论断信息,可以采取下面的诊断方法:1.数据库运行缓慢这个问题是常见还是在特定时间出现如果数据库运行缓慢是一个常见的问题那么可以在问题出现的时候收集这 ...

  9. Flash Recovery Area空间不足导致DB不能打开或hang住处理方法

    当归档目录设置在闪回恢复区,并且闪回恢复区又满了的情况下, DB 就会无法归档而hang住或者无法打开. 这种情况下打开数据库会遇到如下错误信息: SQL> select status from ...

随机推荐

  1. HTML5适合移动应用开发的几大特性

    1.离线缓存为HTML5开发移动应用提供了基础 HTML5 Web Storage API可以看做是加强版的cookie,不受数据大小限制,有更好的弹性以及架构,可以将数据写入到本机的ROM中,还可以 ...

  2. 利用Jmeter进行Web测试

    JMeter介绍 脚本录制 运行JMeter进行测试 JMeter主要组件介绍 参数化设置 动态数据关联 使用命令行运行JMeter脚本 利用XSLT分析JMeter结果文件 1:JMeter,一个1 ...

  3. 升级设置win2008r2开发环境,遇到问题小结

    升级设置2008r2开发环境,是一般程序员经历的事情.许多从vs 2003,vs2005+sql2000+win2003过来,但是,时间推移,技术革新,64位的推行.架构的变化和强大.我们也只可以学习 ...

  4. android 面试总结,后续注意学习

    1.数据结构和算法 一般情况下,工作中是用不到的,但是就是问,每个公司都问,而且有的公司还问的特别深,还让你手写代码.我觉得这个确实有点恶心,我个人也是很讨厌算法的,但是真是没办法,人家就问,你说怎么 ...

  5. zookeeper初识之原理

    ZooKeeper 是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等. Zookeeper是hadoop的一个子项目 ...

  6. apache2服务器mod_rewrite模块 开启方法[linux, ubuntu]

    在UBUNTU系统中要启用mod_rewrite的方法有两种: 第一种: 在终端中执行 sudo a2enmod rewrite 指 令后,即启用了 Mod_rewrite 模块, apache2服务 ...

  7. codeforces 682D(DP)

    题目链接:http://codeforces.com/contest/682/problem/D 思路:dp[i][j][l][0]表示a串前i和b串前j利用a[i] == b[j]所得到的最长子序列 ...

  8. 打包ane之后在FB上生成ipa的阶段错误

    1. 初次打包 碰到这个错误得 就是你mac 上jre版本的问题 此时用 FB 必须是跑在jre1.6版本上的 我得是1.8 上图 版本可以自己查下 已经截图了 而且 你如果想要下载 1.6版本的 就 ...

  9. SVN提交碰到的问题奇怪的问题

    svn提交遇到恶心的问题,可能是因为上次cleanup中断后,进入死循环了. 错误如下: 解决方法:清空svn的队列 1.下载sqlite3.exe 2.找到你项目的.svn文件,查看是否存在wc.d ...

  10. leetcode51. N-Queens

    The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens ...