Easy Database Migration to Oracle Cloud Infrastructure OCI by Creating a Backup in the Cloud

Oracle has provided an updated OCI command line toolset with a new and easy method to migrate an on-premises database into the Oracle Cloud Infrastructure as DBaaS. According the document here, I have tried it out – and it works:

https://docs.cloud.oracle.com/iaas/Content/Database/Tasks/mig-onprembackup.htm

My Test Setup

  • Oracle 18c Enterprise Edition with SID=ORA18
  • Single Tenant Architecture
  • Oracle Linux 7.4
  • non TDE – Attention: non TDE on-premises data stays unencrypted in the cloud !!!

Database and Server Prerequisites

The OCI CLI Directory 

OCI CLI and opc_install.jar plus the .pem file have to be in the same directory.

oracle@ol7ora18:~/migrate/ [ORA18] ll
total 1828
drwxr-xr-x 7 oracle oinstall 4096 Nov 2 12:45 .
drwx------. 23 oracle oinstall 4096 Nov 2 12:45 ..
drwxr-xr-x 2 oracle oinstall 4096 Nov 1 09:34 bin
drwxr-xr-x 2 oracle oinstall 43 Nov 1 09:34 cx_Oracle-doc
drwxr-xr-x 2 oracle oinstall 23 Nov 1 09:33 include
drwxr-xr-x 3 oracle oinstall 23 Nov 1 09:33 lib
lrwxrwxrwx 1 oracle oinstall 3 Nov 1 09:33 lib64 -> lib
drwxr-xr-x 2 oracle oinstall 39 Nov 1 09:34 oci-cli-scripts
-rw------- 1 oracle oinstall 1679 Nov 2 12:36 oci_api_key.pem
-rw-r--r-- 1 oracle oinstall 944514 Jun 12 09:37 opc_install.jar
-rw-r--r-- 1 oracle oinstall 891380 Nov 2 12:35 opc_installer.zip
-rw-r--r-- 1 oracle oinstall 11093 May 7 17:27 opc_readme.txt
-rw-r--r-- 1 oracle oinstall 59 Nov 1 09:33 pip-selfcheck.json

Set Environment Variables

oracle@ol7ora18:~/ [ORA18] export AD=EUZg:EU-FRANKFURT-1-AD-2 
oracle@ol7ora18:~/ [ORA18] export C=ocid1.compartment.oc1..aaaaaaaaburam3rql3blnmxo123456789123456789abcdef 
oracle@ol7ora18:~/ [ORA18] rm -rf /home/oracle/migrate/onprem_upload 
oracle@ol7ora18:~/ [ORA18] cd /home/oracle/migrate/oci-cli-scripts

Execute the Database Migration Job

In the background:

  1. The script installs and configures temporarily the OPC Backup Module
  2. A RMAN backup job will be started with encrypted backups into the cloud on ObjectStorage
  3. After the successful backup, the temporarily created files are removed
oracle@ol7ora18:~/migrate/bin/ [ORA18] ./create_backup_from_onprem --config-file /home/oracle/.oci/config --display-name testimport01 --availability-domain $AD --edition STANDARD_EDITION --opc-installer-dir /home/oracle/migrate --tmp-dir /home/oracle/migrate/onprem_upload --compartment-id $C --rman-password welcome1
Connecting to Oracle database
Oracle version is:18.3.0.0.0
Checking the archive log mode of the database
Checking if the database is open
Getting database name and database unique name
Database Id:1281053557 Name:ORA18 UniqueName:ORA18
Fetching character set
Character Set:AL32UTF8
Fetching national character set
National Character Set:AL16UTF16
Fetching rac mode
Rac mode:FALSE
Creating external backup job resource...
Created external backup job resource with id: ocid1.dbbackup.oc1.eu-frankfurt-1.abcdefghijklmnopqrst1234567890
Creating external backup job resource...
Creating external backup job resource...
Waiting for completion of external backup job...
Uploading parameter logs
Setting up opc installer
Executing command: java -jar /home/oracle/migrate/opc_install.jar -host https://swiftobjectstorage.eu-frankfurt-1.oraclecloud.com/v1/dbbackupfra -opcId 'iyA7xeIeR3abcdefghIJ' -opcPass <redacted_password> -walletDir /home/oracle/migrate/onprem_upload -libDir /home/oracle/migrate/onprem_upload -configFile /home/oracle/migrate/onprem_upload/opcORA18.ora -container iyA7xeIeRabcdefghIJKl
Executing RMAN. It will take a few minutes to complete..
Completing the external backup job..
Response:200
External Backup created.

Created  Files for Backup and Transfer and the RMAN Logfile

