您的位置:首页 > 其它

ORA-01102: cannot mount database in EXCLUSIVE mode 处理方法

2017-01-25 02:56 453 查看

报错现象:

数据库报出 ORA-01102 错误,无法 mount

[oracle@edbjr2p2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 25 02:38:03 2017

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

Connected to an idle instance.

 SYS @ PROD4 >startup

ORACLE instance started.

Total System Global Area  941600768 bytes

Fixed Size                  1348860 bytes

Variable Size             549456644 bytes

Database Buffers          385875968 bytes

Redo Buffers                4919296 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode

 SYS @ PROD4 >alter database mount;

alter database mount

*

ERROR at line 1:

ORA-01102: cannot mount database in EXCLUSIVE mode

查看日志:

大概意思为文件被占用,无法锁定(最后发现报错关系到一个文件和一个进程,就是日志里标出的两行)

[oracle@edbjr2p2 ~]$ tail -10 /u01/app/oracle/diag/rdbms/prod4/PROD4/trace/alert_PROD4.log



Wed Jan 25 03:07:39 2017

MMNL started with pid=16, OS id=20451

starting up 1 shared server(s) ...

ORACLE_BASE from environment = /u01/app/oracle

Wed Jan 25 03:07:39 2017

ALTER DATABASE   MOUNT
sculkget: failed to lock /u01/app/oracle/product/11.2.0/db_1/dbs/lkPROD4 exclusive

sculkget: lock held by PID: 17127

ORA-09968: unable to lock file

Linux Error: 11: Resource temporarily unavailable

Additional information: 17127

ORA-1102 signalled during: ALTER DATABASE   MOUNT...

查报错原因:

通过访问多个技术大牛的博客找到问题原因和解决方法,以下Metalink的内容就摘自他们博客,里边描述了的问题原因和解决方法。其中下文第3条我觉得如果主机有多个实例并且都属于Oracle用户的话可能不可以直接这么操做(适合单实例环境),不排除我的理解有偏差,如果主机有多个实例请先验证!:

Metalink 原文如下:

analysis:

Problem Description:

====================  

You are trying to startup the database and you receive the following error: 

     ORA-01102:  cannot mount database in EXCLUSIVE mode

       Cause:  Some other instance has the database mounted exclusive 

               or shared.

      Action: Shutdown other instance or mount in a compatible mode.

    Problem Explanation:

====================  

A database is started in EXCLUSIVE mode by default.  Therefore, the 

ORA-01102 error is misleading and may have occurred due to one of the 

following reasons:  

  - there is still an "sgadef.dbf" file in the "ORACLE_HOME/dbs"

    directory 

  - the processes for Oracle (pmon, smon, lgwr and dbwr) still exist

  - shared memory segments and semaphores still exist even though the 

    database has been shutdown

  - there is a "ORACLE_HOME/dbs/lk" file

   Search Words:

=============  

ORA-1102, crash, immediate, abort, fail, fails, migration

Solution Description:

=====================  

Verify that the database was shutdown cleanly by doing the following:

  1. Verify that there is not a "sgadef.dbf" file in the directory

   "ORACLE_HOME/dbs".    

        % ls $ORACLE_HOME/dbs/sgadef.dbf

     If this file does exist, remove it.  

        % rm $ORACLE_HOME/dbs/sgadef.dbf  

2. Verify that there are no background processes owned by "oracle" 

          % ps -ef | grep ora_ | grep $ORACLE_SID

     If background processes exist, remove them by using the Unix 

   command "kill".  For example:

          % kill -9

  3. Verify that no shared memory segments and semaphores that are owned 

   by "oracle" still exist

          % ipcs -b

     If there are shared memory segments and semaphores owned by "oracle",

   remove the shared memory segments 

          % ipcrm -m

     and remove the semaphores 

          % ipcrm -s

     NOTE:  The example shown above assumes that you only have one 

          database on this machine.  If you have more than one

          database, you will need to shutdown all other databases

          before proceeding with Step 4.

  4. Verify that the "$ORACLE_HOME/dbs/lk" file does not exist

  5. Startup the instance

    Solution Explanation:

=====================  

The "lk" and "sgadef.dbf" files are used for locking shared memory.  It seems that even though no memory is allocated, Oracle thinks memory is  still locked.  By removing the "sgadef" and "lk" files you remove any knowledge oracle has of shared memory that
is in use. Now the database can start.

解决步骤:

先查看dbs目录下文件情况:

发现有lkPROD4 文件(其中PROD4为我的实例名,上文内容所描述为要删除 lk{$ORACLE_SID} ,也就是lk+实例名的文件)

[oracle@edbjr2p2 ~]$ cd $ORACLE_HOME/dbs

[oracle@edbjr2p2 dbs]$ ll

-rw-r----- 1 oracle oinstall    24 Oct 14  2014 lkEMREP

-rw-r----- 1 oracle oinstall    24 Oct 14  2014 lkPROD4

[oracle@edbjr2p2 dbs]$ rm lkPROD4                                                   #删除lkPROD4 文件

 SYS @ PROD4 >startup mount                                                            #尝试打开数据库

ORACLE instance started.

Total System Global Area  941600768 bytes

Fixed Size                  1348860 bytes

Variable Size             549456644 bytes

Database Buffers          385875968 bytes

Redo Buffers                4919296 bytes
ORA-00205: error in identifying control file, check alert log for more info            #此时报出了另一个错误,先别着急,咱照上文内容

一步步排查    ,先关闭                 

SYS @ PROD4 >shu immediate

ORA-01507: database not mounted
ORACLE instance shut down.

[oracle@edbjr2p2 ~]$
ps -ef |grep ora_ |grep PROD4

oracle   17109     1  0 Jan24 ?        00:00:00 ora_pmon_PROD4

oracle   17111     1  0 Jan24 ?        00:00:00 ora_psp0_PROD4

oracle   17113     1  0 Jan24 ?        00:00:18 ora_vktm_PROD4

oracle   17117     1  0 Jan24 ?        00:00:00 ora_gen0_PROD4

oracle   17119     1  0 Jan24 ?        00:00:00 ora_diag_PROD4

oracle   17121     1  0 Jan24 ?        00:00:00 ora_dbrm_PROD4

oracle   17123     1  0 Jan24 ?        00:00:04 ora_dia0_PROD4

oracle   17125     1  0 Jan24 ?        00:00:10 ora_mman_PROD4
oracle   17127     1  0 Jan24 ?        00:00:01 ora_dbw0_PROD4

oracle   17129     1  0 Jan24 ?        00:00:00 ora_lgwr_PROD4

oracle   17131     1  0 Jan24 ?        00:00:04 ora_ckpt_PROD4

oracle   17133     1  0 Jan24 ?        00:00:01 ora_smon_PROD4

oracle   17135     1  0 Jan24 ?        00:00:00 ora_reco_PROD4

oracle   17137     1  0 Jan24 ?        00:00:02 ora_mmon_PROD4

oracle   17139     1  0 Jan24 ?        00:00:04 ora_mmnl_PROD4

oracle   17141     1  0 Jan24 ?        00:00:00 ora_d000_PROD4

oracle   17143     1  0 Jan24 ?        00:00:00 ora_s000_PROD4

oracle   17244     1  0 Jan24 ?        00:00:00 ora_qmnc_PROD4

oracle   17298     1  0 Jan24 ?        00:00:00 ora_q001_PROD4

oracle   17330     1  0 Jan24 ?        00:00:01 ora_cjq0_PROD4

oracle   17383     1  0 Jan24 ?        00:00:00 ora_smco_PROD4

oracle   17743     1  0 Jan24 ?        00:00:00 ora_q002_PROD4

oracle   20934     1  0 03:43 ?        00:00:00 ora_w000_PROD4

这一步看见里一个进程,其进程号和数据库日志中记录的PID是相同的,因此判断此进程有占用。杀掉该进程:

[oracle@edbjr2p2 ~]$ kill -9 17127

再次尝试启动数据库:

 SYS @ PROD4 >startup mount

ORACLE instance started.

Total System Global Area  941600768 bytes

Fixed Size                  1348860 bytes

Variable Size             549456644 bytes

Database Buffers          385875968 bytes

Redo Buffers                4919296 bytes

Database mounted.

 SYS @ PROD4 >alter database open ;

Database altered.

 SYS @ PROD4 >

至此数据库已正常打开。问题的关键如文中Metalink内容描述,一下为主要参考的两个博文,较详细解释的报错原因和解决方法,供大家扩展学习。

参考博客链接 :http://www.cnblogs.com/kerrycode/p/3656655.html

参考博客链接2:http://blog.csdn.net/lzwgood/article/details/26368323
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: