在ORACLE 11g 数据库静默安装完成后,启动数据库时报错了
[oracle@localhost app]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 2 09:36:50 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn sys/oracle as sysdba
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/dbs/initorcl.ora'
SQL> exit
在oracle 11g中,数据库默认将使用spfile启动数据库,如果spfile不存在,则就会出现上述错误。
-- 进入dbs目录
[oracle@localhost dbs]$ pwd
/u01/app/oracle/dbs
[oracle@localhost dbs]$ ls
hc_orcl11g.dat init.ora lkORCL orapworcl11g spfileorcl11g.ora
发现没有 initorcl.ora(orcl为我的oracle_sid), 于是将 /u01/app/admin/orcl/pfile/init.ora.12201591938 复制到 /u01/app/oracle/dbs/initorcl.ora
[oracle@localhost dbs]$ cp init.ora.12201591938 /u01/app/oracle/dbs/initorcl.ora
再次重启数据库
[oracle@localhost dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 2 10:02:01 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2230072 bytes
Variable Size 163580104 bytes
Database Buffers 360710144 bytes
Redo Buffers 7942144 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode
又报“不能挂载数据库中独占模式”了这个错误 ORA-01102: cannot mount database in EXCLUSIVE mode ,于是关掉数据 shutdown immediate,
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> exit
<pre name="code" class="sql">
网上搜索了一下相关的文章,下面是网址http://www.itpub.net/thread-1573387-1-1.html 的具体解决方案<span style="font-family: Arial, Helvetica, sans-serif;">ORA-01102 cannot mount database in EXCLUSIVE mode</span>
出现1102错误可能有以下几种可能:
一、在HA系统中,已经有其他节点启动了实例,将双机共享的资源(如磁盘阵列上的裸设备)占用了;
二、说明 oracle 被异常关闭时,有资源没有被释放,一般有以下几种可能,
1、 oracle 的共享内存段或信号量没有被释放;
2、 oracle 的后台进程(如SMON、PMON、DBWn等)没有被关闭;
3、 用于锁内存的文件lk<sid>和sgadef<sid>.dbf文件没有被删除。
首先,虽然我们的系统是HA系统,但是备节点的实例始终处在关闭状态,这点通过在备节点上查数据库状态可以证实。
其次、是因系统掉电引起数据库宕机的,系统在接电后被重启,因此我们排除了第二种可能种的1、2点。最可疑的就是第3点了。
查$ORACLE_HOME/dbs目录:
$ cd $ORACLE_HOME/dbs
$ ls sgadef*
sgadef* not found
$ ls lk*
lkORA92
果然,lk<sid>文件没有被删除。将它删除掉
$ rm lk*
再启动数据库,成功。
如果怀疑是共享内存没有被释放,可以用以下命令查看:
$ipcs -mop
IPC status from /dev/kmem as of Thu Jul 6 14:41:43 2006
T ID KEY MODE OWNER GROUP NATTCH CPID LPID
Shared Memory:
m 0 0×411c29d6 –rw-rw-rw- root root 0 899 899
m 1 0×4e0c0002 –rw-rw-rw- root root 2 899 901
m 2 0×4120007a –rw-rw-rw- root root 2 899 901
m 458755 0×0c6629c9 –rw-r—– root sys 2 9113 17065
m 4 0×06347849 –rw-rw-rw- root root 1 1661 9150
m 65541 0xffffffff –rw-r–r– root root 0 1659 1659
m 524294 0×5e100011 –rw——- root root 1 1811 1811
m 851975 0×5fe48aa4 –rw-r—– oracle oinstall 66 2017 25076
然后它ID号清除共享内存段:
$ipcrm –m 851975
对于信号量,可以用以下命令查看:
$ ipcs -sop
IPC status from /dev/kmem as of Thu Jul 6 14:44:16 2006
T ID KEY MODE OWNER GROUP
Semaphores:
s 0 0×4f1c0139 –ra——- root root
… …
s 14 0×6c200ad8 –ra-ra-ra- root root
s 15 0×6d200ad8 –ra-ra-ra- root root
s 16 0×6f200ad8 –ra-ra-ra- root root
s 17 0xffffffff –ra-r–r– root root
s 18 0×410c05c7 –ra-ra-ra- root root
s 19 0×00446f6e –ra-r–r– root root
s 20 0×00446f6d –ra-r–r– root root
s 21 0×00000001 –ra-ra-ra- root root
s 45078 0×67e72b58 –ra-r—– oracle oinstall
根据信号量ID,用以下命令清除信号量:
$ipcrm -s 45078
如果是 oracle 进程没有关闭,用以下命令查出存在的 oracle 进程:
$ ps -ef|grep ora
oracle 29976 1 0 Jun 22 ? 0:52 ora_dbw0_ora92
oracle 29978 1 0 Jun 22 ? 0:51 ora_dbw1_ora92
oracle 5128 1 0 Jul 5 ? 0:00 oracleora92 (LOCAL=NO)
… …
然后用kill -9命令杀掉进程
$kill -9 <PID>
总结:
当发生1102错误时,可以按照以下流程检查、排错:
1.如果是HA系统,检查其他节点是否已经启动实例;
2.检查 oracle 进程是否存在,如果存在则杀掉进程;
3.检查信号量是否存在,如果存在,则清除信号量;
4.检查共享内存段是否存在,如果存在,则清除共享内存段;
5.检查锁内存文件lk<sid>和sgadef<sid>.dbf是否存在,如果存在,则删除。
根据上面的解决方案,查看了一下本机的相关的oracle进程
<pre name="code" class="html">[root@localhost response]# ps -ef|grep ora
root 1770 1734 0 2014 ? 01:10:39 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root 2504 15374 0 09:00 ? 00:00:00 sshd: oracle [priv]
oracle 2508 2504 0 09:00 ? 00:00:00 sshd: oracle@notty
oracle 2509 2508 0 09:00 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 2634 15374 0 09:07 ? 00:00:00 sshd: oracle [priv]
oracle 2638 2634 0 09:07 ? 00:00:00 sshd: oracle@notty
oracle 2639 2638 0 09:07 ? 00:00:00 /usr/libexec/openssh/sftp-server
oracle 3167 1 0 09:20 ? 00:00:00 ora_pmon_orcl11g
oracle 3169 1 0 09:20 ? 00:00:00 ora_psp0_orcl11g
oracle 3171 1 0 09:20 ? 00:00:31 ora_vktm_orcl11g
oracle 3175 1 0 09:20 ? 00:00:00 ora_gen0_orcl11g
oracle 3177 1 0 09:20 ? 00:00:00 ora_diag_orcl11g
oracle 3179 1 0 09:20 ? 00:00:00 ora_dbrm_orcl11g
oracle 3181 1 0 09:20 ? 00:00:02 ora_dia0_orcl11g
oracle 3183 1 0 09:20 ? 00:00:00 ora_mman_orcl11g
oracle 3185 1 0 09:20 ? 00:00:00 ora_dbw0_orcl11g
oracle 3187 1 0 09:20 ? 00:00:00 ora_lgwr_orcl11g
oracle 3189 1 0 09:20 ? 00:00:00 ora_ckpt_orcl11g
oracle 3191 1 0 09:20 ? 00:00:01 ora_smon_orcl11g
oracle 3193 1 0 09:20 ? 00:00:00 ora_reco_orcl11g
oracle 3195 1 0 09:20 ? 00:00:01 ora_mmon_orcl11g
oracle 3197 1 0 09:20 ? 00:00:01 ora_mmnl_orcl11g
oracle 3199 1 0 09:20 ? 00:00:00 ora_d000_orcl11g
oracle 3201 1 0 09:20 ? 00:00:00 ora_s000_orcl11g
oracle 3209 1 0 09:20 ? 00:00:00 ora_qmnc_orcl11g
oracle 3224 1 0 09:20 ? 00:00:01 ora_cjq0_orcl11g
oracle 3226 1 0 09:20 ? 00:00:00 ora_q000_orcl11g
oracle 3228 1 0 09:20 ? 00:00:00 ora_q001_orcl11g
oracle 3408 1 0 09:30 ? 00:00:00 ora_smco_orcl11g
oracle 3984 1 0 09:50 ? 00:00:00 ora_w000_orcl11g
oracle 4303 1 0 10:05 ? 00:00:00 ora_w003_orcl11g
oracle 4481 1 0 10:16 ? 00:00:00 ora_j000_orcl11g
oracle 4483 1 0 10:16 ? 00:00:00 ora_j001_orcl11g
root 4485 19827 0 10:16 pts/0 00:00:00 grep ora
root 18929 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 18933 18929 0 Feb01 ? 00:00:01 sshd: oracle@pts/0
oracle 18934 18933 0 Feb01 pts/0 00:00:00 -bash
root 21126 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 21130 21126 0 Feb01 ? 00:00:00 sshd: oracle@pts/1
oracle 21131 21130 0 Feb01 pts/1 00:00:00 -bash
root 21445 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 21449 21445 0 Feb01 ? 00:01:33 sshd: oracle@pts/2
oracle 21450 21449 0 Feb01 pts/2 00:00:00 -bash
oracle 26054 1 0 Feb01 ? 00:00:03 /u01/app/oracle/bin/tnslsnr LISTENER -inherit
数据库关闭了,竟然后台进程都还在,先关闭后台进程,再查看相关的信息
<pre name="code" class="html">-- 这里直接关掉系统监控进程,其他的后台进程就没了
[root@localhost response]# kill -9 3191
[root@localhost response]#
[root@localhost response]# ps -ef|grep ora
root 1770 1734 0 2014 ? 01:10:39 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root 2504 15374 0 09:00 ? 00:00:00 sshd: oracle [priv]
oracle 2508 2504 0 09:00 ? 00:00:00 sshd: oracle@notty
oracle 2509 2508 0 09:00 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 2634 15374 0 09:07 ? 00:00:00 sshd: oracle [priv]
oracle 2638 2634 0 09:07 ? 00:00:00 sshd: oracle@notty
oracle 2639 2638 0 09:07 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 4527 19827 0 10:20 pts/0 00:00:00 grep ora
root 18929 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 18933 18929 0 Feb01 ? 00:00:01 sshd: oracle@pts/0
oracle 18934 18933 0 Feb01 pts/0 00:00:00 -bash
root 21126 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 21130 21126 0 Feb01 ? 00:00:00 sshd: oracle@pts/1
oracle 21131 21130 0 Feb01 pts/1 00:00:00 -bash
root 21445 15374 0 Feb01 ? 00:00:00 sshd: oracle [priv]
oracle 21449 21445 0 Feb01 ? 00:01:33 sshd: oracle@pts/2
oracle 21450 21449 0 Feb01 pts/2 00:00:00 -bash
oracle 26054 1 0 Feb01 ? 00:00:03 /u01/app/oracle/bin/tnslsnr LISTENER -inherit
按照上面的说法,就是还有一个文件 /u01/app/oracle/dbs/lkORCL ,将该文件删掉,于是再次启动数据
<span style="font-family:Arial, Helvetica, sans-serif;"></span><pre name="code" class="sql">[oracle@localhost dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 2 10:26:46 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2230072 bytes
Variable Size 163580104 bytes
Database Buffers 360710144 bytes
Redo Buffers 7942144 bytes
Database mounted.
Database opened.
SQL> show parameter instance
OK数据库启动成功
附: 关于 $ORACLE_HOME/dbs目录下面的文件的作用,在网上找到一个图片