I had read a lot about transportable database but up until today didn't get a chance to try it out. Well today in the morning I was having coffee with my colleagues when suddenly topic of transportable database came up and I thought of giving it a go. So here's what I had and what I did.
Resource:
Well I had a PC and a laptop both running Windows and the username in both was Koenig. I had oracle 11g R1 installed on both of the system.
Target:
To transport the
orcl database from the PC to my laptop and rename it to
MYDB
Process:
Step 1: Check if the operating system to which you want to migrate is compatible with the source system operating system..
SQL> select platform_name from v$db_transportable_platform;
PLATFORM_NAME
-------------------------------------------------------------------------------
Microsoft Windows IA (32-bit)
Linux IA (32-bit)
HP Tru64 UNIX
Linux IA (64-bit)
HP Open VMS
Microsoft Windows IA (64-bit)
Linux 64-bit for AMD
Microsoft Windows 64-bit for AMD
Solaris Operating System (x86)
HP IA Open VMS
Solaris Operating System (AMD64)
Since both my source and target are of
Microsoft Windows IA (32-bit) hence I had little to worry about here.
Next I needed to identify the external tables, directories and BFILES that are part of the source database cause they need to be transported separately at a later time.
For that execute the following command:
SQL> set serveroutput on
SQL> declare x boolean;
2 begin x := dbms_tdb.check_external; end;
3 /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.MEDIA_DIR, SYS.IDR_DIR, SYS.SUBDIR,
SYS.XMLDIR, SYS.AUDIT_DIR, SYS.DATA_PUMP_DIR, SYS.ORACLE_OCM_CONFIG_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA
PL/SQL procedure successfully completed.
Identify the directory objects in the source system (PC) and created them in the target system(laptop).
For identifying the directory objects on the source system execute the command:
SQL> select directory_path from dba_directories;
DIRECTORY_PATH
-------------------------------------------------------------------------------
c:\app\koenig\diag\rdbms\orcl\orcl\ir
C:\app\Koenig\product\11.1.0\db_1\demo\schema\order_entry\/2002/Sep
C:\app\Koenig\product\11.1.0\db_1\demo\schema\order_entry\
C:\app\Koenig\product\11.1.0\db_1\demo\schema\log\
C:\app\Koenig\product\11.1.0\db_1\demo\schema\sales_history\
C:\app\Koenig\product\11.1.0\db_1\demo\schema\product_media\
/tmp/
C:\app\Koenig\admin\orcl\dpdump\
C:\app\Koenig\product\11.1.0\db_1\ccr\state
9 rows selected.
Then I ensured that the folders existed in the target system (laptop). To my surprise most of the folders were already there. I just had to create the following folders:
C:\app\Koenig\product\11.1.0\db_1\demo\schema\product_media\ /tmp/
C:\app\Koenig\admin\orcl\dpdump\
C:\app\Koenig\product\11.1.0\db_1\ccr\state
In order to identify the external tables execute the following sql query on the source (PC) system:
SQL> select directory_path || '\' || location External_file_path from dba_directories a, dba_external_locations b where a.directory_name=b.directory_name;
EXTERNAL_FILE_PATH
--------------------------------------------------------------------------------
C:\app\Koenig\product\11.1.0\db_1\demo\schema\sales_history\\sale1v3.dat
It is recommended to copy the files to the same location on the target system but since the file already existed on the target (laptop) system hence this was not needed.
Next step involved identifying which BFILE I need to migrate seperately. For this I used a script that I obtained from the net: and got the following output:
SQL> @"C:\Documents and Settings\Koenig\My Documents\tdb_get_bfile_dirs.sql"
The following directories contain external files for BFILE columns
Copy the files within these directories to the same path on the target system
C:\app\Koenig\product\11.1.0\db_1\demo\schema\product_media\
There are 1 directories, 4 total BFILEs
Since I couldn't locate the folder in the source system hence I didn't bother about copying them or transferring them to the laptop. (Will do R&D on product_media folder later).
P.S. I will post the tdb_get_bfile_dirs.sql script in another post but frankly it was of no use in this practice.
Before moving to the next step open the source database in read only mode as follows:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 535662592 bytes
Fixed Size 1334380 bytes
Variable Size 243270548 bytes
Database Buffers 285212672 bytes
Redo Buffers 5844992 bytes
Database mounted.
SQL> alter database open read only;
Next I needed to convert the database from source format to target format. Since the source and target were on the same operating system the only thing I needed to worry about was the database name. For this I executed the following RMAN operation on the source system:
C:\Documents and Settings\Koenig>rman
Recovery Manager: Release 11.1.0.6.0 - Production on Wed Nov 10 23:39:26 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: ORCL (DBID=1262344548)
RMAN> convert database
2> transport script 'c:\temp\transport_mydb.sql'
3> new database 'mydb'
4> to platform 'Microsoft Windows IA (32-bit)'
5> parallelism 4
6> format 'c:\temp\mydb'
7> db_file_name_convert 'C:\app\Koenig\oradata\orcl\','c:\stage\';
Starting conversion at source at 10-NOV-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=170 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=143 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=151 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=155 device type=DISK
External table SH.SALES_TRANSACTIONS_EXT found in the database
Directory SYS.IDR_DIR found in the database
Directory SYS.SUBDIR found in the database
Directory SYS.XMLDIR found in the database
Directory SYS.MEDIA_DIR found in the database
Directory SYS.LOG_FILE_DIR found in the database
Directory SYS.DATA_FILE_DIR found in the database
Directory SYS.AUDIT_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
BFILE PM.PRINT_MEDIA found in the database
User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=C:\APP\KOENIG\ORADATA\ORCL\UNDOTBS01.DBF
channel ORA_DISK_2: starting datafile conversion
input datafile file number=00001 name=C:\APP\KOENIG\ORADATA\ORCL\SYSTEM01.DBF
channel ORA_DISK_3: starting datafile conversion
input datafile file number=00002 name=C:\APP\KOENIG\ORADATA\ORCL\SYSAUX01.DBF
channel ORA_DISK_4: starting datafile conversion
input datafile file number=00005 name=C:\APP\KOENIG\ORADATA\ORCL\EXAMPLE01.DBF
converted datafile=C:\STAGE\UNDOTBS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:13
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=C:\APP\KOENIG\ORADATA\ORCL\USERS01.DBF
converted datafile=C:\STAGE\USERS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15
converted datafile=C:\STAGE\EXAMPLE01.DBF
channel ORA_DISK_4: datafile conversion complete, elapsed time: 00:00:34
converted datafile=C:\STAGE\SYSTEM01.DBF
channel ORA_DISK_2: datafile conversion complete, elapsed time: 00:01:23
converted datafile=C:\STAGE\SYSAUX01.DBF
channel ORA_DISK_3: datafile conversion complete, elapsed time: 00:01:20
Edit init.ora file C:\TEMP\INIT_MYDB.ORA. This PFILE will be used to create the
database on the target platform
Run SQL script C:\TEMP\TRANSPORT_MYDB.SQL on the target platform to create datab
ase
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 conversion at source at 10-NOV-10.
Since we are doing this on a windows to windows transport hence in the target system create an instance:
c:\> oradim --new -sid mydb
Then I copied the generated pfile from Temp folder of source to c:\app\Koenig\admin\MYDB\pfile' folder of target.
Next I made the following changes to the INIT_MYDB.ora:
control_files="c:\app\Koenig\oradata\MYDB\control01.ctl"
db_recovery_file_dest="c:\app\Koenig\flash_recovery_area"
audit_file_dest="c:\app\Koenig\admin\MYDB\adump"
Then I copied the TRANSPORT_MYDB.SQL file to a desired location and made the following changes:
In the Logfile section:
LOGFILE
GROUP 1 'C:\app\Koenig\oradata\log1' size 50M,
GROUP 2 'C:\app\Koenig\oradata\log2' size 50M,
GROUP 3 'C:\app\Koenig\oradata\log3' size 50M,
Finally on the target system I connected as the sysdba to the mydb instance:
c:\> set ORACLE_SID=mydb
c:\> sqlplus / as sysdba
and executed the copied TRANSPORT_MYDB.SQL script
SQL> @"C:\TRANSPORT_MYDB.SQL"
My database was created and ready.
Cheers!!!
For Reference:
http://www.oracle.com/technetwork/database/features/availability/maa-wp-10gr2-platformmigrationtdb-131164.pdf