Database Migration From Windows to Linux Using Rman In Oracle11g

Let us we discuss how to convert a database(Migrate) from Windows to Linux Platform,First we need to check both Machines are same endian format so I logged on oracle windows platform

S-1:

Windows Logon through Command (Cmd) Prompt


C:\>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 22 04:51:37 2016

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

Enter user-name: sys/oracle as sysdba
Connected to an idle instance.

 

S-2:

Start the database



  SQL> startup
ORACLE instance started.

Total System Global Area  631914496 bytes
Fixed Size                  1376436 bytes
Variable Size             218107724 bytes
Database Buffers          406847488 bytes
Redo Buffers                5582848 bytes
Database mounted.
Database opened.

 

S-3:

To find the Endian format


  SQL> col  platform_name for a25
SQL> set pages 100
SQL> select * from V$transportable_platform order by 2;

PLATFORM_ID    PLATFORM_NAME             ENDIAN_FORMAT
-----------   --------------------      --------------
          6     AIX-Based Systems (64-bit Big
            )

         16 Apple Mac OS              Big
         21 Apple Mac OS (x86-64)     Little
         19 HP IA Open VMS            Little
         15 HP Open VMS               Little
          5 HP Tru64 UNIX             Little
          3 HP-UX (64-bit)            Big
          4 HP-UX IA (64-bit)         Big
         18 IBM Power Based Linux     Big
          9 IBM zSeries Based Linux   Big
         10 Linux IA (32-bit)         Little
         11 Linux IA (64-bit)         Little
         13 Linux x86 64-bit          Little
          7 Microsoft Windows IA (32- Little
            bit)

          8 Microsoft Windows IA (64- Little
            bit)

         12 Microsoft Windows x86 64- Little
            bit

         17 Solaris Operating System  Little
            (x86)

         20 Solaris Operating System  Little
            (x86-64)

          1 Solaris[tm] OE (32-bit)   Big
          2 Solaris[tm] OE (64-bit)   Big

20 rows selected.




  

Note:Here Windows and Linux both 32 and 64 bit have same endian format

 

S-4:

check our current DB migration status



SQL> select platform_id,platform_name from V$database;

PLATFORM_ID        PLATFORM_NAME
---------------   -------------------------
          7      Microsoft Windows IA (32-bit)

 

S-5:

Then start our database in mount stage and use alter command read-only mode


SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area  631914496 bytes
Fixed Size                  1376436 bytes
Variable Size             218107724 bytes
Database Buffers          406847488 bytes
Redo Buffers                5582848 bytes
Database mounted.

SQL> alter database open read only;

Database altered.



 

S-6:

check transportable Status



SQL> set serveroutput on
SQL> declare
  2  v_return boolean;
  3  begin
  4  v_return:= dbms_tdb.check_db( 'Linux IA (32-bit)');
  5  end;
  6  /

PL/SQL procedure successfully completed.

Note: It doesn't return anything so our database transfer is correct

 

S-7:

To check external functions db is external tables or directories or files



  SQL> declare
  2  v_return boolean;
  3  begin
  4  v_return:= dbms_tdb.check_external;
  5  end;
  6  /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.SUBDIR, SYS.MEDIA_DIR, SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR,
SYS.SS_OE_XMLDIR, SYS.RAM_DIR, SYS.XMLDIR, SYS.DATA_PUMP_DIR,
SYS.ORACLE_OCM_CONFIG_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA

PL/SQL procedure successfully completed.


  

 

S-8:

create one folder in that name of a database using RMAN we can convert the entire database



  SQL>EXIT

C:\Users>rman

Logon to user
RMAN> connect target sys/oracle@tamil;

connected to target database: TAMIL (DBID=677725468)


 

S-9:

to convert the database



  RMAN> convert database new database 'str'
2> transport script 'c:\str\transport.sql'
3> db_file_name_convert 'E:\APP\RAMKRISH\ORACLE\ORADATA\TAMIL' 'c:\str'
4> to platform'Linux IA (32-bit)';

