参考文档--1、HowTo Restore RMAN Disk backups of RAC Database to Single Instance On Another Node (文档 ID 415579.1)
测试思路:在测试机上的orcl的rac类型的数据库恢复到另一个单节点。
总结过程:先从源环境的参数文件改动必要的参数----启动到nomount--恢复控制文件---数据库到mount状态--将备份信息注册到控制文件(如果目标环境中的存放备份文件的地址发生变化)
--确定还原的时间点或者scn,做还原和恢复操作---将不必要的在线日志删除--打开数据库--将不必要的undo表空间删除
1、归档模式下备份数据库
RMAN> run{
allocate channel c1 type disk format '/u01/dbbackup/20190912/%U';
backup database;
backup archivelog all;
}
RMAN> BACKUP CURRENT CONTROLFILE FORMAT '/u01/dbbackup/20190912/ctl.bak';--备份控制文件
2、源数据库中创建pfile,将该pfile在目标环境上改动部分参数。
a) don't forget to modify the following parameters depending on the directory structure of the new host: audit_file_dest, background_dump_dest, control_files, core_dump_dest, log_archive_dest_1, user_dump_dest etc
b) remove RAC specific parameters such as cluster_database_instances, cluster_database etc
c) for the parameter undo_tablespace, mention any one undo tablespace name
启动数据库
startup nomount;
3、还原控制文件并加载
RMAN> restore controlfile from '/u01/dbbak/orcl/ctl.bak';
Starting restore at 12-SEP-19
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/orcldata/orclctl.ctl
Finished restore at 12-SEP-19
SQL> alter database mount;
Database altered.
4、将备份信息注册到控制文件中
run{
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2369_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2368_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2367_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2366_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2365_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2364_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2363_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2362_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2361_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2360_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2359_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2358_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2357_1.backupset';
catalog backuppiece '/u01/dbbak/orcl/rman_ORCL_20190912_2355_1.backupset';
}
5、找出要恢复的最近的要用的重做日志,
SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE#
--------------------------------------------------
5975487643818
List of Archived Logs in backup set 2341
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 3 5975487569134 11-SEP-19 5975487580230 11-SEP-19
1 4 5975487580230 11-SEP-19 5975487591405 11-SEP-19
1 5 5975487591405 11-SEP-19 5975487593070 11-SEP-19
1 6 5975487593070 11-SEP-19 5975487596453 11-SEP-19
1 7 5975487596453 11-SEP-19 5975487599538 11-SEP-19
1 8 5975487599538 11-SEP-19 5975487600249 11-SEP-19
1 9 5975487600249 11-SEP-19 5975487611769 12-SEP-19
1 10 5975487611769 12-SEP-19 5975487623414 12-SEP-19
1 11 5975487623414 12-SEP-19 5975487643818 12-SEP-19
2 4 5975487636155 12-SEP-19 5975487643822 12-SEP-19
Backup Set Copy #1 of backup set 2341
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:03 12-SEP-19 NO TAG20190912T112547
List of Backup Pieces for backup set 2341 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
2341 1 EXPIRED /u01/dbbackup/rman_ORCL_20190912_2361_1.backupset
Backup Set Copy #2 of backup set 2341
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:03 12-SEP-19 NO TAG20190912T112547
List of Backup Pieces for backup set 2341 Copy #2
BP Key Pc# Status Piece Name
------- --- ----------- ----------
2363 1 AVAILABLE /u01/dbbak/orcl/rman_ORCL_20190912_2361_1.backupset
在以上信息中发现 sequence 11 thread 1是可用的最近的归档日志,那么恢复时的语句为
RMAN> report schema; ---查看需要恢复的表空间和数据文件情况
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name ORCL
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** +DATA/ORCL/DATAFILE/system.447.960913379
3 0 SYSAUX *** +DATA/ORCL/DATAFILE/sysaux.446.960913335
4 0 UNDOTBS1 *** +DATA/ORCL/DATAFILE/undotbs1.449.960913435
5 0 UNDOTBS2 *** +DATA/ORCL/DATAFILE/undotbs2.457.960913643
6 0 USERS *** +DATA/ORCL/DATAFILE/users.7838.985944863
7 0 T1 *** +DATA/ORCL/DATAFILE/t1.6685.1002206215
8 0 USERS *** +DATA/ORCL/DATAFILE/users.448.960913435
RMAN> run {
Set until time "to_date('2019-09-12 10:30:00','yyyy-mm-dd hh24:mi:ss')";
set newname for datafile 1 to '/u01/app/oracle/orcldata/system01.dbf';
set newname for datafile 3 to '/u01/app/oracle/orcldata/sysaux01.dbf';
set newname for datafile 4 to '/u01/app/oracle/orcldata/undotbs01.dbf';
set newname for datafile 5 to '/u01/app/oracle/orcldata/undotbs02.dbf';
set newname for datafile 6 to '/u01/app/oracle/orcldata/users01.dbf';
set newname for datafile 7 to '/u01/app/oracle/orcldata/t101.dbf';
set newname for datafile 8 to '/u01/app/oracle/orcldata/users02.dbf';
restore database;
switch datafile all;
recover database;
}
6、按照本地的地址重命名在线日志文件
7、打开数据库
SQL> alter database open resetlogs;
Database altered.
8、把原来rac环境下另外一个实例的日志文件删除
SQL> select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------------------ ------------------------
1 OPEN PUBLIC
2 CLOSED PUBLIC
SQL> select group# from v$log where THREAD#=2;
GROUP#
----------
3
4
SQL> select group# from v$log where THREAD#=2;
GROUP#
----------
3
4
SQL>
SQL> alter database disable thread 2;
Database altered.
SQL> alter database clear unarchived logfile group 3
2 ;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------------------ ------------------------
1 OPEN PUBLIC