天天看點

oracle安裝完無法登陸資料庫

今天靜默安裝完oracle11gr2版本後,連入資料庫後,出現如下情況:

[oracle@oracle response]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 29 09:04:40 2017

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

Connected to an idle instance.                                                  

SQL> shutdown immediate;

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux-x86_64 Error: 2: No such file or directory

SQL> alter system register;

alter system register

*

ERROR at line 1:

Process ID: 0

Session ID: 0 Serial number: 0

于是上網查了一下資料,排除了記憶體不足問題,說是資料庫沒有打開,然後嘗試重新打開,結果還是報錯。如下:

SQL> startup mount;

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora'

根據提示查找initORCL.ora檔案,發現沒有。于是将$ORACLE_BASE/admin/orcl/pfile目錄下的init.ora.***形式的檔案copy到$ORACLE_HOME/dbs目錄下重命名為initORCL.ora即可。(注:initORCL.ora中的orcl為你的執行個體名 ORACLE_SID,這裡我的SID為:ORCL)

或者将$ORACLE_HOME/dbs目錄下spflieoracl.ora改名為spfileORCL.ora即可。(注:spfileORCL.ora中的ORCL為環境變量中設定的SID)

[oracle@oracle ~]$ cp /u01/app/oracle/admin/orcl/pfile/init.ora.82920179156 $ORACLE_HOME/dbs/initORCL.ora

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 29 11:58:27 2017

Connected to an idle instance.

ORACLE instance started.

Total System Global Area  626327552 bytes

Fixed Size                  2215944 bytes

Variable Size             184553464 bytes

Database Buffers          436207616 bytes

Redo Buffers                3350528 bytes

ORA-01102: cannot mount database in EXCLUSIVE mode

嘗試正常關閉資料庫:

ORA-01507: database not mounted

ORACLE instance shut down.

查了一下資料,發現是lk<SID>檔案造成的,該檔案位于ORALCE_HOME下的dbs目錄下,馬上檢查該檔案:

[oracle@oracle ~]$ ls $ORACLE_HOME/dbs

hc_DBUA0.dat  hc_ORCL.dat  initORCL.ora  orapworcl

hc_orcl.dat   init.ora     lkORCL        spfileorcl.ora

[oracle@oracle dbs]$ fuser -u lkORCL

lkORCL:               7621(oracle)  7627(oracle)  7631(oracle)  7633(oracle)  7637(oracle)  7639(oracle)  7641(oracle)  7643(oracle)  7645(oracle)  7647(oracle)  7649(oracle)  7651(oracle)  7663(oracle)  7680(oracle)  7682(oracle)  7684(oracle)  7692(oracle)  8272(oracle)

果然該檔案沒有釋放,用fuser指令kill掉:

[oracle@oracle dbs]$ fuser -k lkORCL

lkORCL:               7621  7627  7631  7633  7637  7639  7641  7643  7645  7647  7649  7651  7663  7680  7682  7684  7692  8272

然後:

Database mounted.

在進行歸檔時發現:

SQL> alter database archivelog;

alter database archivelog

ORA-00265: instance recovery required, cannot set ARCHIVELOG mode

繼續查資料,發現需要先将資料庫起到open狀态:

SQL> alter dababase open;

alter dababase open

      *

ORA-00940: invalid ALTER command

發現還是報錯,繼續查資料,找到一個datafile被offline的解決辦法。解決辦法。

shutdown immediate

startup mount

recover datafile 2

alter database datafile 2 online

alter datebase open

結果如下:

SQL> recover datafile 2;

Media recovery complete.

SQL> alter database datafile 2 online;

Database altered.

SQL> alter database open;

然後對資料庫進行重新開機,問題解決。

靜默安裝了很多次,頭一次出現安裝好就無法登陸資料庫的問題,折騰到半夜兩點,還是度參數不熟悉,繼續努力吧!