使用RMAN对PDB中的表空间或数据文件执行完全恢复

因为不同PDB中的表空间可以有相同的名字,为了消除这种混淆你必须直接连接到PDB来恢复PDB的表空间。相反,因为数据文件号与路径名是跨CDB唯一标识的,所以可以连接到root容器或PDB来恢复PDB的数据文件。如果连接到CDB的root容器,那么可以使用单个命令来恢复多个PDB中的数据文件。如果连接到PDB,只能恢复PDB中的数据文件。

还原与恢复PDB中的non-SYSTEM表空间
1.启动RMAN并连接到目标数据库

[Oracle@jytest1 ~]$ rman target sys/xxxxx@jypdb

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 17:59:27 2017

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

connected to target database: JY:JYPDB (DBID=4203494064)
2.如果数据库的状态为open,那么将要恢复的表空间置于脱机状态

SQL> alter tablespace test offline immediate;

Tablespace altered.
3.使用show命令来查看是否配置了预先设置的通道。如果需要的设置类型与通道被配置,那么不需要执行任何操作。否则可以使用configure命令来配置自动通道,或都使用包含allocate channel命令的run块

RMAN> show all;

RMAN configuration parameters for database with db_unique_name JY are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+test/rman_backup/%F';
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 RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+test/jy/snapcf_jy.f';
4.还原与恢复表空间
.如果将数据文件还原到原始位置,那么执行restore tablespace与recover tablespace命令

.如果将数据文件还原到新目录,那么在run命令块中执行restore tablespace与recover tablespace命令,并且使用set newname命令来重命名数据文件。

RMAN> restore tablespace 'TEST';

Starting restore at 11-DEC-17
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 00015 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_20171211_0osls830_1_1
channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_20171211_0osls830_1_1 tag=TAG20171211T164446
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 11-DEC-17

RMAN> recover tablespace 'TEST';

Starting recover at 11-DEC-17
using channel ORA_DISK_1

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

Finished recover at 11-DEC-17
5.检查输出结果查看是否恢复成功。如果恢复成功将表空间设置为联机状态

RMAN> alter tablespace test online;

Statement processed
还原与恢复PDB中的SYSTEM表空间
1.启动RMAN并使用有sysdba或sysbackup权限的公共用户连接到root容器。

[oracle@jytest1 ~]$ rman target/ catalog rco/xxzx7817600@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 18:11:55 2017

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

connected to target database: JY (DBID=979425723)
connected to recovery catalog database
2.关闭CDB并重启到mount状态

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  8807168 bytes
Variable Size            1895828736 bytes
Database Buffers        4529848320 bytes
Redo Buffers                7966720 bytes
Database mounted.

3.还原与恢复PDB中SYSTEM表空间的数据文件

[oracle@jytest1 ~]$ rman target/ catalog rco/xxzx7817600@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 18:20:30 2017

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

connected to target database: JY (DBID=979425723, not open)
connected to recovery catalog database

RMAN> report schema;

starting full resync of recovery catalog
full resync complete
Report of database schema for database with db_unique_name JY

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3637a6381143196654f817770f1dbd0e.html