案例背景:一套跑在Windows 2K3 SP1 32位系统下的Oracle 10g 10.2.0.2.0的单实例数据库,数据库软件和数据库文件都放在D盘。遭遇到该服务器主板故障之后,更换主板,重新安装Windows 2K3 SP1 32位操作系统。成功配置好Windows操作系统之后,下面简单记录一下这个案例的恢复过程。
1 将之前的数据库安装目录重命名,将D:\oracle 重命名为D:\oracle_old;
2 重新安装Oracle软件,不建库,数据库版本同之前的版本一致,并且将安装目录指向D:\oracle;
3 再次将新安装的D:\oracle重命名为D:\oracle_new,重命名第1步骤中的D:\oracle_old为D:\oracle:
4 重新配置监听,设置ORACLE_SID环境变量,环境变量同之前的ORACLE_SID=cssdb,创建Oracle数据库服务:
C:\Documents and Settings\huangw>set oracle_sid=cssdb C:\Documents and Settings\huangw>oradim ORADIM:[options]. Refer to manual. Enter one of the following command: Create an instance by specifying the following options: -NEW -SID sid | -SRVC srvc | -ASMSID sid | -ASMSRVC srvc [-SYSPWD pass] [-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE] [-SHUTMODE normal|immediate|abort] [-TIMEOUT secs] [-RUNAS osusr/ospass] Edit an instance by specifying the following options: -EDIT -SID sid | -ASMSID sid [-SYSPWD pass] [-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE] [-SHUTMODE normal|immediate|abort] [-SHUTTYPE srvc|inst] [-RUNAS osusr/ospass] Delete instances by specifying the following options: -DELETE -SID sid | -ASMSID sid | -SRVC srvc | -ASMSRVC srvc Startup services and instance by specifying the following options: -STARTUP -SID sid | -ASMSID sid [-SYSPWD pass] [-STARTTYPE srvc|inst|srvc,inst] [-PFILE filename | -SPFILE] Shutdown service and instance by specifying the following options: -SHUTDOWN -SID sid | -ASMSID sid [-SYSPWD pass] [-SHUTTYPE srvc|inst|srvc,inst] [-SHUTMODE normal|immediate|abort] Query for help by specifying the following parameters: -? | -h | -help C:\Documents and Settings\huangw>oradim -new -sid cssdb Instance created. C:\Documents and Settings\huangw>
5 调用SQL*PLUS,发现权限不足的错误,重建口令文件,执行口令文件验证登录:
C:\Documents and Settings\huangw>oradim -new -sid cssdb Instance created. C:\Documents and Settings\huangw>sqlplus /nolog SQL*Plus: Release 10.2.0.2.0 - Production on Mon Nov 19 18:21:39 2012 Copyright (c) 1982, 2005, Oracle. All Rights Reserved. SQL> conn / as sysdba ERROR: ORA-01031: insufficient privileges SQL> exit C:\Documents and Settings\huangw> C:\Documents and Settings\huangw>orapwd file=PWDCSSDB.ora password=dehamdb entri es=10 C:\Documents and Settings\huangw>sqlplus /nolog SQL*Plus: Release 10.2.0.2.0 - Production on Mon Nov 19 18:23:49 2012 Copyright (c) 1982, 2005, Oracle. All Rights Reserved. SQL> conn / as sysdba ERROR: ORA-01031: insufficient privileges SQL> conn sys/dehamdb as sysdba Connected to an idle instance. SQL>
6 直接启库,完成。
小结:该案例的幸运之处在于Oracle软件和数据库文件都在D盘,Windows系统崩溃之后,只是影响到C盘下的数据和文件,好在对D盘下的文件没有破坏。其实重命名D:\oracle文件,以及重新安装oracle数据库软件的目的无非就是重新将Oracle软件的注册信息,环境变量等信息重新写到Windows系统和注册表中而已。
最后,在系统的环境变量中重新添加ORACLE_SID和在系统服务项中将OracleServiceCSSDB服务配置为自动启动。