Thursday, August 05, 2010

Restore RMAN from Lower to Upper Version




Is it possible to restore Oracle 9.2 RMAN backup with 10.2.0.4 version?

Actually, this is possible because RMAN can read from backupset files written by older versions. The same is true for patchset differences, 10.2.0.2 backupset can be used for a restore with RMAN 10.2.0.4. We can also restore 32-bit database backup set with 64-bit version. Of course, keep in mind that simply restoring older database with newer version doesn't give you "instant" upgraded database - 

All upgrade steps must be performed after a restore (yes, you'll have to read that manual, after all)


Refer to Metalink Note:369644.1 "Answers To FAQ For Restoring Or Duplicating Between Different Versions And Platforms". 

I tested 9.2->10.2 scenario by restoring 9.2.0.8 backupset with 10.2.0.4 RMAN.

-- Connecting to Oracle 9.2.0.8 (noarchivelog) database
Recovery Manager: Release 9.2.0.8.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: ORA9 (DBID=422058228)
using target database controlfile instead of recovery catalog

D:\Oracle>rman target / nocatalog
-- -------------------------------------
-- Clean shutdown
-- -------------------------------------
RMAN> shutdown

database closed
database dismounted
Oracle instance shut down


-- ------------------------------------
Mount the database.for the sake of simplicity I left 9i db in noarchivelog mode
-- ------------------------------------

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     705765992 bytes

Fixed Size                      455272 bytes
Variable Size                301989888 bytes
Database Buffers             402653184 bytes
Redo Buffers                    667648 bytes


-- --------------------------------------
-- Backup 9i database with 9i RMAN
-- --------------------------------------

RMAN> run {
2>  allocate channel d1 type disk;
3>  backup format 'D:\ORADATA\ORA9\BACKUP\%d_%t_%s_%p.bak' database;
4>  backup current controlfile format 'D:\ORADATA\ORA9\BACKUP\ctrl_%d_%u_%s.bak';
5>  release channel d1;
6> }

allocated channel: d1
channel d1: sid=11 devtype=DISK

Starting backup at 05.06.08
channel d1: starting full datafile backupset
channel d1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORADATA\ORA9\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORADATA\ORA9\UNDOTBS01.DBF
input datafile fno=00007 name=D:\ORADATA\ORA9\XDB01.DBF
input datafile fno=00006 name=D:\ORADATA\ORA9\USERS01.DBF
input datafile fno=00004 name=D:\ORADATA\ORA9\INDX01.DBF
input datafile fno=00003 name=D:\ORADATA\ORA9\DRSYS01.DBF
input datafile fno=00005 name=D:\ORADATA\ORA9\TOOLS01.DBF
channel d1: starting piece 1 at 05.06.08
channel d1: finished piece 1 at 05.06.08
piece handle=D:\ORADATA\ORA9\BACKUP\ORA9_656636859_7_1.BAK comment=NONE
channel d1: backup set complete, elapsed time: 00:01:15
Finished backup at 05.06.08
Starting backup at 05.06.08
channel d1: starting full datafile backupset
channel d1: specifying datafile(s) in backupset
including current controlfile in backupset
channel d1: starting piece 1 at 05.06.08
channel d1: finished piece 1 at 05.06.08
piece handle=D:\ORADATA\ORA9\BACKUP\CTRL_ORA9_08JI6V06_8.BAK comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 05.06.08
Starting Control File and SPFILE Autobackup at 05.06.08
piece handle=D:\ORACLE\ORA9\DATABASE\C-422058228-20080605-02 comment=NONE
Finished Control File and SPFILE Autobackup at 05.06.08

released channel: d1

-- ---------------------
-- Shutdown 9i instance
-- ---------------------

RMAN> shutdown

database dismounted
Oracle instance shut down
-- -----------------------------------------
-- Prepare 10g instance with which you'll
-- restore 9i backup (this step is out of
-- the scope of this note!)
-- -----------------------------------------

Prior to excecuting restore of 9i RMAN backup with 10g RMAN I took backup of 9i files and deleted them from original location. As shown below, there are no datafile in directory D:\ORADATA\ORA9 directory.

D:\ORADATA\ORA9>dir
Volume in drive D is SW
Volume Serial Number is 408C-7E40

Directory of D:\ORADATA\ORA9
05.06.2008  23:24  
         .
05.06.2008  23:24  
          ..
05.06.2008  23:08  
          BACKUP
05.06.2008  23:23  
          BACKUP9_ORIGINAL
               0 File(s)              0 bytes

And the RMAN backup directory contains:

D:\ORADATA\ORA9\BACKUP>dir
Volume in drive D is SW
Volume Serial Number is 408C-7E40

Directory of D:\ORADATA\ORA9\BACKUP

05.06.2008  23:08  
          .
05.06.2008  23:08  
          ..
05.06.2008  23:08         1.638.400 CTRL_ORA9_08JI6V06_8.BAK
05.06.2008  23:08       517.414.912 ORA9_656636859_7_1.BAK
               2 File(s)    519.053.312 bytes
               2 Dir(s)   4.094.455.808 bytes free

-- -----------------------------------------
Restore 9i backupset with 10g  (Note: I used 9i pfile to start 10g instance  that's what caused some warnings about obsolete parameters.)
-- -----------------------------------------

D:\Oracle>rman target / nocatalog
Recovery Manager: Release 10.2.0.4.0 - Production on Cet Jun 5 23:29:08 2008
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database (not started)

RMAN> startup nomount
Oracle instance started
Total System Global Area     683671552 bytes
Fixed Size                     1298592 bytes
Variable Size                276828000 bytes
Database Buffers             402653184 bytes
Redo Buffers                   2891776 bytes

-- -----------------------
-- Restore control file...
-- -----------------------

RMAN> run {
2>  allocate channel d1 type disk;
3>  restore controlfile from 'D:\ORADATA\ORA9\BACKUP\CTRL_ORA9_08JI6V06_8.BAK';
4>  release channel d1;
5> }

allocated channel: d1
channel d1: sid=157 devtype=DISK

Starting restore at 05.06.08

channel d1: restoring control file
channel d1: restore complete, elapsed time: 00:00:03
output filename=D:\ORADATA\ORA9\CONTROL01.CTL
output filename=D:\ORADATA\ORA9\CONTROL02.CTL
output filename=D:\ORADATA\ORA9\CONTROL03.CTL
Finished restore at 05.06.08

released channel: d1
-- ------------------------
-- Mount database...
-- ------------------------
RMAN> alter database mount;
database mounted

-- ------------------------
-- Restore database...
-- ------------------------

RMAN> run {
2>  allocate channel d1 type disk;
3>  restore database;
4> }

allocated channel: d1
channel d1: sid=157 devtype=DISK

Starting restore at 05.06.08

channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\ORADATA\ORA9\SYSTEM01.DBF
restoring datafile 00002 to D:\ORADATA\ORA9\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORADATA\ORA9\DRSYS01.DBF
restoring datafile 00004 to D:\ORADATA\ORA9\INDX01.DBF
restoring datafile 00005 to D:\ORADATA\ORA9\TOOLS01.DBF
restoring datafile 00006 to D:\ORADATA\ORA9\USERS01.DBF
restoring datafile 00007 to D:\ORADATA\ORA9\XDB01.DBF
channel d1: reading from backup piece D:\ORADATA\ORA9\BACKUP\ORA9_656636859_7_1.BAK
channel d1: restored backup piece 1
piece handle=D:\ORADATA\ORA9\BACKUP\ORA9_656636859_7_1.BAK tag=TAG20080605T230738
channel d1: restore complete, elapsed time: 00:01:25
Finished restore at 05.06.08
released channel: d1

-- ----------------------------
-- Open database with resetlogs
-- ----------------------------

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 06/05/2008 23:41:57
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-03114: not connected to ORACLE
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 06/05/2008 23:41:57
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option

This error is normal, since we're now running 9i database with 10g binaries,
so we'll still have to upgrade 9i to 10g...

-- ---------------------------------
-- Startup database in upgrade mode
-- ---------------------------------

D:\Oracle>sqlplus /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on Cet Jun 5 23:42:53 2008

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> connect / as sysdba
Connected to an idle instance.

SQL> startup upgrade;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.

Total System Global Area  683671552 bytes
Fixed Size                  1298592 bytes
Variable Size             276828000 bytes
Database Buffers          402653184 bytes
Redo Buffers                2891776 bytes
Database mounted.
Database opened.

-- ------------------------------------------
-- from here on you have to follow instructions from Oracle Upgrade Guide. Ie,
1.    Shut down the database as follows:
    SQL> SHUTDOWN IMMEDIATE

2.    Restart the database in UPGRADE mode:
    SQL> STARTUP UPGRADE

3.    Set the system to spool results to a log file for later verification of success:
    SQL> SPOOL upgrade.log

4.    Rerun catupgrd.sql:
    SQL> @catupgrd.sql
  
    5.  Rerun utlu112s.sql:
    SQL> @utlu112s.sql

No comments: