X
  • December 27, 2018

Migrate Oracle Database to Oracle Cloud Infrastructure by Using Storage Gateway

Niranjan Mohapatra
Solution Architect

This blog post outlines the process of migrating a single-instance Oracle Database from on-premises to the Oracle Cloud Infrastructure Database as a Service (DBaaS) instance. There are many other way to migrate an on-premises Oracle Database to the Oracle Cloud Infrastructure DBaaS instance. However, this blog post uses the Oracle Cloud Infrastructure Storage Gateway Service and Oracle RMAN utility to migrate an on-premises Oracle single-instance database to Oracle Cloud Infrastructure. 

Oracle Cloud Infrastructure Storage Gateway is a cloud storage gateway that lets you connect your on-premises applications with Oracle Cloud Infrastructure. Any application that can write data to an NFS target can also write data to Oracle Cloud Infrastructure Object Storage by using Storage Gateway, without requiring application modification.

At very high level, the OCI Storage Gateway and Object Storage are used to create an NFS share. The NFS share is mounted on the database host and offline full database backup is performed using the the Oracle RMAN utility to the NFS share. This backup copy is getting stored on Object Storage through the Storage Gateway. Restore the Oracle Database on the DBaaS instance using Oracle RMAN utility from Object Storage mounted through Storage Gateway, not the DBaaS host.

Before You Start

Before you start the database migration, consider the following requirements:

  • Ensure that Storage Gateway is already installed on a virtual or physical host in your on-premises data center as well as on Oracle Cloud Infrastructure.
  • Create the file system on the Storage Gateway host and map it to Object Storage.
  • Install the Cloud Backup Module on both the source and destination database.
  • Encrypt the backup by using RMAN (wallet or password based).
  • Create a manifest file for RMAN to know about the contents of backup set files (manifest.xml).
  • Consider a high-throughput network for Storage Gateway to reduce the latency.
  • Appropriately size the Storage Gateway cache for read and write operations.
  • Set up a strong password and share passwords with others only as needed.

Evaluate and Plan

Use the Evaluation and Planning Checklist to help you evaluate and plan for the migration of your on-premises Oracle Databases to Oracle Cloud Infrastructure, based on the unique requirements of your source and target databases. 

Back Up the Oracle Database to the NFS Share

Before starting the backup of the Oracle database, mount the file system that you created using Storage Gateway and export to the NFS share on the database host by using the appropriate NFSv4 mount options. Use the RMAN utility to create a full backup of the Oracle database to the NFS share as follows:

  1. Mount the file system on your database host.

    [root@db-host ~]# mount –t nfs –o vers=4,port=32769  <IP_of_storage_gateway>:/<filesystem_name>  /<local_directory>
    [root@db-host ~]# chown –R oracle:oinstall /<mount_directory>
    
  2. Connect to the source database, enable backup encryption, and set the compression to medium.

    [oracle@db-host ~]$ rman target /
    RMAN > set encryption on;
    RMAN > set compression algorithm 'medium';
    
  3. Perform a full database backup including controlfile and spfile.

    RUN
    {
    ALLOCATE CHANNEL ch11 DEVICE TYPE DISK MAXPIECESIZE 1G;
      BACKUP
      FORMAT '/mydb_backup/%d_D_%T_%u_s%s_p%p'
      DATABASE
      CURRENT CONTROLFILE
      FORMAT '/mydb_backup/%d_C_%T_%u'
      SPFILE
      FORMAT '/mydb_backup/%d_S_%T_%u'
      PLUS ARCHIVELOG
      FORMAT '/mydb_backup/%d_A_%T_%u_s%s_p%p';
      RELEASE CHANNEL ch11;
    }
    
  4. Copy the password file and TDE wallet files.

    [oracle@db-host ~]$cp $ORACLE_HOME/dbs/orapwdorcl 
    /mydb_backup/.
    [oracle@db-host ~]$ zip –rj   /mydb_backup/tde_wallet.zip
    /u01/app/oracle/admin/orcl/tde_wallet
    

Restore and Recover the Oracle Database on Oracle Cloud Infrastructure Database

Before starting the restore process, disconnect the file system from the on-premises Storage Gateway host and create a file system on Oracle Cloud Infrastructure Storage Gateway by using the same object storage.

  1. Create the target database in Oracle Cloud Infrastructure.

    To ensure that the target database has all the required metadata for Oracle Cloud Infrastructure tooling to work, create the target database by using one of the supported methods: Oracle Cloud Infrastructure Console, CLI, or Terraform provider. This target database will be cleaned to be used as a shell for the migration, as needed.

  2. Configure the Oracle Database Cloud Backup Module.

    Configuring the Cloud Backup Module for Existing or Fresh Backups provides an example of how to configure the Cloud Backup Module to point to the Object Storage backup bucket. For details, including variables and commands, see Installing the Oracle Database Cloud Backup Module.

  3. Shut down the database on Oracle Cloud Infrastructure and clean up the existing files.

    Delete the existing data files, temp files, redo log files, wallet file, and password file using the grid user and the oracle user.

    Note: Do not delete the parameter file.

  4. Create a local directory and mount the Storage Gateway file system on the database host.

    [opc@dbhost ~]$ sudo mount –t nfs –o vers=4,port=32769  <IP_of_storage_gateway>:/<filesystem_name>  /<local_directory>
    [opc@dbhost ~]$ sudo chown –R oracle:oinstall /<mount_directory>
    
  5. Copy the source password file and TDE wallet files at the target location.

    Use the oracle user to copy the password file and TDE wallet files from the NFS mount directory to the target location of the Oracle Cloud Infrastructure database host.

  6. Ensure that sqlnet.ora has the right ENCRYPTION_WALLET_LOCATION.

    cat $ORACLE_HOME/network/admin/sqlnet.ora
    
  7. Restore the database on the Oracle Cloud Infrastructure host by using the RMAN utility.

    Run the RMAN utility as the oracle user to restore and recover the database. Set the appropriate dbid and start up the instance to the nomount stage before restoring the database.

    [oracle@dbhost ~]$ rman target /
    RMAN>  startup nomountpfile=’$ORACLE_HOME/dbs/initorcl.ora’
    RMAN>  restore controlfile from ‘/mydb_backup/ORCL_C_xxxxxxx_xxxxx’;
    RMAN>  alter database mount;
    RMAN> catalog start with ‘/mydb_backup/ORCL’;
    RMAN> RUN {
      SET NEWNAME FOR DATAFILE 1 TO '+DATA/mydb/system01.dbf';
      SET NEWNAME FOR DATAFILE 2 TO '+DATA/mydb/sysaux01.dbf';
      SET NEWNAME FOR DATAFILE 3 TO '+DATA/mydb/undotbs01.dbf';
      SET NEWNAME FOR DATAFILE 4 TO '+DATA/mydb/users01.dbf';
      SET NEWNAME FOR DATAFILE 6 TO '+DATA/mydb/soe.dbf';
      RESTORE DATABASE;
      SWITCH DATAFILE ALL;
      RECOVER DATABASE;
    }
    RMAN> alter database open resetlogs;
    SELECT open_mode from v$database;
    

    Note: Create an spfile by using the pfile.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services