今天靜默安裝完oracle11gr2版本後,連入數據庫後,出現以下狀況:sql
[oracle@oracle response]$ sqlplus / as sysdba數據庫
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 29 09:04:40 2017oracle
Copyright (c) 1982, 2009, Oracle. All rights reserved.app
Connected to an idle instance. ide
SQL> shutdown immediate;ui
ORA-01034: ORACLE not availablespa
ORA-27101: shared memory realm does not existorm
Linux-x86_64 Error: 2: No such file or directory內存
SQL> alter system register;it
alter system register
*
ERROR at line 1:
ORA-01034: ORACLE not available
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
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
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
嘗試正常關閉數據庫:
SQL> shutdown immediate;
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
[oracle@oracle dbs]$ fuser -u lkORCL
而後:
SQL> startup mount;
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
Database mounted.
在進行歸檔時發現:
SQL> alter database archivelog;
alter database archivelog
*
ERROR at line 1:
ORA-00265: instance recovery required, cannot set ARCHIVELOG mode
繼續查資料,發現須要先將數據庫起到open狀態:
SQL> alter dababase open;
alter dababase open
*
ERROR at line 1:
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;
Database altered.
而後對數據庫進行重啓,問題解決。
靜默安裝了不少次,頭一次出現安裝好就沒法登錄數據庫的問題,折騰到半夜兩點,仍是度參數不熟悉,繼續努力吧!