No great genius has ever existed without some touch of madness.

Friday 4 November 2011

CROSS PLATFORM TRANSPORT DATABASE USING RMAN


SOURCE DATABASE: TEST ON WINDOWS 32-BIT
TARGET DATABASE:  TEST ON centOS 5.5 32-BIT

Open the source database in read-only mode:::::::
SQL>alter database open read only;


SQL>select * from v$transportable_platform order by 2;
SQL> desc v$db_transportable_platform
 Name                                      Null?    Type
 ----------------------------------------- -------- --------------------------

 PLATFORM_ID                                        NUMBER
 PLATFORM_NAME                                      VARCHAR2(101)
 ENDIAN_FORMAT                                      VARCHAR2(14)

SQL> select * from v$db_transportable_platform;
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
          7
Microsoft Windows IA (32-bit)
Little
10
Linux IA (32-bit)
Little
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
          5
HP Tru64 UNIX
Little
         11
Linux IA (64-bit)
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
Little
         15
HP Open VMS
Little
          8
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
Microsoft Windows IA (64-bit)
Little
         13
Linux 64-bit for AMD
Little
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
         12
Microsoft Windows 64-bit for AMD
Little
         17
Solaris Operating System (x86)
Little
PLATFORM_ID
-----------
PLATFORM_NAME
------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
9 rows selected.











Start RMAN and connect to the source database as TARGET:::::
On another window:
C:\Documents and Settings\sagar.verma>set oracle_sid=test
C:\Documents and Settings\sagar.verma>rman
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Nov 4 12:13:10 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

RMAN> connect target;
connected to target database: TEST (DBID=2060060426)

Run the CONVERT DATABASE command::::::::
RMAN> convert database
2> new database 'newdb'
3> transport script 'C:\convertdb\transportscript.sql'
4> to platform 'Linux IA (32-bit)'
5> DB_FILE_NAME_CONVERT'D:\oracle\product\10.2.0\oradata\test' 'C:\convertdb';

Starting convert at 04-NOV-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
Directory SYS.DATA_PUMP_DIR found in the database
User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\SYSTEM.DBF
converted datafile=C:\CONVERTDB\SYSTEM.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\SYSAUX.DBF
converted datafile=C:\CONVERTDB\SYSAUX.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\UNDOTBS1.DBF
converted datafile=C:\CONVERTDB\UNDOTBS1.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Run SQL script C:\CONVERTDB\TRANSPORTSCRIPT.SQL on the target platform to create
 database
Edit init.ora file D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00MQQCRM_1_0.ORA.
 This PFILE will be used to create the database on the target platform
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target plat
form
To change the internal database identifier, use DBNEWID Utility
Finished backup at 04-NOV-11

RMAN>
1.     the command creates the files in the C:/convertdb/ directory on the source host. Move these files to the directory on the destination host that will contain the destination database files.
2.    If the path to the data files is different on the destination host, then edit the transport script to refer to the new data file locations.
3.    If necessary, edit the initialization parameter file to change any settings for the destination database.

These are the contents of my TRANSPORTSCRIPT.SQL
STARTUP NOMOUNT PFILE='/u01/oracle/product/10.2.0/db_1/dbs/INIT_00MQQCRM_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 32
    MAXLOGMEMBERS 2
    MAXDATAFILES 32
    MAXINSTANCES 16
    MAXLOGHISTORY 1752
LOGFILE
  GROUP 1 '/u01/oracle/oradata/test/ARCH_D-NEWDB_ID-2060060426_S-151_T-1_A-761913994_00MQQCRM'  SIZE 10M,
  GROUP 2 '/u01/oracle/oradata/test/ARCH_D-NEWDB_ID-2060060426_S-152_T-1_A-761913994_00MQQCRM'  SIZE 10M,
  GROUP 3 '/u01/oracle/oradata/test/ARCH_D-NEWDB_ID-2060060426_S-153_T-1_A-761913994_00MQQCRM'  SIZE 10M
DATAFILE
  '/u01/convertdb/SYSTEM.DBF',
  '/u01/ convertdb /UNDOTBS1.DBF',
  '/u01/ convertdb /SYSAUX.DBF'
CHARACTER SET AL32UTF8
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oracle/oradata/test/DATA_D-NEWDB_I-2060060426_TS-TEMP_FNO-1_00MQQCRM'
     SIZE 10485760  AUTOEXTEND OFF;
-- End of tempfile additions.
--

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID)
prompt *    or the global database name for this database. Use the
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE
STARTUP UPGRADE PFILE='/u01/oracle/product/10.2.0/db_1/dbs/INIT_00MQQCRM_1_0.ORA'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='/u01/oracle/product/10.2.0/db_1/dbs/INIT_00MQQCRM_1_0.ORA'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;

              NOW I CREATE DESIRED FOLDERS ON NY CENTOS 5.5 MACHINE
              adump at /u01/oracle/admin/test/
              bdump at /u01/oracle/admin/test/
              cdump at /u01/oracle/admin/test/
              udump at /u01/oracle/admin/test/
             Also transferred my pfile i.e INIT_00MQQCRM_1_0.ORA from windows m/c to linux m/c (with name   
             inittest.ora at location /u01/oracle/product/10.2.0/db_1network/admin/ with command
             bash-3.2$ mv INIT_00MQQCRM_1_0.ORA inittest.ora)
             and have changed the locations within inittest.ora .
 
            This is a view of my inittest.ora on centOS m/c
  control_files            = "/u01/oracle/oradata/test/CF_D-NEWDB_ID-2060060426_00MQQCRM"
  db_recovery_file_dest    = "/u01/oracle/flash_recovery_area/test"
  db_recovery_file_dest_size= 2147483648
  instance_name            = "TEST"
  audit_file_dest          = "/u01/oracle/admin/test/adump"
  background_dump_dest     = "/u01/oracle/admin/test/bdump"
  user_dump_dest           = "/u01/oracle/admin/test/udump"
  core_dump_dest           = "/u01/oracle/admin/test/cdump"
  db_name                  = "TEST"
 db_unique_name           = "TEST

Also, don’t forget to update the tns entries within tnsnames.ora on CentOS m/c .
Now,
Bash-3.2$ export ORACLE_SID=test
Bash-3.2$ sqlplus /nolog as sysdba
Sql>@/u01/convertdb/TRANSPORTSCRIPT.SQL
After running this script, startup the database with
Sql>startup upgrade;
And then run scripts:
utlirp.sql and then utlrp.sql