Starting conversion at source at 22-SEP-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=130 device type=DISK

External table SH.SALES_TRANSACTIONS_EXT found in the database

Directory SYS.RAM_DIR found in the database
Directory SYS.SUBDIR found in the database
Directory SYS.SS_OE_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.XMLDIR 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 data file file number=00001 name=E:\APP\ORACLE\ORADATA\TAMIL\SYSTE
M01.DBF
converted datafile=C:\STR\SYSTEM01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:02:54
channel ORA_DISK_1: starting datafile conversion
input data file file number=00002 name=E:\APP\ORACLE\ORADATA\TAMIL\SYSAU
X01.DBF
converted datafile=C:\STR\SYSAUX01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input data file file number=00005 name=E:\APP\ORACLE\ORADATA\TAMIL\EXAMP
LE01.DBF
converted datafile=C:\STR\EXAMPLE01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input data file file number=00003 name=E:\APP\ORACLE\ORADATA\TAMIL\UNDOT
BS01.DBF
converted datafile=C:\STR\UNDOTBS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input data file file number=00004 name=E:\APP\ORACLE\ORADATA\TAMIL\USERS
01.DBF
converted datafile=C:\STR\USERS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
Edit init.ora file E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\INIT_
00RGDVQQ_1_0.ORA. This PFILE will be used to create the database on the target p
platform
Run SQL script C:\STR\TRANSPORT.SQL on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
form
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 22-SEP-16

RMAN>exit


 

S-10:

Create pfile from spfile Current Windows database to ease edit parameter for Linux Environment


  SQL> create pfile from spfile;

File created.

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      E:\APP\ORACLE\PRODUCT
                                                 \11.2.0\DBHOME_1\DATABASE\SPFI
                                                 LETAMIL.ORA


(Note: Once We did convert the database in STR Folder create one separate folder "ConvertDB" in desktop and copy all those files from STR into ConvertDB )

 

S-11:

Now we take Linux OS on virtual Machine in a temp location creates the folder Test drag files from windows switch to ORACLE_HOME and create a directory


[oracle11g@oracle]$cd $ORACLE_HOME/admin
[oracle11g@oracle admin]$mkdir -p str
[oracle11g@oracle admin]$cd str
[oracle11g@oracle str]$mkdir -p adump bdump cdump udump

 

S-12:

Go to oradata folder



  [oracle11g@oracle str]$ cd  $ORACLE_BASE/oradata
[oracle11g@oracle oradata]$mkdir -p str

 

S-13:

now we have to all .DBF files into oradata folder


[oracle11g@oracle oradata]$cd /tmp/test/
[oracle11g@oracle test]$mv *.DBF /u01/app/oracle/product/11.2.0.3/oradata/str/

 

S-13:

edit the pfile and change the database name , path of the directories


[oracle11g@oracle test]$gedit pfile.ora
change database name and Adump location,$ORACLE_HOME

 

S-14:

edit the transportscript.sql file and change the location


[oracle11g@oracle test]$gedit transportscript.sql
startup nomount pfile='/tmp/test/pfile.ora '
Logfile group location ' '
Datafile location ' '
TEMp TABLESPACE Name ' temp01.dbf'
startup upgrade pfile='/tmp/test/pfile.ora '
startup pfile='/tmp/test/pfile.ora '


 

S-15:

now set the ORACLE_SID and run the script


[oracle11g@oracle test]$export ORACLE_SID=sam
[oracle11g@oracle test]$sqlplus '/as sysdba'

SQL>@TRANSPORT.SQL

Note: once you run the SQL It 'll create control files and redolog files

 

S-16:

Open another tab and check the Error to find no of invalid objects



  select count(*) from obj$ where status in (4,5,6);


  

 

NOTE: it automatically decreases once the script has been run it done now our database is ready

Source: Oracle,Google