在没有控制文件备份的情况下,重新创建控制文件也是其中一个选择。本文旨在帮助初学者学习之用,谢谢!!
如何恢复一个只有完好数据文件的数据库?
本文欲将此数据文件恢复成数据库TTI,实例名TTI
$Oracle_HOME=d:oracleora92
1、创建相关目录
d:oracleoradatatti --拷贝数据文件到此目录下,假如没有redolog文件,需要手工创建
d:oracleadminttibdumpd:oracleadmintticdumpd:oracleadmintticreated:oracleadminttipfiled:oracleadminttiudump2、创建初始化文件(本例的初始化文件D:oracleadminttipfileinit.ora)
可拷贝现有数据库的初始化文件进行修改,主要修改内容如下:
db_name=ttibackground_dump_dest=D:oracleadminttibdumpcore_dump_dest=D:oracleadmintticdumptimed_statistics=TRUEuser_dump_dest=D:oracleadminttiudumpcontrol_files=("D:oracleoradatattiCONTROL01.CTL", "D:oracleoradatattiCONTROL02.CTL", "D:oracleoradatattiCONTROL03.CTL")instance_name=ttidispatchers="(PROTOCOL=TCP) (SERVICE=ttiXDB)"
3、创建实例及密码文件
开始-〉执行-〉cmdD:>oradim.exe -new -sid tti -startmode mD:>orapwd.exe file=d:oracleora92databasePWDtti.ora passWord=zlw0014、添加监听和连接
1)在d:oracleora92networkadminlistener.ora中的SID_LIST_LISTENER下面添加如下内容:
(SID_DESC =(GLOBAL_DBNAME = tti)(ORACLE_HOME = D:oracleora92)(SID_NAME = tti))2)在d:oracleora92networkadmintnsnames.ora中添加如下内容:
(这里注重:假如你的d:oracleora92networkadminsqlnet.ora中的参数
NAMES.DEFAULT_DOMAIN = ###,则你的tnsnames.ora中下面的title那里也要改为tti.###)
tti = #title(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = MIS011)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = tti)))
5、开始重建控制文件
1)在类似的数据库(比如数据库名称"rman")上执行:
alter database backup controlfile to trace;
然后在D:oracleadminrmanudump下找到最新的trace文件,以文本方式打开,找到类似下面的一段话:
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "rman" NORESETLOGS ARCHIVELOG-- SET STANDBY TO MAXIMIZE PERFORMANCEMAXLOGFILES 50MAXLOGMEMBERS 5MAXDATAFILES 100MAXINSTANCES 1MAXLOGHISTORY 226LOGFILEGROUP 1 'D:ORACLEORADATARMANREDO01.LOG' SIZE 100M,GROUP 2 'D:ORACLEORADATARMANREDO02.LOG' SIZE 100M,GROUP 3 'D:ORACLEORADATARMANREDO03.LOG' SIZE 100M-- STANDBY LOGFILEDATAFILE'D:ORACLEORADATARMANSYSTEM01.DBF','D:ORACLEORADATARMANUNDOTBS01.DBF','D:ORACLEORADATARMANCWMLITE01.DBF','D:ORACLEORADATARMANDRSYS01.DBF','D:ORACLEORADATARMANEXAMPLE01.DBF','D:ORACLEORADATARMANINDX01.DBF','D:ORACLEORADATARMANODM01.DBF','D:ORACLEORADATARMANTOOLS01.DBF','D:ORACLEORADATARMANUSERS01.DBF','D:ORACLEORADATARMANXDB01.DBF','D:ORACLEORADATARMANTEST.ORA'CHARACTER SET WE8MSWIN1252
2)将上面这段话修改为如下:
STARTUP NOMOUNTCREATE CONTROLFILE set DATABASE "tti" RESETLOGS --注重这里要"set"-- SET STANDBY TO MAXIMIZE PERFORMANCEMAXLOGFILES 50MAXLOGMEMBERS 5MAXDATAFILES 100MAXINSTANCES 1MAXLOGHISTORY 226LOGFILEGROUP 1 'D:ORACLEORADATAttiREDO01.LOG' SIZE 100M,GROUP 2 'D:ORACLEORADATAttiREDO02.LOG' SIZE 100M,GROUP 3 'D:ORACLEORADATAttiREDO03.LOG' SIZE 100M-- STANDBY LOGFILEDATAFILE'D:ORACLEORADATAttiSYSTEM01.DBF','D:ORACLEORADATAttiUNDOTBS01.DBF','D:ORACLEORADATAttiCWMLITE01.DBF','D:ORACLEORADATAttiDRSYS01.DBF','D:ORACLEORADATAttiEXAMPLE01.DBF','D:ORACLEORADATAttiINDX01.DBF','D:ORACLEORADATAttiODM01.DBF','D:ORACLEORADATAttiTOOLS01.DBF','D:ORACLEORADATAttiUSERS01.DBF','D:ORACLEORADATAttiXDB01.DBF','D:ORACLEORADATAttiTEST.ORA'CHARACTER SET WE8MSWIN1252
3)开始重建控制文件
D:>sqlplus/nolog
SQL*Plus: Release 9.2.0.1.0 - ProdUCtion on Thu Nov 16 09:08:19 2006Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.SQL> conn sys/zlw001@tti as sysdba;Connected to an idle instance.SQL> startup nomount pfile=d:oracleadminttipfileinit.ora;ORACLE instance started.Total System Global Area 135338868 bytesFixed Size 453492 bytesVariable Size 109051904 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesSQL> CREATE CONTROLFILE set DATABASE "tti" RESETLOGS2 -- SET STANDBY TO MAXIMIZE PERFORMANCE3 MAXLOGFILES 504 MAXLOGMEMBERS 55 MAXDATAFILES 1006 MAXINSTANCES 17 MAXLOGHISTORY 2268 LOGFILE9 GROUP 1 'D:ORACLEORADATAttiREDO01.LOG' SIZE 100M,10 GROUP 2 'D:ORACLEORADATAttiREDO02.LOG' SIZE 100M,11 GROUP 3 'D:ORACLEORADATAttiREDO03.LOG' SIZE 100M12 -- STANDBY LOGFILE13 DATAFILE14 'D:ORACLEORADATAttiSYSTEM01.DBF',15 'D:ORACLEORADATAttiUNDOTBS01.DBF',16 'D:ORACLEORADATAttiCWMLITE01.DBF',17 'D:ORACLEORADATAttiDRSYS01.DBF',18 'D:ORACLEORADATAttiEXAMPLE01.DBF',19 'D:ORACLEORADATAttiINDX01.DBF',20 'D:ORACLEORADATAttiODM01.DBF',21 'D:ORACLEORADATAttiTOOLS01.DBF',22 'D:ORACLEORADATAttiUSERS01.DBF',23 'D:ORACLEORADATAttiXDB01.DBF',24 'D:ORACLEORADATAttiTEST.ORA'25 CHARACTER SET WE8MSWIN1252;Control file created.SQL> alter database open resetlogs;Database altered.SQL> select instance_name,status from v$instance;INSTANCE_NAME STATUS---------------- ------------tti OPENSQL> select ts#,name from v$datafile;file# NAME--------- --------------------------------------------1 D:ORACLEORADATATTISYSTEM01.DBF2 D:ORACLEORADATATTIUNDOTBS01.DBF3 D:ORACLEORADATATTICWMLITE01.DBF4 D:ORACLEORADATATTIDRSYS01.DBF5 D:ORACLEORADATATTIEXAMPLE01.DBF6 D:ORACLEORADATATTIINDX01.DBF7 D:ORACLEORADATATTIODM01.DBF8 D:ORACLEORADATATTITOOLS01.DBF9 D:ORACLEORADATATTIUSERS01.DBF10 D:ORACLEORADATATTIXDB01.DBF11 D:ORACLEORADATATTITEST.ORA11 rows selected.SQL>
至此全部结束!