Oracle 11G 恢复目录

一个recovery catalog是一个数据库中的方案,被RMAN使用来存储关于一个或多个Oracle数据库的元数据。

recovery catalog提供了下面的好处:

1. recovery catalog对于存储在每个目标数据库控制文件中的RMAN库提供了冗余。recovery catalog就像是第2个元数据库。

2. recovery catalog将所有的目标数据库集中进行管理。将元数据存储在单一的位置上可以使报表和管理任务更容易执行。

3. recovery catalog可以比控制文件将元数据存储更长的时间。

如果你要恢复数据库到比控制文件的历史还往前,这个功能就比较有用了。

管理recovery catalog增加的复杂度可以被扩展可用的备份的历史所带来的使得所抵销

 

一些RMAN功能只有当使用恢复目录时才可用,例如可以在恢复目录中存储RMAN脚本。

存储脚本的主要好处是,它对任何可以连接到目标数据库和恢复目录的RMAN客户端可用。

命令文件只有在RMAN客户端连接到它存储的文件系统时才可用。

当你在DG环境中使用RMAN时需要恢复目录。

通过存储所有主库和备库的备份的元数据,目录允许你offload备份任务到备库之一,

同时允许你在该环境中在其它数据库上还原备份。


恢复目录的基本概念

恢复目录包含每个注册的目标数据库的RMAN操作的元数据。

RMAN连接到恢复目录,RMAN从恢复目录exclusively获取它的元数据。

目录中包含下面类型的元数据:

1.  数据文件和归档重做日志文件备份集和备份片

2. 数据文件拷贝

3. 归档重做日志和它们的拷贝

4. 数据库结构(表空间和数据文件)

5. 存储脚本,是命名的用户创建的RMAN命令的序列

6. 持久化的RMAN配置设置

具体实现

--0. 两个场景都是运行在归档模式的数据库丢失一个数据文件,当前所有控制文件丢失。

--   控制文件、数据文件、归档日志都有备份而且是齐全的。

 

--1. 查看数据库当前的归档模式

sys@TESTDB11>archive log list;

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     123

Current log sequence           125

 

--2. 使数据库运行归档模式

--2.1 关库

sys@TESTDB11>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

--2.2 启动到MOUNT状态

sys@TESTDB11>startup mount;

ORACLE instance started.

 

Total System Global Area  855982080 bytes

Fixed Size                  2230792 bytes

Variable Size             641730040 bytes

Database Buffers          209715200 bytes

Redo Buffers                2306048 bytes

Database mounted.

--2.3 修改为归档模式

sys@TESTDB11>alter database archivelog;

 

Database altered.

--2.4 开库

sys@TESTDB11>alter database open;

 

Database altered.

 

--2.5 查看当前的归档模式

sys@TESTDB11>archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     123

Next log sequence to archive   125

Current log sequence           125

 

--3. 对数据库做个备份

RMAN> backup database;

 

Starting backup at 23-MAY-14

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=40 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=125 RECID=1 STAMP=848316651

input archived log thread=1 sequence=126 RECID=2 STAMP=848316921

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_annnn_TAG20140523T113522_9qyy6c86_.bkp tag=TAG20140523T113522 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

Finished backup at 23-MAY-14

 

Starting backup at 23-MAY-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/TestDB11/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/TestDB11/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/TestDB11/users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T113530_9qyy7bny_.bkp tag=TAG20140523T113530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:05:16

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_ncsnf_TAG20140523T113530_9qyyjk9h_.bkp tag=TAG20140523T113530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-MAY-14

 

Starting backup at 23-MAY-14

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=127 RECID=3 STAMP=848317250

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_annnn_TAG20140523T114051_9qyyjm50_.bkp tag=TAG20140523T114051 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-MAY-14

 

--3.1 查看上面的结果,确定控制文件并没有进行备份

--3.2 查看当前的配置

RMAN> show all;

 

RMAN configuration parameters for database with db_unique_name TESTDB11 are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_TestDB11.f'; # default

 

--3.3 配置控制文件自动备份

RMAN> configure controlfile autobackup on;

 

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

 

--3.3 删除当前备份

RMAN> delete backup;

 

--3.4 再次进行备份

RMAN> backup database;

 

Starting backup at 23-MAY-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/TestDB11/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/TestDB11/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/TestDB11/users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T114917_9qyz0fxc_.bkp tag=TAG20140523T114917 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:05:55

Finished backup at 23-MAY-14

 

Starting Control File and SPFILE Autobackup at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 23-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>show parameter control_files

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

control_files                        string      /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 / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 23 13:40:40 2014

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

sys@TESTDB11>select * from scott.emp;

select * from scott.emp

                    *

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4: '/u01/app/oracle/oradata/TestDB11/users01.dbf'

ORA-27041: unable to open file

Solaris-AMD64 Error: 2: No such file or directory

Additional information: 3

 

