ITPub博客

首页 > 数据库 > Oracle > Backup And Recovery User's Guide-执行完全数据库恢复-执行表空间的完全恢复

Backup And Recovery User's Guide-执行完全数据库恢复-执行表空间的完全恢复

原创 Oracle 作者:luisedalian 时间:2014-02-27 08:34:07 0 删除 编辑

执行表空间的完全恢复

场景:                                                                                    

数据库处于OPEN状态,只有部分并不是所有的数据文件损坏了。

当在数据库处于打开状态时还原和恢复损坏的表空间,这样数据库的其它部分仍然可用。

这里假设trgt数据库丢失了users表空间。

练习:还原和恢复表空间

--1. 启动RMAN连接到目标数据库

--2. 如果数据库是OPEN状态,则使需要恢复的数据文件脱机

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";

--3. 使用SHOW命令查看预先配置的channel

--   如果需要的设备和通道已经被配置了,则不需要其它的操作;否则 使用CONFIGURE命令配置自动通道或在RUN块中包含ALLOCATE CHANNEL命令

SHOW ALL;

 

 

RMAN configuration parameters for database with db_unique_name PROD1 are:

.

.

.

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

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

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

CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so";

--4. 如果还原口令加密的备份,则指定口令; 如果使用了多个不同的口令创建备份,则需要执行SET DECRYPTION IDENTIFIED BY多次

--   指定还原备份可能需要的所有口令。

SET DECRYPTION IDENTIFIED BY password;

--5. 还原和恢复表空间

--5.1 如果还原数据文件到原来的位置,则执行RESTORE TABLESPACERECOVER TABLESPACE命令

RMAN> RESTORE TABLESPACE users;

 

Starting restore at 20-JUN-06

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=37 device type=DISK

allocated channel: ORA_SBT_TAPE_1

channel ORA_SBT_TAPE_1: SID=38 device type=SBT_TAPE

channel ORA_SBT_TAPE_1: Oracle Secure Backup

 

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 00012 to /disk1/oracle/dbs/users01.f

channel ORA_DISK_1: restoring datafile 00013 to /disk1/oracle/dbs/users02.f

channel ORA_DISK_1: restoring datafile 00021 to /disk1/oracle/dbs/users03.f

channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20070620T105435_29jflwor_.bkp

channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20070620T105435_29jflwor_.bkp tag=TAG20070620T105435

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 20-JUN-06

 

RMAN> RECOVER TABLESPACE users;

 

Starting recover at 20-JUN-06

using channel ORA_DISK_1

using channel ORA_SBT_TAPE_1

 

starting media recovery

 

archived log for thread 1 with sequence 27 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_27_29jjmtc9_.arc

archived log for thread 1 with sequence 28 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_28_29jjnc5x_.arc

.

.

.

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=5

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=6

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=7

.

.

.

channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T113128_29jhr197_.bkp

channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T113128_29jhr197_.bkp tag=TAG20070620T113128

channel ORA_DISK_1: restored backup piece 1

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

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq_.arc thread=1 sequence=5

channel default: deleting archived log(s)

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq_.arc RECID=91 STAMP=593611179

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_6_29jkdvbz_.arc thread=1 sequence=6

channel default: deleting archived log(s)

.

.

.

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

Finished recover at 20-JUN-06

 

--5.2 还原数据文件到新的位置,则必须在RUN块中执行RESTORERECOVER命令,使用SET NEWNAME来重命名数据文件。

RUN

{

  # 对每个数据文件指定新的位置

  SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users01.f' TO

                           '/disk2/users01.f';

  SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users02.f' TO

      &n

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

请登录后发表评论 登录
全部评论

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    5678350