top of page

Oracle Database Migration from Windows to Linux Using RMAN

Migrate Oracle databases with RMAN from Windows to Linux.

We all know that RMAN is a powerful tool for database backup, recovery, cloning and migration. In this article, we will be perform database migration from Windows to Linux using RMAN with two scenarios.


RMAN Windows to Linux Migration (same version)


In this scenario, we will be migrating Oracle database from Windows to Linux where both source and target database version are 12c.


Both source & target database version is same - 12c

In order to convert the database from one platform to another, the endian format of both databases should be the same. Let's check the v$transportable_platform view for both platforms

col platform_name for a35
set pagesize 1000
select * from v$transportable_platform order by 2;
rman windows to linux migration - v$transportable_platform

We can see from the output that both Windows and Linux are in the little-endian format. Open the source database is read-only mode

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

Use dbms_tdb.check_db function to check whether the database can be transported to a target platform

set serveroutput on
declare
v_return boolean;
begin
v_return:=dbms_tdb.check_db('Linux x86 64-bit');
end;
/

If nothing is returned, then it means that the database is ready to be transported to the destination platform. Execute below function to check for the existence of external objects, directories, and BFILEs

declare
v_return boolean;
begin
v_return:=dbms_tdb.check_external;
end;
/
rman windows to linux migration - check external objects inside database

Create pfile from spfile

create pfile from spfile;

Start RMAN conversion in SOURCE database

rman target /

convert database new database 'orcl' 
transport script 'c:\Clone\transport.sql' 
db_file_name_convert 'C:\app\piyus\oradata\orcl'
'c:\Clone' to platform 'Linux x86 64-bit';
rman windows to linux migration - rman convert source database for linux

Now copy the parameter file, transport.sql script, which is located at the $ORACLE_HOME/database directory, that is used to create the database and all datafiles to the destination host


Create dump directories on target host

cd $ORACLE_BASE
mkdir -p admin/orcl/adump admin/orcl/bdump
mkdir -p admin/orcl/cdump admin/orcl/udump
mkdir -p oradata/orcl/
mkdir -p fast_recovery_area/orcl    

Copy below files carefully from source to target host:

  • We have to copy all the datafile in oradata folder

  • Pfile to $ORACLE_HOME/dbs and

  • TRANSPORT.SQL to the /tmp

Edit the Pfile on target host and change the path of the below:

  • adump location

  • control_files locations

rman windows to linux migration - edit parameter file on linux

Edit the transportscript.sql file and change the locations of pdfile, redolog files and data files

rman windows to linux migration - transportscript.sql

Now set the ORACLE_SID to orcl, connect to sqlplus and run the transport script

SQL> @/tmp/TRANSPORT.SQL


RMAN Windows to Linux Migration (higher version)


In this scenario, we will be migrating Oracle database from Windows to Linux where both source database is 12c version and target database is 19c version.


Source database is 12c and target database is 19c version

In order to Clone the database from Windows 12c to Linux 19c we have to do the same as steps as we did above, we just need to edit the TRANSPORT.SQL and remove all the lines after STARTUP UPGRADE parameter

rman windows to linux migration higher version - oracle clone

Set the ORACLE_SID to orcl and run the script inside sqlplus

SQL> @/tmp/TRANSPORT.SQL

Our next steps is to upgrade the database to 19c

cd $ORACLE_HOME/rdbms/admin
$ORACLE_HOME/perl/bin/perl catctl.pl catupgrd.sql

This will take around takes about 40-50mins to upgrade 12c to 19c

rman windows to linux migration higher version - upgrade oracle database 19c enterprise
rman windows to linux migration higher version - upgrade oracle database 19c enterprise

Login to the sqlplus again and bounce the database and create spfile

create SPFILE from PFILE;

Run utlrp.sql script to re-compile invalid objects - if any

SQL> @?/rdbms/admin/utlrp.sql
rman windows to linux migration higher version - utlrp.sql

Wait for the script to complete and your database migration from Windows to Linux onto a higher version is done!



Further Read


Become a top notch dba with DBA Genesis
Start your DBA career today
bottom of page