The latest cloud infrastructure announcements, technical solutions, and enterprise cloud insights.

  • December 27, 2018

Migrate Oracle Database to Oracle Cloud Infrastructure by Using Storage Gateway

Niranjan Mohapatra
Principal 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.

      FORMAT '/mydb_backup/%d_D_%T_%u_s%s_p%p'
      FORMAT '/mydb_backup/%d_C_%T_%u'
      FORMAT '/mydb_backup/%d_S_%T_%u'
      FORMAT '/mydb_backup/%d_A_%T_%u_s%s_p%p';
  4. Copy the password file and TDE wallet files.

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

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';
    RMAN> alter database open resetlogs;
    SELECT open_mode from v$database;

    Note: Create an spfile by using the pfile.

Join the discussion

Comments ( 4 )
  • Raj Gupta Wednesday, January 2, 2019
    Thanks for details. I am having few questions.

    1- Do we have to setup two storage gateway separately at on premises and OCI cloud?

    2- Can we use the same for application server to copy log and other data from on premises to OCI cloud object storage? not only on time activity on daily basis as we have dependency with on premises applit data on OCI application...

    3- NFS mount point filesystem mounted in on premises and also in OCI is encrypted? Or customer has to encrypt before put there data in NFS share filesystem exposed by storage gateway?

    4- What machenism get used to sync or transferring the data from on premises NFS share mount to object storage... Specially what encryption and security during data in transit and data in rest ?

    Please help so we can utilize this feature of relevent.

    Thanks in advance for your help.

    Raj Gupta
  • Rajesh Kumar Wednesday, January 2, 2019
    Under "before you start" why do we need storage gateway to be configured both on prem and oci ?
    If on prem and oci is connected then just configure storage gateway at any side and then just mount the filesystem at both sides. Isn,t it ?
  • karthikeyan Nagalingam Thursday, January 10, 2019
    Nice Article. Keep rocking niranjan.
  • Manush Wednesday, January 23, 2019
    Nice post Niranjan Mohapatra.

    Could you please help me understand the reason(s) for choosing Storage gateway rather than using Cloud File system (Which is readily available)?

    Please ignore if this post is just to explain storage gateway concept.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha