Oracle RMAN restores the database to different hosts
I. RMAN backup content
When RMAN is used for full backup, it contains data files, archive logs, control files, parameter files, and backup logs, as shown below:
Arch_20160223_08qukp2t_1_1 arch_20160223_0bqukp92_1_1 ctl_c-3234695588-20160223-01 rmanbak-20160223-0852.log scp_20160223_09qukp2u_1_1 scp_20160223_0aqukp2u_1_1
Ii. Test Environment
OS: CentOS release 6.4 (Final)
Database: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0-64bit Production
The original platform is consistent with the current platform environment, but the directory structure of the oracle database is inconsistent.
Iii. Start recovery
1. Confirm the DBID of the original database (identified by the RMAN backup log or the RMAN backup control file name) and the Instance name of the original database;
2. Copy the RMAN backup content to the target database;
3. Set environment variables:
[Oracle @ dg1 ~] $ Export NLS_DATA_FORMAT = 'yyyy-MM-DD HH24: MI: ss'
[Oracle @ dg1 ~] $ Export ORACLE_SID = scp
[Oracle @ dg1 ~] $ Rman target/
Recovery Manager: Release 12.1.0.2.0-Production on Fri May 6 22:18:52 2016
4. Load and restore the database
A. Load the database
RMAN> set dbid = 3234695588;
Executing command: SET DBID
RMAN> startup nomount;
Startup failure: ORA-01078: failure in processing system parameters
LRM-00109: cocould not open parameter file '/u01/app/oracle/product/12.1.0.2/dbs/initscp. ora'
Starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
B. Restore the spfile file (or pfile file, you can modify parameters) first, because the spfile file contains the location of the control file.
RMAN> restore spfile to pfile' $ ORACLE_HOME/dbs/initscp. ora 'from'/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01 ';
OR:
RMAN> restore spfile to '$ ORACLE_HOME/dbs/spfilescp. ora' from '/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01 ';
C. Modify the local system directory based on the relevant parameters in the pfile file, or modify the pfile to match the path and directory in the local system.
You need to modify: oracle_base, *. audit_file_dest, *. control_files, *. db_recovery_file_dest, *. Tables, *. diagnostic_dest, *. log_archive_dest_1,
Memory_target and undo_tablespace. Create related directories and permissions in the current system.
[Oracle @ dg1 dbs] $ vim initscp. ora
Scp. _ data_transfer_cache_size = 0
Scp. _ db_cache_size = 822083584
Scp. _ java_pool_size = 16777216
Scp. _ large_pool_size = 33554432
Scp. _ oracle_base = '/u01/app/oracle' # ORACLE_BASE set from environment
Scp. _ pga_aggregate_target = 654311424
Scp. _ sga_target = 1241513984
Scp. _ shared_io_pool_size = 50331648
Scp. _ shared_pool_size = 301989888
Scp. _ streams_pool_size = 0
*. Audit_file_dest = '/u01/app/oracle/admin/scp/adump'
*. Audit_trail = 'db'
*. Compatible = '12. 1.0.2.0'
*. Control_files = '/u01/app/oracle/oradata/scp/control01.ctl', '/u01/app/oracle/fast_recovery_area/scp/control02.ctl'
*. Db_block_size = 8192
*. Db_domain =''
*. Db_name = 'scp'
*. Db_recovery_file_dest = '/u01/app/oracle/fast_recovery_area'
*. Db_recovery_file_dest_size = 4560 m
*. Diagnostic_dest = '/u01/app/oracle'
*. Dispatchers = '(PROTOCOL = TCP) (SERVICE = scpXDB )'
*. Log_archive_dest_1 = 'location =/OracleArch'
*. Memory_target = 1800 m
*. Open_cursors = 300
*. Processses = 300
*. Remote_login_passwordfile = 'clusive'
*. Undo_tablespace = 'undotbs1'
D. Start the database from the modified pfile file and restore the control file.
RMAN> shutdown abort;
RMAN> startup nomount pfile = '$ ORACLE_HOME/dbs/initscp. ora ';
RMAN> restore controlfile from '/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01 ';
Starting restore at 06-MAY-16
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 243 device type = DISK
Channel ORA_DISK_1: restoring control file
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Output file name =/home/OracleData/scp/control01.ctl
Output file name =/home/OracleArch/fast_recovery_area/control02.ctl
Finished restore at 06-MAY-16
-------------------------------------- Recommended reading --------------------------------------
ORA-19571 for RMAN backup
RMAN: Configure an archive log deletion policy
Basic Oracle tutorial-copying a database through RMAN
Reference for RMAN backup policy formulation
RMAN backup learning notes
Oracle Database Backup encryption RMAN Encryption
ORA-19588 encountered during RMAN backup
-------------------------------------- Split line --------------------------------------
E. After the control file is restored, you can mount the database.
RMAN> alter database mount;
Statement processed
Released channel: ORA_DISK_1
F. At this point, the control file has been restored, the database has been mounted, and all RMAN configuration parameters have been set. You should verify the paths to ensure that they apply to the host.
RMAN> show all;
RMAN configuration parameters for database with db_unique_name SCP are:
Configure retention policy to recovery window of 7 DAYS;
Configure backup optimization off; # default
Configure default device type to disk; # default
Configure controlfile autobackup on;
Configure controlfile autobackup format for device type disk to '/orabackup/RmanBackupSet/20160223/ctl _ % 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 '/u01/app/oracle/product/12.1.0.2/dbs/snapcf_scp.f'; # default
G. To allow RMAN to locate the file to be recovered, we have two ways to achieve this: first, modify the RMAN configuration to match the location of the current backup file, next, copy the RMAN backup file to the location specified in the configuration file (refer to the RMAN backup log ). In the first method, to let RMAN know the location of the backup file/home/OracleBack/rmanbak, we use the catalog command:
RMAN> catalog start with '/home/OracleBack/rmanbak ';
Starting implicit crosscheck backup at 06-MAY-16
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 243 device type = DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 06-MAY-16
Starting implicit crosscheck copy at 06-MAY-16
Using channel ORA_DISK_1
Finished implicit crosscheck copy at 06-MAY-16
Searching for all files in the recovery area
Cataloging files...
No files cataloged
Searching for all files that match the pattern/home/OracleBack/rmanbak
List of Files Unknown to the Database
============================================
File Name:/home/OracleBack/rmanbak/scp_20160223_09qukp2u_1_1
File Name:/home/OracleBack/rmanbak/arch_20160223_0bqukp92_1_1
File Name:/home/OracleBack/rmanbak/scp_20160223_0aqukp2u_1_1
File Name:/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01
File Name:/home/OracleBack/rmanbak/arch_20160223_08qukp2t_1_1
Do you really want to catalog the above files (enter YES or NO )? Yes
Cataloging files...
Cataloging done
List of Cataloged Files
======================================
File Name:/home/OracleBack/rmanbak/scp_20160223_09qukp2u_1_1
File Name:/home/OracleBack/rmanbak/arch_20160223_0bqukp92_1_1
File Name:/home/OracleBack/rmanbak/scp_20160223_0aqukp2u_1_1
File Name:/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01
File Name:/home/OracleBack/rmanbak/arch_20160223_08qukp2t_1_1
H. Perform a cross-check on the backup set. Otherwise, an error may be reported during database restoration.
RMAN> crosscheck backup;
Using channel ORA_DISK_1
Crosschecked backup piece: found to be 'expired'
Backup piece handle =/orabackup/RmanBackupSet/20160223/arch_20160223_08qukp2t_1_1 RECID = 8 STAMP = 904553565
Crosschecked backup piece: found to be 'available'
Backup piece handle =/home/OracleBack/rmanbak/arch_20160223_08qukp2t_1_1 RECID = 16 STAMP = 911172456
Crosschecked backup piece: found to be 'expired'
Backup piece handle =/orabackup/RmanBackupSet/20160223/scp_20160223_0aqukp2u_1_1 RECID = 9 STAMP = 904553567
Crosschecked backup piece: found to be 'available'
Backup piece handle =/home/OracleBack/rmanbak/scp_20160223_0aqukp2u_1_1 RECID = 14 STAMP = 911172456
Crosschecked backup piece: found to be 'expired'
Backup piece handle =/orabackup/RmanBackupSet/20160223/scp_20160223_09qukp2u_1_1 RECID = 10 STAMP = 904553567
Crosschecked backup piece: found to be 'available'
Backup piece handle =/home/OracleBack/rmanbak/scp_20160223_09qukp2u_1_1 RECID = 12 STAMP = 911172456
Crosschecked backup piece: found to be 'expired'
Backup piece handle =/orabackup/RmanBackupSet/20160223/arch_20160223_0bqukp92_1_1 RECID = 11 STAMP = 904553762
Crosschecked backup piece: found to be 'available'
Backup piece handle =/home/OracleBack/rmanbak/arch_20160223_0bqukp92_1_1 RECID = 13 STAMP = 911172456
Crosschecked backup piece: found to be 'available'
Backup piece handle =/home/OracleBack/rmanbak/ctl_c-3234695588-20160223-01 RECID = 15 STAMP = 911172456
Crosschecked 9 objects
I. Obtain the table space and data file list through the control file
RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name SCP
List of Permanent Datafiles
======================================
File Size (MB) Tablespace RB segs Datafile Name
---------------------------------------------------------------
1 0 SYSTEM ***/u01/app/oracle/oradata/scp/system01.dbf
2 0 ZYTK_AC ***/u01/app/oracle/oradata/scp/zytk_ac01.dbf
3 0 SYSAUX ***/u01/app/oracle/oradata/scp/sysaux01.dbf
4 0 UNDOTBS1 ***/u01/app/oracle/oradata/scp/undotbs01.dbf
5 0 EXAMPLE ***/u01/app/oracle/oradata/scp/example01.dbf
6 0 USERS ***/u01/app/oracle/oradata/scp/users01.dbf
7 0 ZYTK_AC ***/u01/app/oracle/oradata/scp/zytk_ac02.dbf
8 0 ZYTK_ID ***/u01/app/oracle/oradata/scp/zytk_id01.dbf
9 0 ZYTK_ID ***/u01/app/oracle/oradata/scp/zytk_id02.dbf
10 0 ZYTK_OP ***/u01/app/oracle/oradata/scp/zytk_op01.dbf
11 0 ZYTK_OP ***/u01/app/oracle/oradata/scp/zytk_op02.dbf
12 0 ZYTK_TEST01 ***/u01/app/oracle/oradata/scp/zytk_test01.dbf
List of Temporary Files
======================================
File Size (MB) Tablespace Maxsize (MB) Tempfile Name
---------------------------------------------------------------
1 60 TEMP 32767/u01/app/oracle/oradata/scp/temp01.dbf
Note: The temp tablespace is not restore during restore. So after restore, We need to manually create the temp tablespace.
J. To restore the data file to a directory structure different from the original one, you must write a script, rename the location of the data file, and restore the entire database.
(If the data file path is the same as the original one, restore the database directly)
Run {
Set newname for datafile 1 to '/home/OracleData/scp/system01.dbf ';
Set newname for datafile 2 to '/home/OracleData/scp/zytk_ac01.dbf ';
Set newname for datafile 3 to '/home/OracleData/scp/sysaux01.dbf ';
Set newname for datafile 4 to '/home/OracleData/scp/undotbs01.dbf ';
Set newname for datafile 5 to '/home/OracleData/scp/example01.dbf ';
Set newname for datafile 6 to '/home/OracleData/scp/users01.dbf ';
Set newname for datafile 7 to '/home/OracleData/scp/zytk_ac02.dbf ';
Set newname for datafile 8 to '/home/OracleData/scp/zytk_id01.dbf ';
Set newname for datafile 9 to '/home/OracleData/scp/zytk_id02.dbf ';
Set newname for datafile 10 to '/home/OracleData/scp/zytk_op01.dbf ';
Set newname for datafile 11 to '/home/OracleData/scp/zytk_op02.dbf ';
Set newname for datafile 12 to '/home/OracleData/scp/zytk_test01.dbf ';
Restore database;
Switch datafile all;
}
Description of the switch datafile all command:
-- In nocatalog mode, the rman backup information is stored in the control file, including the path information of the data file. Switch datafile all is used to update the information in the control file. If the control file is not updated, the file is still located in the original location during the recover operation.
K. Perform the recover operation after restoring the database
RMAN> recover database;
Starting recover at 06-MAY-16
Using channel ORA_DISK_1
Starting media recovery
Channel ORA_DISK_1: starting archived log restore to default destination
Channel ORA_DISK_1: restoring archived log
Archived log thread = 1 sequence = 148
Channel ORA_DISK_1: reading from backup piece/home/OracleBack/rmanbak/arch_20160223_0bqukp92_1_1
Channel ORA_DISK_1: piece handle =/home/OracleBack/rmanbak/arch_20160223_0bqukp92_1_1 tag = ZYTK_DB_FULL
Channel ORA_DISK_1: restored backup piece 1
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Archived log file name =/home/OracleArch/ArchiveLog/logs 148_899483175.dbf thread = 1 sequence = 148
Unable to find archived log
Archived log thread = 1 sequence = 149
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of recover command at 23:53:58
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 149 and starting SCN of 3507749
For more details, please continue to read the highlights on the next page: