Wednesday 1 August 2012

Cross-Platform Oracle Database Restore

The RMAN CONVERT DATABASE use to move database from one platform(HP-UX) to another platform(Solaris). The source and destination database must share the same enadian format. If source and destination are on different endian format then you can use cross transport tablespace. 
For example,

SQL>Select * from v$db_transportable_platform;

PLATFORM_ID PLATFORM_NAME                            ENDIAN_FORMAT
----------- ---------------------------------------- --------------
          1 Solaris[tm] OE (32-bit)                  Big
          2 Solaris[tm] OE (64-bit)                  Big
          6 AIX-Based Systems (64-bit)               Big
          3 HP-UX (64-bit)                           Big
          4 HP-UX IA (64-bit)                        Big
          9 IBM zSeries Based Linux                  Big
         16 Apple Mac OS                             Big
         18 IBM Power Based Linux                    Big

All of the above are sharing the same endian format (Big) then RMAN convert database can be used to move database among them. In my case I will be converting from HP-UX to Solaris 10.

Source ---> 11g on HP-UX.
Destination ---> 11g on Solaris 10.


Step 1.  Check Compatible parameter and it must be 10 or higher.
Step 2.  Open source database in read-only mode.
Step 3.  Check to see if source can be transported to destination platform.
Step 4.  Run RMAN CONVERT database command on source.
Step 5.  Copy transportscript, init.ora and datafiles created by RMAN convert to destination platform.
Step 6.  Make necessary changes to init.ora file at destination platform and run the transportscript. This will create controlfile and open the database in resetlogs. 


Let's start with Step 3.

Step 3. Check to see if source can be transported to destination platform

  
      DBMS_TDB.CHECK_DB checks to see if database can be transported to destination platform.

SQL> l
  1  declare
  2      db_ready boolean;
  3    begin
  4      db_ready := dbms_tdb.check_db('Solaris[tm] OE (64-bit)',
  5          dbms_tdb.skip_none);
  6    end;
  7*
SQL> /
Database is not open in READ-ONLY mode. Open the database in READ-ONLY mode and
retry.

PL/SQL procedure successfully completed.
Open the database in read-only mode and try again.

SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database open read only;

SQL> l
  1  declare
  2      db_ready boolean;
  3    begin
  4      db_ready := dbms_tdb.check_db('Solaris[tm] OE (64-bit)',
  5          dbms_tdb.skip_none);
  6    end;
  7*
SQL> /

PL/SQL procedure successfully completed.
No errors reported. Source is all set to run convert DB, make sure you have enough space to hold datafiles on source database server or ask administrator to give you a seperate mount point say ("/backup2").


Step 4.  Run RMAN CONVERT database command on source.

 - make sure all required directory exists (/backup2/convertdb).

$ rman taget /

RMAN> CONVERT DATABASE NEW DATABASE 'TEST'
2>         transport script '/backup2/convertdb/transportscript'
3>         to platform 'Solaris[tm] OE (64-bit)'
4>         db_file_name_convert '+DATA' '/backup2/convertdb' ;
Starting conversion at source at 27-APR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6596 device type=DISK
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=+DATA/TEST/datafile/system.311.781438167
converted datafile= "/backup2/convertdb/TEST/datafile/system.311.781438167"
...
...
...
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01

Edit init.ora file /u01/app/oracle/11.2.0/db/dbs/init_00n9gvp5_1_0.ora. This PFILE will be used to create the database on the target platform
Run SQL script /backup2/convertdb/transportscript on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 28-APR-12

You can open your source database in write mode now. 


Step 5.  Copy transportscript, init.ora and datafiles created by RMAN convert to destination platform

- You can use ftp, sftp or some other way to move these three set of files from source to destination.

 1. init.ora, in my case init.ora named as init_00n9gvp5_1_0.ora
 2. transportsript, in my case it was created under "/backup2/convertdb/" folder.
 3. database datafiles, in my case they are under ""/backup2/convertdb/TEST/datafile/"


Step 6.  Make necessary changes to init.ora file at target.

$cd  /u01/app/oracle/11.2.0/db/dbs/
$ mv init_00n9gvp5_1_0.ora initTEST.ora
$ export ORACLE_SID=TEST
$ sqlplus /nolog
SQL>@transportscript

This script will do following.

Startup nomount;
Create controlfile.
Add logfile groups.
Open the database in resetlogs.
Add tempfiles.

- If you are using ASM in target platform now next step would be to move these datafiles from /backup2 to ASM. Please look into my next blog "How to move datafiles from NON-ASM to ASM"

No comments:

Post a Comment