Forgot your password?    
+ Reply to Thread
Results 1 to 2 of 2

Thread: Database Migration From Windows to Linux Using RMAN

  1. #1
    Oracle DBA
    Join Date
    Nov 2011
    Posts
    1

    Database Migration From Windows to Linux Using RMAN

    This article describes the procedure to migrate a database from Windows to Linux using the "RMAN Convert Database" command.

    In my environment , both Windows and Linux platforms have the same endian format, which makes possible to transfer the whole database, making the migration process very straightforward and simple.

    To migrate between platforms that have a different endian format, Cross Platform Transportable Tablespaces needs to be used instead, which would not be discussed in this article.

    Endian Format is a term that describe the order, in which, sequence of bytes are stored in computer memory. There are 2 endian format named "Little Endian" and "Big Endian". Linux, Windows use "Little Endian" byte order whereas Solaris, HPUX, Apple Mac use "Big Endian" byte order.

    In Oracle 10g and onwards , following SQL should tell you which operating systems follow which byte order:

    select * from v$transportable_platform order by platform_id;

    The Windows Database:

    SQL> select * from v$version;

    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    SQL> select name from v$datafile;

    NAME
    ----------------------------------------------------
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DB F
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DB F

    SQL> select name from v$controlfile;

    NAME
    ----------------------------------------------------
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CT L
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CT L
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CT L


    SQL> select member from v$logfile;

    MEMBER
    ------------------------------------------------
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG



    List of Steps Needed to Complete the Migration:

    The migration process is simple, but as it has several steps it is convenient to be familiar with them before running it:

    1. Check platform compatibility between source and target OS
    2. Start the database in read only mode
    3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB
    4. Check if there are any external objects
    5. Execute the RMAN Convert database command
    6. Copy converted datafiles, generated Transport Script and Parameter File to Linux
    7. Edit the init.ora for the new database
    8. Edit the Transport Script and Parameter File changing the windows paths to Linux Paths
    9. Execute the Transport Script
    10. Change the Database ID
    11. Check database integrity

    1. Check platform compatibility between source and target OS:

    First we need to check the platforms to be sure they have the same endian format, also we need to save the
    PLATFORM_NAME string to use it later as part of the convert database syntax in RMAN.

    SQL> select * from v$transportable_platform where PLATFORM_NAME='Microsoft Windows IA (64-bit)' or PLATFORM_NAME like 'Linux%' order by platform_id;

    PLATFORM_ID PLATFORM_NAME ENDIAN_FOR
    ----------- ---------------------------------------- ----------
    8 Microsoft Windows IA (64-bit) Little
    10 Linux IA (32-bit) Little
    11 Linux IA (64-bit) Little
    13 Linux x86 64-bit Little


    2. Start the database in read only mode:

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


    3. Check database readiness for transport from Windows to Linux:

    Before converting the database, we have to be make sure that whether a database can be transported to a desired destination platform, and whether the current state of the database permits transport. We check this using "DBMS_TDB.CHECK_DB" procedure.

    If this procedure returns "FALSE" then the output includes the reason why the database cannot be transported like target platform has a different endian format, database is not open read-only, there are active transactions in the database, database compatibility version is below 10 etc.

    SQL> set serveroutput on
    SQL> declare
    2 db_ready boolean;
    3 begin
    4 db_ready := dbms_tdb.check_db('Linux IA (64-bit)');
    5 end;
    6 /
    PL/SQL procedure successfully completed.

    If database is not open in read-only mode, then the above procedure may return error like "Database is not open READ ONLY. Please open database READ ONLY and retry."


    4. Check if there are any external objects:

    If there is any external objects take note of them, they will need to be taken care manually because RMAN cannot automate the transport of such objects. "DBMS_TDB.CHECK_EXTERNAL" must be used to identify any external tables, directories or BFILEs.

    SQL> set serveroutput on
    SQL> declare
    2 external boolean;
    3 begin
    4 external := 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.DATA_PUMP_DIR, SYS.ORACLE_OCM_CONFIG_DIR, SYS.ADMIN_DIR, SYS.WORK_DIR,
    SYS.DATA_FILE_DIR, SYS.LOG_FILE_DIR, SYS.MEDIA_DIR, SYS.XMLDIR, SYS.SUBDIR
    The following BFILEs exist in the database:
    PM.PRINT_MEDIA

    PL/SQL procedure successfully completed.


    5. Using the RMAN CONVERT DATABASE Command:

    After all the pre-requisites have been performed successfully, we can use the RMAN CONVERT DATABASE command to generate the output files for the target database.

    While executing the CONVERT DATABASE command, we need to specify the new database name, the destination platform, path to save the transport script and optionally a path, where to save the output files using "DB_FILE_NAME_CONVERT". If you omit the "DB_FILE_NAME_CONVERT" clause, the output files are created in "$ORACLE_HOME\database" folder.

    If you are using Oracle Managed Files(OMF), then RMAN itself generate and display the new file names on the output of the convert database command.



    C:\Users\dell>rman target /

    RMAN> CONVERT DATABASE NEW DATABASE 'orcllnx'
    2> transport script 'C:\oracle\trans\script.sql'
    3> to platform 'Linux IA (64-bit)'
    4> db_file_name_convert 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\' 'C:\ORACLE\TRANS\';

    Starting convert at 09-JAN-12
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=158 devtype=DISK
    .
    .
    .
    User SYS with SYSDBA and SYSOPER privilege found in password file
    channel ORA_DISK_1: starting datafile conversion
    input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM0 1.DBF
    converted datafile=C:\ORACLE\TRANS\SYSTEM01.DBF
    channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
    .
    .
    .
    Run SQL script C:\ORACLE\TRANS\SCRIPT.SQL on the target platform to create database
    Edit init.ora file C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00N0BG 62_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 platform
    To change the internal database identifier, use DBNEWID Utility
    Finished backup at 09-JAN-12

    Note that at the end of the convert process RMAN does display information about how to complete the conversion on the target platform.

    You can use the init.ora file generated by the "CONVERT DATABASE" command or you can create your own pfile using the SQL statement "create pfile from spfile". I am going with the init.ora, generated by RMAN.


    6. Copy Converted Datafiles, Generated Transport Script and Parameter File to the Linux:

    Now copy these converted datafiles, transport script and parameter file on the Linux server using FTP or any other utility you use.

    Also create the necessary folders on Linux server for new database.

    [oracle]$ mkdir -p /u01/app/oracle/admin/orcllnx/adump
    [oracle]$ mkdir -p /u01/app/oracle/admin/orcllnx/bdump
    [oracle]$ mkdir -p /u01/app/oracle/admin/orcllnx/cdump
    [oracle]$ mkdir -p /u01/app/oracle/admin/orcllnx/udump
    [oracle]$ mkdir -p /u01/app/oracle/oradata/orcllnx
    [oracle]$ mkdir -p /u01/app/oracle/flash_recovery_area


    7. Edit init.ora for new database:

    Open the init.ora file generated by RMAN using a editor you preferred. You will notice that the init.ora file is divided into 3 sections as denoted by the following comment:

    # Please change the values of the following parameters:
    # Please review the values of the following parameters:
    # The values of the following parameters are from source database:

    The first section must be updated, others are optional. Change all the absolute path of windows environment to absolute path of Linux environment.
    8. Edit The Transport Script:

    Before running the transport script on the target Linux server we need to edit it to set the correct paths for pfile, datafiles, logfiles and tempfiles. Update all the paths as per your Linux environment.

    9. Execute the Transport Script:

    [oracle]$ export ORACLE_SID=orcllnx
    [oracle]$ sqlplus / as sysdba
    SQL> @script.sql

    On the completion of the script, the database would be open and ready for use.

    10. Change database identifier:

    DBNEWID is a database utility that can change the internal database identifier (DBID). It is run when the database is mounted.

    [oracle]$ sqlplus / as sysdba
    SQL> startup mount;
    SQL> exit

    [oracle]$ nid TARGET=/ # ORACLE_SID must be set

    After completing the above command, open the database with RESETLOGS option.

    [oracle]$ sqlplus / as sysdba
    SQL> startup mount;
    SQL> alter database open resetlogs;


    11. Check database integrity:

    SQL> select tablespace_name from dba_tablespaces;
    SQL> select file_name from dba_data_files;

    Checking component status after transport:

    SQL> SELECT COMP_NAME,STATUS FROM DBA_REGISTRY;
    Last edited by mamta; 01-11-2012 at 10:44 AM.

  2. #2
    Oracle DBA
    Join Date
    Oct 2011
    Posts
    11

    Thumbs up

    very nice job mums....

+ Reply to Thread

Similar Threads

  1. Interview Question related to Database migration
    By mdmasood in forum Database Installation,Upgrades,Migration,Patching and Cloning
    Replies: 0
    Last Post: 06-07-2012, 04:15 PM
  2. Setup auto start and shut of the Oracle database in linux
    By shoaibansari in forum Core Database Administration and Monitoring
    Replies: 0
    Last Post: 02-14-2012, 07:57 PM
  3. Mounting Windows Shares on Linux
    By mdmasood in forum Oracle Apps Patching and Cloning, Installation , Migration,Upgrades
    Replies: 1
    Last Post: 01-01-2012, 10:08 PM
  4. Duplicate Database using RMAN
    By Hemant in forum Backup, Restoration & Recovery, RMAN, Flashback, Datapump, Export, Import
    Replies: 0
    Last Post: 11-23-2011, 11:38 AM
  5. Clone Database using RMAN Duplicate Database Feature
    By Hemant in forum Database Installation,Upgrades,Migration,Patching and Cloning
    Replies: 0
    Last Post: 11-23-2011, 11:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

DBA Lounge (P) Ltd. deals in Oracle Technologies on Consulting, Resourcing, Corporate Training


Online and corporate training available on Oracle Database 11g, Oracle 11g Real Application Cluster (RAC), Oracle Applications 11i/R12, Oracle Fusion Middleware 11g, Oracle Identity Management-OIM, Oracle Internet Directory 11g-OID, Oracle Business Intelligence Enterprise Edition-OBIEE, Oracle Golden Gate, Oracle Access Management-OAM, Oracle Internet Directory-ODS, Oracle Identity Analytics Architecture-OIA Statistics