normal数据库关闭hang的问题

Shutting down instance (normal)Stopping background process SMCOShutting down instance: further logons disabled这里涉及到shutdown normal的原理,稍后引述。

2. 此时重新登录,sqlplus / as sysdba,执行startup或shutdown immediate命令都提示失败,

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 22 17:03:06 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected.SQL> startupORA-01012: not logged onSQL> shutdown immediateORA-24324: service handle not initializedORA-24323: value not allowedORA-01090: shutdown in progress – connection is not permittedMon Jun 22 16:50:24 2015Stopping background process CJQ0Stopping background process QMNCStopping background process MMNLStopping background process MMONLicense high water mark = 125

ORA-01090提示说正在执行关闭操作,不允许其他连接的操作。

3. 其实这涉及到normal关闭的原理,他需要等待所有已连接用户中断连接,换句话说,如果仍有连接到库的用户,shutdown的操作就一直等待。这是最完全的关闭方式,但同时是变数最大的,因为可能你不知其他用户什么时候中断。

首先尝试查找出所有连接用户,用kill -9直接杀进程。

可以使用ps -ef查找所有(LOCAL=NO)的进程,LOCAL=NO表示连接不是本地,而是远程。

ps -ef|grep ora|grep -v grep|grep -v ora_|grep LOCAL=NO|awk ‘{print $2}’,然后kill -9 进程号或者ps -ef|grep ora|grep -v grep|grep -v ora_|grep LOCAL=NO|awk ‘{print $2}’|xargs kill从alert日志看:

Mon Jun 22 16:55:26 2015Active process 27446 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27402 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27555 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 11697 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 14942 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27559 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27513 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 26911 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 31993 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 30810 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27557 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 11684 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 11666 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 27510 user ‘oracle11g’ program ‘oracle@dcsopenNode1’Active process 11688 user ‘oracle11g’ program ‘oracle@dcsopenNode1’SHUTDOWN: waiting for logins to complete.Mon Jun 22 17:01:29 2015All dispatchers and shared servers shutdown

是提示了所有dispatcher和共享服务关闭,但sqlplus登录后仍是上面的提示。

4. 尝试关闭监听服务,lsnrctl stop。

问题依旧。

5. 重登陆执行shutdown abort,强制关闭。

从alert日志看:

USER (ospid: 28558): terminating the instance

Instance terminated by USER, pid = 28558

看样子是关闭了实例。

重新执行sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 22 17:43:25 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.

再次执行startup-shutdown normal,

SQL> startupORACLE instance started.Total System Global Area 3290345472 bytesFixed Size2217832 bytesVariable Size2499807384 bytesDatabase Buffers771751936 bytesRedo Buffers16568320 bytesDatabase mounted.Database opened.SQL> shutdown normalDatabase closed.Database dismounted.ORACLE instance shut down.由于现在已经没有连接的用户了,正常启动,正常关闭了。

从alert日志看,

