Clone Database from Windows To Linux (Lower patchset to Higher) using RMAN (Doc ID 2143991.1)

To BottomTo Bottom

In this Document

  Goal
  Solution
  References

 

APPLIES TO: 

Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

GOAL

 

NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data 
from the Oracle sample schema(s), Public Documentation delivered with an Oracle database product or other training material.  
Any similarity to actual environments, actual persons, living or dead, is purely coincidental and not intended in any manner.


For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:

Database Name:  ORCL
Directory Names: D:\BAK\, D:\APP\ORCL, /u01/oradata and all sub-directories

***************** 

Steps to clone a database from Windows to Linux using RMAN .

SOLUTION

  

Source database in Windows - DBName - ORCL (11.2.0.1)
Cloned database in Linux - DBName - ORCL (11.2.0.3)

Step 1 :- Create a pfile from Source 

++Take the backup of pfile  from source .

create pfile='<>' from spfile. 

Step 2 :- Shutdown the database immediate and mount it 

++Take the backup of source database in Mount mode (Always take the cold backup)

SQL>Shutdown immediate ;

SQL>Startup mount ;

SQL> select name,open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
ORCL MOUNTED

SQL> exit 

Step 3 :- Connect to Rman and take a cold backup of Source database

$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed May 4 10:06:38 2016

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

connected to target database: ORCL (DBID=<DBID>, not open)

RMAN> backup database format 'D:\BAK\full_%U'; ----Full backup

Starting backup at 04-MAY-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=<PATH>\SYSTEM01.DBF
input datafile file number=00002 name=<PATH>\SYSAUX01.DBF
input datafile file number=00003 name=<PATH>\UNDOTBS01.DBF
input datafile file number=00004 name=<PATH>\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 04-MAY-16
channel ORA_DISK_1: finished piece 1 at 04-MAY-16
piece handle=D:\BAK\FULL_A5R4O160_1_1 tag=TAG20160504T100656 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:15
Finished backup at 04-MAY-16

Starting Control File and SPFILE Autobackup at 04-MAY-16
piece handle=D:\APP\ORCL\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2016_05_04\O1_MF_S_910951563_****_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 04-MAY-16

RMAN> backup current controlfile format 'd:\bak\control_%U'; --Controlfile backup

Starting backup at 04-MAY-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 04-MAY-16
channel ORA_DISK_1: finished piece 1 at 04-MAY-16
piece handle=D:\BAK\CONTROL_A7R4O1B4_1_1 tag=TAG20160504T100940 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 04-MAY-16

Starting Control File and SPFILE Autobackup at 04-MAY-16
piece handle=D:\APP\ORCL\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2016_05_04\****.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 04-MAY-16

 

Step 4 :- Copied the required files to  the destination server (Linux)   

Cloned Server :

++Copy the pfile backup from source (Windows) to Target (Linux) and modify the location as per your environment .
++Copy all the backups from source to cloned server . 

Step 5 :- No Mount the Destination database 

Start the cloned database in NOMOUNT mode .

SQL> startup nomount pfile='/u01/oradata/ORCL/initORCL.ora'; 

Step 6 :- Restore the controlfile

 

++Connect through RMAN and restore the controlfile

$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed May 4 10:15:48 2016

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

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from '<backup location>/CONTROL_A7R4O1B4_1_1';

Starting restore at 04-MAY-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradata/ORCL/CONTROL01.CTL
Finished restore at 04-MAY-16

 

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1 

Step 7 :- Run the Rman maintainance command to Mark the unwanted backups as expired

 

++Execute crosscheck command and delete the expired backup .

RMAN> crosscheck backup;  

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK\FULL_A5R4O160_1_1 RECID=375 STAMP=910951617
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\APP\ORCL\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2016_05_04\O1_MF_S_910951563_&***_.BKP RECID=376 STAMP=910951754
Crosschecked 2 objects

RMAN> delete expired backup;

using channel ORA_DISK_1

List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
375 257 1 1 EXPIRED DISK D:\BAK\FULL_A5R4O160_1_1
376 258 1 1 EXPIRED DISK D:\APP\ORCL\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2016_05_04\O1_MF_S_910951563_*****_.BKP

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=D:\BAK\FULL_A5R4O160_1_1 RECID=375 STAMP=910951617
deleted backup piece
backup piece handle=D:\APP\ORCL\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2016_05_04\O1_MF_S_910951563_*****_.BKP RECID=376 STAMP=910951754
Deleted 2 EXPIRED objects

Step 8 :- Catalog the backuppiece on the Destination server(Linux)

 

++Catalog all the backups copied in the cloned server .

RMAN> catalog backuppiece '<backup location>/FULL_*****0_1_1';

cataloged backup piece
backup piece handle=<backup location>/FULL_******1_1 RECID=377 STAMP=910952261

++Set the newname for datafile location's on cloned server .

Step 9: -Restore the datafiles to new location

RMAN> run {
set newname for database to '/u01/oradata/ORCL/datafile_%U';
restore database;
}2> 3> 4>

executing command: SET NEWNAME

Starting restore at 04-MAY-16
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 00001 to /u01/oradata/ORCL/datafile_data_D-ORCL_TS-SYSTEM_FNO-1
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/ORCL/datafile_data_D-ORCL_TS-SYSAUX_FNO-2
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/ORCL/datafile_data_D-ORCL_TS-UNDOTBS1_FNO-3
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/ORCL/datafile_data_D-ORCL_TS-USERS_FNO-4
channel ORA_DISK_1: reading from backup piece <backup location>/FULL_A5R4O160_1_1
channel ORA_DISK_1: piece handle=<backup location>/FULL_A5R4O160_1_1 tag=TAG20160504T100656
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 04-MAY-16

RMAN> switch database to copy;  

datafile 1 switched to datafile copy "/u01/oradata/ORCL/datafile_data_D-ORCL_TS-SYSTEM_FNO-1"
datafile 2 switched to datafile copy "/u01/oradata/ORCL/datafile_data_D-ORCL_TS-SYSAUX_FNO-2"
datafile 3 switched to datafile copy "/u01/oradata/ORCL/datafile_data_D-ORCL_TS-UNDOTBS1_FNO-3"
datafile 4 switched to datafile copy "/u01/oradata/ORCL/datafile_data_D-ORCL_TS-USERS_FNO-4"

RMAN> exit 

++Once restore done ...open the database with RESETLOG mode along with UPGRADE option . 

If cloning the database with  same RDBMS version  as source , open the database in normal RESETLOG mode .  

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed May 4 10:18:23 2016

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database open resetlogs upgrade;

Database altered.

Step 10 :- Run the required Upgrade scripts

 

 

REFERENCES

NOTE:2003327.1 - Restore From Windows To Linux using RMAN Fails