--6. 将数据文件脱机,准备进行还原和恢复. (结论:发现控制文件也丢失了)

sys@TESTDB11>alter database datafile 4 offline;

alter database datafile 4 offline

*

ERROR at line 1:

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/TestDB11/control01.ctl'

ORA-27041: unable to open file

Solaris-AMD64 Error: 2: No such file or directory

Additional information: 3

 

--7. 关库

sys@TESTDB11>shutdown immediate;

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/TestDB11/control01.ctl'

ORA-27041: unable to open file

Solaris-AMD64 Error: 2: No such file or directory

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: Release 11.2.0.3.0 - Production on Fri May 23 13:46:54 2014

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

 

--8.2 启库到NOMOUNT状态

RMAN> startup nomount;

 

Oracle instance started

 

Total System Global Area     855982080 bytes

 

Fixed Size                     2230792 bytes

Variable Size                641730040 bytes

Database Buffers             209715200 bytes

Redo Buffers                   2306048 bytes

 

--8.3 还原控制文件

RMAN> restore controlfile from autobackup;

 

Starting restore at 23-MAY-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

 

recovery area destination: /u01/app/oracle/fast_recovery_area

database name (or database unique name) used for search: TESTDB11

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848318113_9qyzclfx_.bkp

channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/app/oracle/oradata/TestDB11/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl

Finished restore at 23-MAY-14

 

--8.4 使数据库进入MOUNT状态

RMAN> alter database mount;

 

--8.5 还原数据文件4

RMAN> restore datafile 4;

 

Starting restore at 23-MAY-14

Starting implicit crosscheck backup at 23-MAY-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 23-MAY-14

 

Starting implicit crosscheck copy at 23-MAY-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 23-MAY-14

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848315530_9qywtvp0_.bkp

 

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/TestDB11/users01.dbf

channel ORA_DISK_1: reading from backup 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 piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

Finished restore at 23-MAY-14

 

--8.6 恢复数据库. (提问,这里为什么不能执行recover datafile 4)

RMAN> recover database;

 

Starting recover at 23-MAY-14

using channel ORA_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 125 is already on disk as file /u01/app/oracle/oradata/TestDB11/redo02.log

archived log file name=/u01/app/oracle/oradata/TestDB11/redo02.log thread=1 sequence=125

media recovery complete, elapsed time: 00:00:06

Finished recover at 23-MAY-14

 

--8.7 开库

RMAN> alter database open resetlogs;

 

database opened

 

--9. 验证数据库恢复正常

sys@TESTDB11>select * from scott.emp;

 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

      7369 SMITH      CLERK           7902 17-DEC-80       1800                    30

      7499 ALLEN      SALESMAN        7698 20-FEB-81       2100        300         30

      7521 WARD       SALESMAN        7698 22-FEB-81       1750        500         30

     

     

--使用恢复目录

--1. 创建恢复目录数据库

--1.1 首先调整虚拟机内存的大小为4G,而且启动虚拟机

--1.2 如果原来的数据库实例已经启动,则关闭它

sys@TESTDB11>shutdown immediate;

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

export PATH=$PATH:$ORACLE_HOME/bin

umask 022

export LD_LIBRAEY_PATH=/usr/local/lib:.

export CC=gcc

export PATH=$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 / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 23 15:29:21 2014

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

sys@RCAT>

 

--1.7 开另一个会话,启动原来的TestDB11数据库实例

[oracle@S1011:/export/home/oracle]$ . oraenv

ORACLE_SID = [rcat] ? TestDB11

The Oracle base remains unchanged with value /u01/app/oracle

[oracle@S1011:/export/home/oracle]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 23 15:29:49 2014

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

idle>startup

ORACLE instance started.

 

Total System Global Area  855982080 bytes

Fixed Size                  2230792 bytes

Variable Size             641730040 bytes

Database Buffers          209715200 bytes

Redo Buffers                2306048 bytes

Database mounted.

Database opened.

idle>conn / as sysdba

Connected.

sys@TESTDB11>

 

--2. 创建恢复目录的所者

--2.1 登录rcat数据库实例, 查看当前数据文件的位置

sys@RCAT>select name from v$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>create tablespace rcat_tbs datafile '/u01/app/oracle/oradata/rcat/rcat_tbs01.dbf' size 30M;

 

Tablespace created.

 

--2.3 创建用户分配配额

sys@RCAT>create user rcatowner identified by rcatowner default tablespace rcat_tbs quota unlimited on rcat_tbs;

 

User created.

 

--2.4 给恢复目录所有者授权

sys@RCAT>grant recovery_catalog_owner to rcatowner;

 

Grant succeeded.

 

 

 

--3. 创建恢复目录

--3.1 连接

[oracle@S1011:/export/home/oracle]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 23 15:45:26 2014

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

sys@RCAT>

 

--3.2 创建

RMAN> create catalog;

 

recovery catalog created

 

--3.3 将数据库注册到恢复目录

[oracle@S1011:/export/home/oracle]$ . oraenv

ORACLE_SID = [rcat] ? TestDB11

The Oracle base remains unchanged with value /u01/app/oracle

[oracle@S1011:/export/home/oracle]$ rman target / catalog rcatowner/rcatowner@rcat

 

Recovery Manager: Release 11.2.0.3.0 - Production on Fri May 23 16:32:10 2014

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: TESTDB11 (DBID=2578856066)

connected to recovery catalog database

 

RMAN> register database;

 

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

--4. 删除现有备份

-- 4.1 同样模拟所有控制文件丢失和丢失一个数据文件的场景

RMAN> delete backup;

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=24 device type=DISK

specification does not match any backup in the repository

 

--4.2 开启控制文件自动备份

RMAN> show all;

 

RMAN configuration parameters for database with db_unique_name TESTDB11 are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_TestDB11.f'; # default

 

RMAN> configure controlfile autobackup on;

 

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

starting full resync of recovery catalog

full resync complete

 

--4.3 对数据库进行备份

RMAN> backup database;

 

Starting backup at 23-MAY-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=39 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/TestDB11/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/TestDB11/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/TestDB11/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/TestDB11/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/TestDB11/users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-MAY-14

channel ORA_DISK_1: finished piece 1 at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/backupset/2014_05_23/o1_mf_nnndf_TAG20140523T164348_9qzj8on3_.bkp tag=TAG20140523T164348 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:04:25

Finished backup at 23-MAY-14

 

Starting Control File and SPFILE Autobackup at 23-MAY-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 23-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 * from scott.emp;

select * from scott.emp

                    *

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4: '/u01/app/oracle/oradata/TestDB11/users01.dbf'

ORA-27041: unable to open file

Solaris-AMD64 Error: 2: No such file or directory

Additional information: 3

 

--4.6 尝试使数据文件脱机

sys@TESTDB11>alter database datafile 4 offline;

alter database datafile 4 offline

*

ERROR at line 1:

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/TestDB11/control01.ctl'

ORA-27041: unable to open file

Solaris-AMD64 Error: 2: No such file or directory

Additional information: 3

 

--4.7 关库

sys@TESTDB11>shutdown abort;

ORACLE instance shut down.

 

--5. 进行还原和恢复

--5.1 启动RMAN,同时连接目标数据库和恢复目录

[oracle@S1011:/export/home/oracle]$ rman target / catalog rcatowner/rcatowner@rcat

 

Recovery Manager: Release 11.2.0.3.0 - Production on Fri May 23 16:56:30 2014

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

connected to recovery catalog database

 

--5.2 启库到NOMOUNT状态

RMAN> startup nomount;

 

Oracle instance started

 

Total System Global Area     855982080 bytes

 

Fixed Size                     2230792 bytes

Variable Size                641730040 bytes

Database Buffers             209715200 bytes

Redo Buffers                   2306048 bytes

 

--5.3 还原控制文件

RMAN> restore controlfile from autobackup;

 

Starting restore at 23-MAY-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

 

recovery area destination: /u01/app/oracle/fast_recovery_area

database name (or database unique name) used for search: TESTDB11

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp found in the recovery area

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140523

channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp

channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/app/oracle/oradata/TestDB11/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl

Finished restore at 23-MAY-14

 

--5.4 还原数据文件4

RMAN> restore datafile 4;

 

Starting restore at 23-MAY-14

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/TestDB11/users01.dbf

channel ORA_DISK_1: reading from backup 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 piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

Finished restore at 23-MAY-14

 

--5.5 使数据库进入MOUNT状态

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

 

--5.6 恢复数据库

RMAN> recover database;

 

Starting recover at 23-MAY-14

Starting implicit crosscheck backup at 23-MAY-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

Crosschecked 2 objects

Finished implicit crosscheck backup at 23-MAY-14

 

Starting implicit crosscheck copy at 23-MAY-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 23-MAY-14

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2014_05_23/o1_mf_s_848335695_9qzjk1wp_.bkp

 

using channel ORA_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 127 is already on disk as file /u01/app/oracle/oradata/TestDB11/redo01.log

archived log file name=/u01/app/oracle/oradata/TestDB11/redo01.log thread=1 sequence=127

media recovery complete, elapsed time: 00:00:01

Finished recover at 23-MAY-14

 

--5.8 开库

RMAN> alter database open resetlogs;

 

database opened

new incarnation of database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

 

--6. 验证数据库恢复正常

sys@TESTDB11>select * from scott.emp;

 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

      7369 SMITH      CLERK           7902 17-DEC-80       1800                    30

      7499 ALLEN      SALESMAN        7698 20-FEB-81       2100        300         30

      7521 WARD       SALESMAN        7698 22-FEB-81       1750        500         30

     

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17013648/viewspace-1172127/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/17013648/viewspace-1172127/

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值