Gene's Notes

Being a DBA is just like being a rock star - except for the groupies, and the music, and the private jets. OK - it's not much like being a rock star.

Name:
Location: Columbus, GA, United States

Tuesday, May 19, 2009

RMAN Convert database

One of the nifty tools in RMAN is the Convert Database which lets you copy a database from one operating system to another. This allows you to migrate a database in very few steps from one OS to another, say from Solaris to AIX. No export/import, transportable tablespaces, or data base links. Just a simple rman command and start up the database in your new environment.
Here's how you do it:
  • First you have to verify that the source and destination platforms share the same endian format. (endian format relates to which bytes are most significant in multi-byte data-types). You can do this by running this select statement:
SQL> select PLATFORM_NAME, ENDIAN_FORMAT
2 from V$TRANSPORTABLE_PLATFORM;

  • Next, run DBMS_TDB to verify that there are no underlying problems that would stop the conversion:
SQL> set serveroutput on
SQL> declare
2 db_ready boolean;
3 begin
4 db_ready := dbms_tdb.check_db('Linux IA (32-bit)');
5 end;
6 /

PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> declare
2 external boolean;
3 begin
4 external := dbms_tdb.check_external;
5 end;
6 /
The following directories exist in the database:
SYS.DATA_PUMP_DIR

PL/SQL procedure successfully completed.


If you see no messages, you are good to go. Otherwise, take care of any warnings first.

  • Now, start RMAN and run the convert. This sample assumes we are moving from a Windows ASM on to a Linux environment:
>rman target / nocatalog

RMAN> CONVERT DATABASE NEW DATABASE 'LinDB10g'
2> TRANSPORT SCRIPT 'D:\oracle\oradata\dbTransport\transport.sql'
3> TO PLATFORM 'Linux IA (32-bit)'
4> DB_FILE_NAME_CONVERT '+DG_DATA/ora10g/datafile' 'D:\oracle\oradata\dbTransport';


The RMAN Convert creates the following:
a) A complete copy of the datafiles of the database, ready to be transported
b) A PFILE for use with the new database on the destination platform, containing settings used in the PFILE/SPFILE from the source database.
c) A transport script, which contains SQL statements used to create the new database on the destination platform.

  • Copy the files to the new system
  • Edit the init.ora file, and the transport script, to reflect your new environment
  • On your new server, make sure your ORACLE_HOME and ORACLE_SID are set to your new database
  • run sqlplus and do the conversion:
[oracle@test-br LinDB10g]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Feb 3 01:55:46 2007

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

Connected to an idle instance.

SQL> @TRANSPORT.SQL

You will get messages as the process procedes. If it is a large database, the process may take a couple of hours.
When the transport script finishes, the creation of the new database is complete.

  • I always add a spool command to the transport script. It's not in there by default, and it's always a good idea to have a log file of a process of this magnitude.
  • Be sure to do a basic health check and make sure things are OK.
  • Change any directories, external tables, bfiles, etc. to match to your new server
But - that is it. Fairly painless way to copy a database to a new operating system.