oracle@ol7ora18:~/migrate/onprem_upload/ [rdbms18000] lr 
total 86268 
-rw-r--r-- 1 oracle oinstall 743 Nov 2 12:42 parameter.log 
-rw------- 1 oracle oinstall 0 Nov 2 12:43 cwallet.sso.lck 
-rw------- 1 oracle oinstall 1645 Nov 2 12:43 cwallet.sso 
-rw-r--r-- 1 oracle oinstall 206 Nov 2 12:43 opcORA18.ora 
-rw-r--r-- 1 oracle oinstall 16801 Nov 2 12:44 bulkimport.pl 
-rw-r--r-- 1 oracle oinstall 13730 Nov 2 12:44 odbsrmt.pl 
-rw-r--r-- 1 oracle oinstall 286 Nov 2 12:44 metadata.xml 
-rw-r--r-- 1 oracle oinstall 88215837 Nov 2 12:44 libopc.so 
-rw-r--r-- 1 oracle oinstall 40661 Nov 2 12:44 odbsrmt.pm 
-rw-r--r-- 1 oracle oinstall 11140 Nov 2 12:44 perl_readme.txt 
-rw-r--r-- 1 oracle oinstall 1118 Nov 2 12:44 rman.sql 
-rw-r--r-- 1 oracle oinstall 5205 Nov 2 12:44 rman.log

Excerpt from the rman.log

Well known from the Oracle Cloud Backup module .

Recovery Manager: Release 18.0.0.0.0 - Production on Fri Nov 2 12:44:03 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORA18 (DBID=1281053557)

RMAN> set echo on
2> set encryption on identified by * only;
3> run {
4> allocate channel odbms0 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
5> allocate channel odbms1 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
6> allocate channel odbms2 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
7> allocate channel odbms3 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
8> allocate channel odbms4 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
9> backup as compressed backupset database tag 'DBTLongterm1541159054034Zmg' format 'DBTLongterm1541159054034Zmg__%d_%I_%U_%T_%t' keep until time 'sysdate+29000' restore point 'DBTLongterm1541159054034Zmg';
10> }
11>
echo set on

executing command: SET encryption
using target database control file instead of recovery catalog

allocated channel: odbms0
channel odbms0: SID=274 device type=SBT_TAPE
channel odbms0: Oracle Database Backup Service Library VER=12.2.0.2

 

 

RMAN List Backup – Excerpt and Verification

The RMAN backup is encrypted by default.

Recovery Manager: Release 18.0.0.0.0 - Production on Fri Nov 2 12:44:03 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORA18 (DBID=1281053557)

RMAN> set echo on
2> set encryption on identified by * only;
3> run {
4> allocate channel odbms0 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
5> allocate channel odbms1 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
6> allocate channel odbms2 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
7> allocate channel odbms3 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
8> allocate channel odbms4 type sbt PARMS='SBT_LIBRARY=/home/oracle/migrate/onprem_upload/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/migrate/onprem_upload/opcORA18.ora)';
9> backup as compressed backupset database tag 'DBTLongterm1541159054034Zmg' format 'DBTLongterm1541159054034Zmg__%d_%I_%U_%T_%t' keep until time 'sysdate+29000' restore point 'DBTLongterm1541159054034Zmg';
10> }
11>

OCI Cloud Console the Backup called testimport is available to create a new DaBaaS Database

Listed as Standalone Backup.

Now we create a new database based on the Standalon Backup.

Enter the RMAN backup password from the CLI job.

The database will be re-created now.

CLI Error Messages

oracle@ol7ora18:~/migrate/oci-cli-scripts/ [ORA18] ./create_backup_from_onprem --config-file /home/oracle/.oci/config --display-name testimport01 --availability-domain $AD --edition STANDARD_EDITION --opc-installer-dir /home/oracle/migrate --tmp-dir /home/oracle/migrate/onprem_upload --compartment-id $C --rman-password *****
Connecting to Oracle database
Oracle version is:18.3.0.0.0
OMF is required for the script to work.
oracle@ol7ora18:~/migrate/oci-cli-scripts/ [ORA18] ./create_backup_from_onprem --config-file /home/oracle/.oci/config --display-name testimport01 --availability-domain $AD --edition STANDARD_EDITION --opc-installer-dir /home/oracle/migrate --tmp-dir /home/oracle/migrate/onprem_upload --compartment-id $C --rman-password *****
Connecting to Oracle database
Oracle version is:18.3.0.0.0
Checking the archive log mode of the database
Database should be in archivelog mode

Summary

The new CLI script makes OCI migrations much easier. than before. Depending on the database size and your network bandwith, it works smart and fast. Take time to read the manual carefully to fullfill the prerequisites,