This feature addresses three capabilities of Oracle Recovery Manager (RMAN) in a cross-platform migration: (1) RMAN support for Data Recovery Advisor on a standby database. Basically, when a data file is lost on a primary or standby database, RMAN generates repair scripts to fetch the file from the primary or standby database. (2) Support for active duplicate scripts with cross-platform transport. The active duplicate defaults to backup set method only when the number of auxiliary channels is equal to or greater than the target channels and there is a TNS alias for the target database. This is required so that we do not break the existing active duplicate scripts. (3) Active restore needs the added capability to support backup and restore cross-endian. However, this is limited to the tablespaces and not the entire database. This needs an additional FROM SERVICE syntax in the RESTORE FROM PLATFORM command such that it starts off an active restore session.

https://apex.oracle.com/database-features/

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/bradv/rman-transporting-data-across-platforms.html#GUID-6D2F4279-B6CC-4BB3-AE56-4D3D40A4CBF3

说明:
在dg 无论是主库还是备库的数据文件丢失或者误删后都可以从对方库进行恢复,亦或者直接进行全库恢复,之后从新开启同步

实验测试

1.dg数据文件丢失恢复

1.取消备库同步

  1. alter database recover managed standby database cancel;

2.主库删除表空间

  1. asmcmd
  2. cd data
  3. rm /ORCL/DATAFILE/xtts1.496.1080356379
  4. rm /ORCL/DATAFILE/xtts2.497.1080356381

3.检查主库到备库的tns连接

  1. netmgr

image.png

4.在备库查询需要迁移的数据文件编号

  1. select * from v$dbfile;

5.从备库恢复数据文件

  1. RESTORE FOREIGN DATAFILE 9,10 TO NEW FROM SERVICE 'tnsorcldg';
  2. RMAN> RESTORE FOREIGN DATAFILE 9,10 TO NEW FROM SERVICE tnsorcldg;
  3. Starting restore at 12-AUG-21
  4. using target database control file instead of recovery catalog
  5. allocated channel: ORA_DISK_1
  6. channel ORA_DISK_1: SID=381 instance=orcl1 device type=DISK
  7. channel ORA_DISK_1: starting datafile backup set restore
  8. channel ORA_DISK_1: using network backup set from service tnsorcldg
  9. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  10. channel ORA_DISK_1: restoring foreign file 9 to +DATA/ORCL/DATAFILE/xtts1.496.1080356379
  11. channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
  12. channel ORA_DISK_1: starting datafile backup set restore
  13. channel ORA_DISK_1: using network backup set from service tnsorcldg
  14. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  15. channel ORA_DISK_1: restoring foreign file 10 to +DATA/ORCL/DATAFILE/xtts2.497.1080356381
  16. channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
  17. Finished restore at 12-AUG-21

6.recover 数据文件

  1. RECOVER FOREIGN DATAFILECOPY '+DATA/ORCL/DATAFILE/xtts1.496.1080356379','+DATA/ORCL/DATAFILE/xtts2.497.1080356381' FROM SERVICE tnsorcldg;
  2. RMAN> RECOVER FOREIGN DATAFILECOPY '+DATA/ORCL/DATAFILE/xtts1.496.1080356379','+DATA/ORCL/DATAFILE/xtts2.497.1080356381' FROM SERVICE tnsorcldg;
  3. Starting recover at 12-AUG-21
  4. using channel ORA_DISK_1
  5. skipping datafilecopy +DATA/ORCL/DATAFILE/xtts1.496.1080356379; already recovered to SCN 9845318
  6. skipping datafilecopy +DATA/ORCL/DATAFILE/xtts2.497.1080356381; already recovered to SCN 11004068
  7. Finished recover at 12-AUG-21

7.检查同步过来的数据文件

  1. select * from v$dbfile;

8.原有备库从新恢复同步

  1. alter database recover managed standby database disconnect;

2.针对全库同步恢复

1.主要命令

  1. shutdown immedaite;
  2. startup mount;
  3. RESTORE database FROM SERVICE tnsorcldg;
  4. RECOVER FOREIGN database FROM SERVICE tnsorcldg;