--0.两个场景都是运行在归档模式的数据库丢失一个数据文件,当前所有控制文件丢失。
--控制文件、数据文件、归档日志都有备份而且是齐全的。
--1.查看数据库当前的归档模式
sys@TESTDB11>archiveloglist;
DatabaselogmodeNoArchiveMode
Automatic archivalDisabled
Archive destinationUSE_DB_RECOVERY_FILE_DEST
Oldestonlinelogsequence123
Currentlogsequence125
--2.使数据库运行归档模式
--2.1关库
sys@TESTDB11>shutdownimmediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
--2.2启动到MOUNT状态
sys@TESTDB11>startup mount;
ORACLE instance started.
Total SystemGlobalArea855982080bytes
FixedSize2230792bytes
VariableSize641730040bytes
Database Buffers209715200bytes
Redo Buffers2306048bytes
Database mounted.
--2.3修改为归档模式
sys@TESTDB11>alterdatabase
archivelog;
Database altered.
--2.4开库
sys@TESTDB11>alterdatabaseopen;
Database altered.
--2.5查看当前的归档模式
sys@TESTDB11>archiveloglist;
DatabaselogmodeArchiveMode
Automatic archivalEnabled
Archive destinationUSE_DB_RECOVERY_FILE_DEST
Oldestonlinelogsequence123
Nextlogsequencetoarchive125
Currentlogsequence125
--3.对数据库做个备份
RMAN>backup database;
Starting backupat23-MAY-14
currentlogarchived
usingtarget database controlfileinsteadofrecoverycatalog
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=40devicetype=DISK
channel ORA_DISK_1:starting archivedlogbackupset
channel ORA_DISK_1:specifying archivedlog(s)inbackupset
inputarchivedlogthread=1sequence=125RECID=1STAMP=848316651
inputarchivedlogthread=1sequence=126RECID=2STAMP=848316921
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_annnn_TAG20140523T113522_9qyy6c86_.bkp tag=TAG20140523T113522comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:00:07
Finished backupat23-MAY-14
Starting backupat23-MAY-14
usingchannel ORA_DISK_1
channel ORA_DISK_1:starting full datafile backupset
channel ORA_DISK_1:specifying datafile(s)inbackupset
inputdatafilefilenumber=00001name=/u01/app/oracle/oradata/TestDB11/system01.dbf
inputdatafilefilenumber=00002name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf
inputdatafilefilenumber=00005name=/u01/app/oracle/oradata/TestDB11/example01.dbf
inputdatafilefilenumber=00003name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf
inputdatafilefilenumber=00004name=/u01/app/oracle/oradata/TestDB11/users01.dbf
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T113530_9qyy7bny_.bkp tag=TAG20140523T113530comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:05:16
channel ORA_DISK_1:starting full datafile backupset
channel ORA_DISK_1:specifying datafile(s)inbackupset
includingcurrentcontrolfileinbackupset
includingcurrentSPFILEinbackupset
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_ncsnf_TAG20140523T113530_9qyyjk9h_.bkp tag=TAG20140523T113530comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:00:01
Finished backupat23-MAY-14
Starting backupat23-MAY-14
currentlogarchived
usingchannel ORA_DISK_1
channel ORA_DISK_1:starting archivedlogbackupset
channel ORA_DISK_1:specifying archivedlog(s)inbackupset
inputarchivedlogthread=1sequence=127RECID=3STAMP=848317250
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_annnn_TAG20140523T114051_9qyyjm50_.bkp tag=TAG20140523T114051comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:00:01
Finished backupat23-MAY-14
--3.1查看上面的结果,确定控制文件并没有进行备份
--3.2查看当前的配置
RMAN>showall;
RMAN configurationparametersfordatabasewithdb_unique_name TESTDB11are:
CONFIGURE RETENTION POLICYTOREDUNDANCY1;#default
CONFIGURE BACKUP OPTIMIZATIONOFF;#default
CONFIGUREDEFAULTDEVICETYPETODISK;#default
CONFIGURE CONTROLFILE AUTOBACKUPOFF;#default
CONFIGURE CONTROLFILE AUTOBACKUPFORMATFORDEVICETYPEDISKTO'%F';#default
CONFIGURE DEVICETYPEDISK PARALLELISM1BACKUPTYPETOBACKUPSET;#default
CONFIGURE DATAFILE BACKUP COPIESFORDEVICETYPEDISKTO1;#default
CONFIGURE ARCHIVELOG BACKUP COPIESFORDEVICETYPEDISKTO1;#default
CONFIGURE MAXSETSIZETOUNLIMITED;#default
CONFIGURE ENCRYPTIONFORDATABASEOFF;#default
CONFIGURE ENCRYPTION ALGORITHM'AES128';#default
CONFIGURE COMPRESSION ALGORITHM'BASIC'ASOFRELEASE'DEFAULT'OPTIMIZEFORLOADTRUE;#default
CONFIGURE ARCHIVELOG DELETION POLICYTONONE;#default
CONFIGURE SNAPSHOT CONTROLFILE NAMETO'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_TestDB11.f';#default
--3.3配置控制文件自动备份
RMAN>configure controlfile autobackupon;
newRMAN configurationparameters:
CONFIGURE CONTROLFILE AUTOBACKUPON;
newRMAN configurationparametersaresuccessfully
stored
--3.3删除当前备份
RMAN>deletebackup;
--3.4再次进行备份
RMAN>backup database;
Starting backupat23-MAY-14
usingchannel ORA_DISK_1
channel ORA_DISK_1:starting full datafile backupset
channel ORA_DISK_1:specifying datafile(s)inbackupset
inputdatafilefilenumber=00001name=/u01/app/oracle/oradata/TestDB11/system01.dbf
inputdatafilefilenumber=00002name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf
inputdatafilefilenumber=00005name=/u01/app/oracle/oradata/TestDB11/example01.dbf
inputdatafilefilenumber=00003name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf
inputdatafilefilenumber=00004name=/u01/app/oracle/oradata/TestDB11/users01.dbf
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T114917_9qyz0fxc_.bkp tag=TAG20140523T114917comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:05:55
Finished backupat23-MAY-14
Starting ControlFileandSPFILE Autobackupat23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkpcomment=NONE
Finished ControlFileandSPFILE Autobackupat23-MAY-14
--此时可以自动自动备份的控制文件
--4模拟数据文件和所有控制文件丢失
--4.1删除/u01/app/oracle/oradata/TestDB11/users01.dbf数据文件
[oracle@S1011:/export/home/oracle]$ rm/u01/app/oracle/oradata/TestDB11/users01.dbf
--4.2查看所有控制文件
sys@TESTDB11>showparametercontrol_files
NAMETYPEVALUE
------------------------------------ -----------
------------------------------
control_filesstring/u01/app/oracle/oradata/TestDB
11/control01.ctl,/u01/app/ora
cle/fast_recovery_area/TestDB1
1/control02.ctl
--4.3删除所有控制文件
[oracle@S1011:/export/home/oracle]$ rm/u01/app/oracle/oradata/TestDB11/control01.ctl
[oracle@S1011:/export/home/oracle]$ rm/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl
--5执行一个查询操作,发现数据文件丢失
[oracle@S1011:/export/home/oracle]$ sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononFri May2313:40:402014
Copyright(c)1982,2011,Oracle.Allrights reserved.
Connectedto:
Oracle Database11g Enterprise EditionRelease11.2.0.3.0-64bitProduction
Withthe Partitioning,OLAP,DataMiningandRealApplication
Testing options
sys@TESTDB11>select*fromscott.emp;
select*fromscott.emp
*
ERRORatline1:
ORA-01116:errorinopening databasefile4
ORA-01110:datafile4:'/u01/app/oracle/oradata/TestDB11/users01.dbf'
ORA-27041:unabletoopenfile
Solaris-AMD64 Error:2:Nosuchfileordirectory
Additional information:3
--6.将数据文件脱机,准备进行还原和恢复. (结论:发现控制文件也丢失了)
sys@TESTDB11>alterdatabase
datafile4offline;
alterdatabase datafile4offline
*
ERRORatline1:
ORA-00210:cannotopenthe specified controlfile
ORA-00202:controlfile:'/u01/app/oracle/oradata/TestDB11/control01.ctl'
ORA-27041:unabletoopenfile
Solaris-AMD64 Error:2:Nosuchfileordirectory
Additional information:3
--7.关库
sys@TESTDB11>shutdownimmediate;
ORA-00210:cannotopenthe specified controlfile
ORA-00202:controlfile:'/u01/app/oracle/oradata/TestDB11/control01.ctl'
ORA-27041:unabletoopenfile
Solaris-AMD64 Error:2:Nosuchfileordirectory
Additional information:3
--7.2再次关库
sys@TESTDB11>shutdown abort;
ORACLE instance shut down.
--8.进行还原和恢复
--8.1启动rman
[oracle@S1011:/export/home/oracle]$ rman target/
Recovery Manager:Release11.2.0.3.0-ProductiononFri May2313:46:542014
Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.
connectedtotarget database(notstarted)
--8.2启库到NOMOUNT状态
RMAN>startup nomount;
Oracle instance started
Total SystemGlobalArea855982080bytes
FixedSize2230792bytes
VariableSize641730040bytes
Database Buffers209715200bytes
Redo Buffers2306048bytes
--8.3还原控制文件
RMAN>restore controlfilefromautobackup;
Starting restoreat23-MAY-14
usingtarget database controlfileinsteadofrecoverycatalog
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=19devicetype=DISK
recovery area destination:/u01/app/oracle/fast_recovery_area
database name(ordatabaseuniquename)usedforsearch:TESTDB11
channel ORA_DISK_1:AUTOBACKUP/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkpfoundinthe recovery area
AUTOBACKUPsearchwithformat"%F"notattempted because DBID wasnotset
channel ORA_DISK_1:restoring controlfilefromAUTOBACKUP/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkp
channel ORA_DISK_1:controlfilerestorefromAUTOBACKUP complete
outputfilename=/u01/app/oracle/oradata/TestDB11/control01.ctl
outputfilename=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl
Finished restoreat23-MAY-14
--8.4使数据库进入MOUNT状态
RMAN>alterdatabase mount;
--8.5还原数据文件4
RMAN>restore datafile4;
Starting restoreat23-MAY-14
Starting implicit crosscheck backupat23-MAY-14
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=19devicetype=DISK
Crosschecked1objects
Finished implicit crosscheck backupat23-MAY-14
Starting implicit crosscheck copyat23-MAY-14
usingchannel ORA_DISK_1
Finished implicit crosscheck copyat23-MAY-14
searchingforallfilesinthe recovery area
cataloging files...
cataloging done
ListofCataloged Files
=======================
FileName:/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848315530_9qywtvp0_.bkp
usingchannel ORA_DISK_1
channel ORA_DISK_1:starting datafile backupsetrestore
channel ORA_DISK_1:specifying datafile(s)torestorefrombackupset
channel ORA_DISK_1:restoring datafile00004to/u01/app/oracle/oradata/TestDB11/users01.dbf
channel ORA_DISK_1:readingfrombackup piece/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T110813_9qywmfpo_.bkp
channel ORA_DISK_1:piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T110813_9qywmfpo_.bkp tag=TAG20140523T110813
channel ORA_DISK_1:restored backup piece1
channel ORA_DISK_1:restore complete,elapsedtime:00:00:03
Finished restoreat23-MAY-14
--8.6恢复数据库. (提问,这里为什么不能执行recover datafile 4)
RMAN>recover database;
Starting recoverat23-MAY-14
usingchannel ORA_DISK_1
starting media recovery
archivedlogforthread1withsequence125isalreadyondiskasfile/u01/app/oracle/oradata/TestDB11/redo02.log
archivedlogfilename=/u01/app/oracle/oradata/TestDB11/redo02.logthread=1sequence=125
media recovery complete,elapsedtime:00:00:06
Finished recoverat23-MAY-14
--8.7开库
RMAN>alterdatabaseopenresetlogs;
database opened
--9.验证数据库恢复正常
sys@TESTDB11>select*fromscott.emp;
EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO
---------- ---------- --------- ---------- --------- ----------
---------- ----------
7369SMITHCLERK790217-DEC-80180030
7499ALLENSALESMAN769820-FEB-81210030030
7521WARDSALESMAN769822-FEB-81175050030
--使用恢复目录
--1.创建恢复目录数据库
--1.1首先调整虚拟机内存的大小为4G,而且启动虚拟机
--1.2如果原来的数据库实例已经启动,则关闭它
sys@TESTDB11>shutdownimmediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
--1.3修改/export/home/oracle/.profile配置文件,将ORACLE_SID环境变量删除
MAIL=/usr/mail/${LOGNAME:?}
export PS1='[\u@\h:$PWD]$ '
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
exportPATH=$PATH:$ORACLE_HOME/bin
umask022
export LD_LIBRAEY_PATH=/usr/local/lib:.
export CC=gcc
exportPATH=$PATH:/usr/local/bin
alias sqlplus='/usr/local/bin/rlwrap sqlplus'
alias rman='/usr/local/bin/rlwrap rman'
alias adrci='/usr/local/bin/rlwrap adrci'
--1.4使用DBCA建立恢复目录数据库
--1.5修改/home/oracle/.bash_profile,添加export
ORACLE_SID=rcat
--1.6启动恢复目录数据库
[oracle@S1011:/export/home/oracle]$ sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononFri May2315:29:212014
Copyright(c)1982,2011,Oracle.Allrights reserved.
Connectedto:
Oracle Database11g Enterprise EditionRelease11.2.0.3.0-64bitProduction
Withthe Partitioning,OLAP,DataMiningandRealApplication
Testing options
sys@RCAT>
--1.7开另一个会话,启动原来的TestDB11数据库实例
[oracle@S1011:/export/home/oracle]$.oraenv
ORACLE_SID=[rcat]?TestDB11
The Oracle base remains unchangedwithvalue/u01/app/oracle
[oracle@S1011:/export/home/oracle]$ sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononFri May2315:29:492014
Copyright(c)1982,2011,Oracle.Allrights reserved.
Connectedtoan idle instance.
idle>startup
ORACLE instance started.
Total SystemGlobalArea855982080bytes
FixedSize2230792bytes
VariableSize641730040bytes
Database Buffers209715200bytes
Redo Buffers2306048bytes
Database mounted.
Database opened.
idle>conn/assysdba
Connected.
sys@TESTDB11>
--2.创建恢复目录的所者
--2.1登录rcat数据库实例,查看当前数据文件的位置
sys@RCAT>selectnamefromv$datafile;
NAME
---------------------------------------------
/u01/app/oracle/oradata/rcat/system01.dbf
/u01/app/oracle/oradata/rcat/sysaux01.dbf
/u01/app/oracle/oradata/rcat/undotbs01.dbf
/u01/app/oracle/oradata/rcat/users01.dbf
--2.2创建新的表空间,用于恢复目录
sys@RCAT>createtablespace rcat_tbs datafile'/u01/app/oracle/oradata/rcat/rcat_tbs01.dbf'size30M;
Tablespace created.
--2.3创建用户分配配额
sys@RCAT>createuserrcatowneridentifiedbyrcatownerdefaulttablespace rcat_tbs quota unlimitedonrcat_tbs;
Usercreated.
--2.4给恢复目录所有者授权
sys@RCAT>grantrecovery_catalog_ownertorcatowner;
Grantsucceeded.
--3.创建恢复目录
--3.1连接
[oracle@S1011:/export/home/oracle]$ sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononFri May2315:45:262014
Copyright(c)1982,2011,Oracle.Allrights reserved.
Connectedto:
Oracle Database11g Enterprise EditionRelease11.2.0.3.0-64bitProduction
Withthe Partitioning,OLAP,DataMiningandRealApplication
Testing options
sys@RCAT>
--3.2创建
RMAN>createcatalog;
recoverycatalogcreated
--3.3将数据库注册到恢复目录
[oracle@S1011:/export/home/oracle]$.oraenv
ORACLE_SID=[rcat]?TestDB11
The Oracle base remains unchangedwithvalue/u01/app/oracle
[oracle@S1011:/export/home/oracle]$ rman target/catalogrcatowner/rcatowner@rcat
Recovery Manager:Release11.2.0.3.0-ProductiononFri May2316:32:102014
Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.
connectedtotarget database:TESTDB11(DBID=2578856066)
connectedtorecoverycatalogdatabase
RMAN>register database;
database registeredinrecoverycatalog
starting full resyncofrecoverycatalog
full resync complete
--4.删除现有备份
-- 4.1同样模拟所有控制文件丢失和丢失一个数据文件的场景
RMAN>deletebackup;
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=24devicetype=DISK
specification doesnotmatchanybackupinthe repository
--4.2开启控制文件自动备份
RMAN>showall;
RMAN configurationparametersfordatabasewithdb_unique_name TESTDB11are:
CONFIGURE RETENTION POLICYTOREDUNDANCY1;#default
CONFIGURE BACKUP OPTIMIZATIONOFF;#default
CONFIGUREDEFAULTDEVICETYPETODISK;#default
CONFIGURE CONTROLFILE AUTOBACKUPOFF;#default
CONFIGURE CONTROLFILE AUTOBACKUPFORMATFORDEVICETYPEDISKTO'%F';#default
CONFIGURE DEVICETYPEDISK PARALLELISM1BACKUPTYPETOBACKUPSET;#default
CONFIGURE DATAFILE BACKUP COPIESFORDEVICETYPEDISKTO1;#default
CONFIGURE ARCHIVELOG BACKUP COPIESFORDEVICETYPEDISKTO1;#default
CONFIGURE MAXSETSIZETOUNLIMITED;#default
CONFIGURE ENCRYPTIONFORDATABASEOFF;#default
CONFIGURE ENCRYPTION ALGORITHM'AES128';#default
CONFIGURE COMPRESSION ALGORITHM'BASIC'ASOFRELEASE'DEFAULT'OPTIMIZEFORLOADTRUE;#default
CONFIGURE ARCHIVELOG DELETION POLICYTONONE;#default
CONFIGURE SNAPSHOT CONTROLFILE NAMETO'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_TestDB11.f';#default
RMAN>configure controlfile autobackupon;
newRMAN configurationparameters:
CONFIGURE CONTROLFILE AUTOBACKUPON;
newRMAN configurationparametersaresuccessfully
stored
starting full resyncofrecoverycatalog
full resync complete
--4.3对数据库进行备份
RMAN>backup database;
Starting backupat23-MAY-14
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=39devicetype=DISK
channel ORA_DISK_1:starting full datafile backupset
channel ORA_DISK_1:specifying datafile(s)inbackupset
inputdatafilefilenumber=00001name=/u01/app/oracle/oradata/TestDB11/system01.dbf
inputdatafilefilenumber=00002name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf
inputdatafilefilenumber=00005name=/u01/app/oracle/oradata/TestDB11/example01.dbf
inputdatafilefilenumber=00003name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf
inputdatafilefilenumber=00004name=/u01/app/oracle/oradata/TestDB11/users01.dbf
channel ORA_DISK_1:starting piece1at23-MAY-14
channel ORA_DISK_1:finished piece1at23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T164348_9qzj8on3_.bkp tag=TAG20140523T164348comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsedtime:00:04:25
Finished backupat23-MAY-14
Starting ControlFileandSPFILE Autobackupat23-MAY-14
piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkpcomment=NONE
Finished ControlFileandSPFILE Autobackupat23-MAY-14
--4.4删除数据文件和所有控制文件
rm/u01/app/oracle/oradata/TestDB11/control01.ctl
rm/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl
--4.5访问数据
sys@TESTDB11>select*fromscott.emp;
select*fromscott.emp
*
ERRORatline1:
ORA-01116:errorinopening databasefile4
ORA-01110:datafile4:'/u01/app/oracle/oradata/TestDB11/users01.dbf'
ORA-27041:unabletoopenfile
Solaris-AMD64 Error:2:Nosuchfileordirectory
Additional information:3
--4.6尝试使数据文件脱机
sys@TESTDB11>alterdatabase
datafile4offline;
alterdatabase datafile4offline
*
ERRORatline1:
ORA-00210:cannotopenthe specified controlfile
ORA-00202:controlfile:'/u01/app/oracle/oradata/TestDB11/control01.ctl'
ORA-27041:unabletoopenfile
Solaris-AMD64 Error:2:Nosuchfileordirectory
Additional information:3
--4.7关库
sys@TESTDB11>shutdown abort;
ORACLE instance shut down.
--5.进行还原和恢复
--5.1启动RMAN,同时连接目标数据库和恢复目录
[oracle@S1011:/export/home/oracle]$ rman target/catalogrcatowner/rcatowner@rcat
Recovery Manager:Release11.2.0.3.0-ProductiononFri May2316:56:302014
Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.
connectedtotarget database(notstarted)
connectedtorecoverycatalogdatabase
--5.2启库到NOMOUNT状态
RMAN>startup nomount;
Oracle instance started
Total SystemGlobalArea855982080bytes
FixedSize2230792bytes
VariableSize641730040bytes
Database Buffers209715200bytes
Redo Buffers2306048bytes
--5.3还原控制文件
RMAN>restore controlfilefromautobackup;
Starting restoreat23-MAY-14
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=19devicetype=DISK
recovery area destination:/u01/app/oracle/fast_recovery_area
database name(ordatabaseuniquename)usedforsearch:TESTDB11
channel ORA_DISK_1:AUTOBACKUP/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkpfoundinthe recovery area
channel ORA_DISK_1:lookingforAUTOBACKUPonday:20140523
channel ORA_DISK_1:restoring controlfilefromAUTOBACKUP/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp
channel ORA_DISK_1:controlfilerestorefromAUTOBACKUP complete
outputfilename=/u01/app/oracle/oradata/TestDB11/control01.ctl
outputfilename=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl
Finished restoreat23-MAY-14
--5.4还原数据文件4
RMAN>restore datafile4;
Starting restoreat23-MAY-14
usingchannel ORA_DISK_1
channel ORA_DISK_1:starting datafile backupsetrestore
channel ORA_DISK_1:specifying datafile(s)torestorefrombackupset
channel ORA_DISK_1:restoring datafile00004to/u01/app/oracle/oradata/TestDB11/users01.dbf
channel ORA_DISK_1:readingfrombackup piece/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T164348_9qzj8on3_.bkp
channel ORA_DISK_1:piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T164348_9qzj8on3_.bkp tag=TAG20140523T164348
channel ORA_DISK_1:restored backup piece1
channel ORA_DISK_1:restore complete,elapsedtime:00:00:03
Finished restoreat23-MAY-14
--5.5使数据库进入MOUNT状态
RMAN>alterdatabase mount;
database mounted
released channel:ORA_DISK_1
--5.6恢复数据库
RMAN>recover database;
Starting recoverat23-MAY-14
Starting implicit crosscheck backupat23-MAY-14
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=19devicetype=DISK
Crosschecked2objects
Finished implicit crosscheck backupat23-MAY-14
Starting implicit crosscheck copyat23-MAY-14
usingchannel ORA_DISK_1
Finished implicit crosscheck copyat23-MAY-14
searchingforallfilesinthe recovery area
cataloging files...
cataloging done
ListofCataloged Files
=======================
FileName:/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp
usingchannel ORA_DISK_1
starting media recovery
archivedlogforthread1withsequence127isalreadyondiskasfile/u01/app/oracle/oradata/TestDB11/redo01.log
archivedlogfilename=/u01/app/oracle/oradata/TestDB11/redo01.logthread=1sequence=127
media recovery complete,elapsedtime:00:00:01
Finished recoverat23-MAY-14
--5.8开库
RMAN>alterdatabaseopenresetlogs;
database opened
newincarnationofdatabase registeredinrecoverycatalog
starting full resyncofrecoverycatalog
full resync complete
--6.验证数据库恢复正常
sys@TESTDB11>select*fromscott.emp;
EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO
---------- ---------- --------- ---------- --------- ----------
---------- ----------
7369SMITHCLERK790217-DEC-80180030
7499ALLENSALESMAN769820-FEB-81210030030
7521WARDSALESMAN769822-FEB-81175050030