Mon Jun 22 17:46:01 2015Starting ORACLE instance (normal)LICENSE_MAX_SESSION = 0LICENSE_SESSIONS_WARNING = 0Picked latch-free SCN scheme 3Using LOG_ARCHIVE_DEST_1 parameter default value as /oracle/ora11gR2/product/11.2.0/dbhome_1/dbs/archAutotune of undo retention is turned on. IMODE=BRILAT =27LICENSE_MAX_USERS = 0SYS auditing is disabledStarting up:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options.Using parameter settings in server-side spfile /oracle/ora11gR2/product/11.2.0/dbhome_1/dbs/spfiledcsopen.oraSystem parameters with non-default values: processes= 150 memory_target= 3152M control_files= "/oracle/ora11gR2/oradata/dcsopen/control01.ctl" control_files= "/oracle/ora11gR2/oradata/dcsopen/control02.ctl" db_block_size= 8192 compatible= "11.2.0.0.0" undo_tablespace= "UNDOTBS1" remote_login_passwordfile= "EXCLUSIVE" db_domain= "" dispatchers= "(PROTOCOL=TCP) (SERVICE=dcsopenXDB)" audit_file_dest= "/oracle/ora11gR2/admin/dcsopen/adump" audit_trail= "DB" db_name= "dcsopen" open_cursors= 300 diagnostic_dest= "/oracle/ora11gR2"Mon Jun 22 17:46:03 2015PMON started with pid=2, OS id=30699 Mon Jun 22 17:46:03 2015VKTM started with pid=3, OS id=30701 at elevated priorityVKTM running at (10)millisec precision with DBRM quantum (100)msMon Jun 22 17:46:03 2015GEN0 started with pid=4, OS id=30705 Mon Jun 22 17:46:03 2015DIAG started with pid=5, OS id=30707 Mon Jun 22 17:46:03 2015DBRM started with pid=6, OS id=30709 Mon Jun 22 17:46:03 2015PSP0 started with pid=7, OS id=30711 Mon Jun 22 17:46:03 2015DIA0 started with pid=8, OS id=30713 Mon Jun 22 17:46:03 2015MMAN started with pid=9, OS id=30715 Mon Jun 22 17:46:03 2015DBW0 started with pid=10, OS id=30717 Mon Jun 22 17:46:03 2015LGWR started with pid=11, OS id=30721 Mon Jun 22 17:46:03 2015CKPT started with pid=12, OS id=30723 Mon Jun 22 17:46:03 2015SMON started with pid=13, OS id=30725 Mon Jun 22 17:46:03 2015RECO started with pid=14, OS id=30727 Mon Jun 22 17:46:03 2015MMON started with pid=15, OS id=30729 starting up 1 dispatcher(s) for network address ‘(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))’…Mon Jun 22 17:46:03 2015MMNL started with pid=16, OS id=30731 starting up 1 shared server(s) …ORACLE_BASE from environment = /oracle/ora11gR2Mon Jun 22 17:46:04 2015ALTER DATABASE MOUNTSuccessful mount of redo thread 1, with mount id 2809595100Database mounted in Exclusive ModeLost write protection disabledCompleted: ALTER DATABASE MOUNTMon Jun 22 17:46:08 2015ALTER DATABASE OPENThread 1 opened at log sequence 1279 Current log# 1 seq# 1279 mem# 0: /oracle/ora11gR2/oradata/dcsopen/redo01.logSuccessful open of redo thread 1MTTR advisory is disabled because FAST_START_MTTR_TARGET is not setSMON: enabling cache recoverySuccessfully onlined Undo Tablespace 2.Verifying file header compatibility for 11g tablespace encryption..Verifying 11g file header compatibility for tablespace encryption completedSMON: enabling tx recoveryDatabase Characterset is ZHS16GBKNo Resource Manager plan activereplication_dependency_tracking turned off (no async multimaster replication found)Starting background process QMNCMon Jun 22 17:46:09 2015QMNC started with pid=20, OS id=30789 Completed: ALTER DATABASE OPENStarting background process CJQ0Mon Jun 22 17:46:11 2015CJQ0 started with pid=22, OS id=30806 Mon Jun 22 17:46:18 2015Shutting down instance (normal)Shutting down instance: further logons disabledStopping background process QMNCStopping background process CJQ0Stopping background process MMNLStopping background process MMONLicense high water mark = 5All dispatchers and shared servers shutdownALTER DATABASE CLOSE NORMALMon Jun 22 17:46:22 2015SMON: disabling tx recoverySMON: disabling cache recoveryMon Jun 22 17:46:22 2015Shutting down archive processesArchiving is disabledArchive process shutdown avoided: 0 activeThread 1 closed at log sequence 1279Successful close of redo thread 1Completed: ALTER DATABASE CLOSE NORMALALTER DATABASE DISMOUNTCompleted: ALTER DATABASE DISMOUNTARCH: Archival disabled due to shutdown: 1090Shutting down archive processesArchiving is disabledArchive process shutdown avoided: 0 activeMon Jun 22 17:46:23 2015Stopping background process VKTM: ARCH: Archival disabled due to shutdown: 1090Shutting down archive processesArchiving is disabledArchive process shutdown avoided: 0 activeMon Jun 22 17:46:25 2015Instance shutdown complete

借鉴《Concept》,一些知识点:

1. 如果用户试图访问一个正在关闭的数据库,会得到错误提示:ORA-01090: shutdown in progress – connection is not permitted.

2. 关闭数据库,必须用SYSOPER或SYSDBA的角色。

3. 关闭数据库,是有超时时间的,如果用户未中断连接,或者交易未完成,超过一小时,则shutdown命令会取消,提示错误:ORA-01013: user requested cancel of current operation.

4. 几种关闭库的参数,

shutdown normal:

默认的关闭参数,需要两个条件:

(1) 执行语句后,不允许新的连接。

(2) 数据库关闭之前,数据库会等待所有已连接用户中断连接。

下一次启动时不需要实例恢复。

shutdown immediate:

使用场景:

(1) 初始化一个自动,无人值守的备份。

(2) 马上就要断电。

(3) 数据库或应用工作不正常,你不能马上联系到用户退出登录或他们无法退出登录。

条件:

(1) 不允许新的连接,不允许新的交易。

(2) 任何未提交的事务会回滚(如果此时有个长交易,未提交,那么不会像这种关闭名称immediate那样迅速地关闭)。

(3) 不会等待已连接用户退出登录。数据库会隐式回滚活动事务,,中断连接用户。

下一次启动时不需要实例恢复。

shutdown transactional:

适用于计划停机,允许活动交易处理完成后再停止实例的场景。

条件:

(1) 不允许新的连接,不允许新的交易。

(2) 所有交易完成后,会中断所有和库的连接。

(3) 在这个时间点,关闭实例就像执行了shutdown immediate。

下一次启动时不需要实例恢复。

transactional参数主要会防止用户丢失交易,同时不需要所有用户退出登录。

shutdown abort:

适用场景:

数据库或应用不能正常工作,并且没有其它类型的关闭操作正在进行。

(1) 需要立即关闭数据库(例如,一分钟后电源会被关闭)。

(2) 启动实例时碰到了问题。

条件:

(1) 不允许新的连接,不允许新的交易。

(2) 正在被Oracle处理的客户端SQL语句会被立即中断。

(3) 未提交事务不会回滚。

(4) Oracle不会等待正保持连接的客户端退出登录。数据库会隐式地中断所有连接。

下一次启动时需要进行实例恢复。

总结:

妩媚动人,让我感受到了大自然的神奇。

normal数据库关闭hang的问题

相关文章:

你感兴趣的文章:

标签云: