Skip to content

Migration of On-Premises Oracle 18c PDB to OCI 19c PDB using Full Transportable Tablespace

Edson Edewor Aug 14, 2024 4:11:00 PM
Migration of On-Premises Oracle 18c PDB to OCI 19c PDB using Full Transportable Tablespace
4:55

Introduction

Migrating an Oracle database from on-premises to Oracle Cloud Infrastructure (OCI) involves several steps to ensure a smooth transition while minimizing downtime. The use of Full Transportable Tablespace is preferable for databases with small data. The procedure below covers the steps to migrate an on-premises Oracle 18c PDB to a 19c PDB on OCI. 

 

Stage 1 Install Oracle 18c on the centos7 operating system.

1. Download the Oracle pre-install and install binary packages using the below command

curl -o oracle-database-preinstall-18c-1.0-.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm                 

pdb

pdb2

pdb3

 

2. Execute the pre-install package using the below command as the root user.

yum -y localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

pdb4

pdb5

 

3. Install the Oracle database using the below command as the root user

yum -y localinstall oracle-database*18c*

pdb6

 

4. Configure the database using the below command.

/etc/init.d/oracle-xe-18c configure.

pdb7

 

5. Switch to the Oracle user and confirm that the XEPDB1 pluggable database has been created. 

pdb8

 

Stage 2. Create a DB System ocitarget virtual machine with a pluggable database PDB1.

pdb9

pdb10

pdb11

pdb12

 

6. Copy the contents of the id_rsa.pub of the on-premises VM into the authorized keys file of the oci target VM to enable passwordless connection.

pdb13

 

7. Connect to the OCI target from the Oracle on-premises VM using the below command.

pdb14

 

Stage 3. Migrate the XEPDB1 18c database to the 19c PDB1 database on the OCI

On-Premises

8. Create the Data Pump directory    # mkdir -p /opt/oracle/dumps

pdb15

 

9. Create directory dpump_dir as ‘/opt/oracle/dumps’;

pdb16

pdb17

 

10. #Create new tablespace testmig to be migrated to OCI.

SQL> create tablespace testmig datafile  ‘/opt/oracle/oradata/XE/XEPDB1/testmig01.dbf’ size 100m;

pdb18

 

11. #Create a migration user and grant quota on the new testmig tablespace to the miguser.

SQL> Create user miguser identified by  xxxxxxx quota 50M on testmig;

pdb19

 

 12. # Add some Data into the testmig tablespace

SQL> Create table miguser.job(Jobi’d number, job_name varchar2(100)) tablespace testmig;

SQL>  Insert into miguser.job values (101,’DBA’);

SQL> Insert into miguser.job values (102,’Data Scientist’);

SQL> Insert into miguser.job values (103,’AWS Solution Architect’);       

SQL> commit;

pdb20

 

13. #Make Tablespace read-only

SQL> alter tablespace testmig read-only;

pdb21

 

14. # Perform the full transportable export excluding USERS tablespace.

expdp system/xxxxxxx@oracleprem:1521/xepdb1 full=y transportable=always directory=dpump_dir
dumpfile=exp_full_tts.dmp logfile=exp_full_tts.log         exclude=tablespace:”IN(‘USERS’)”

pdb22

pdb23

 

15. Transfer the dump file and datafiles to the OCI target.

# scp -i /home/oracle/.ssh/id_rsa /opt/oracle/dumps/exp_ful_tts.dmp oracle@ocitargetIP:/u01/app/oracle/admin/export

# scp -i /home/oracle/.ssh/id_rsa /opt/oracle/oradata/XE/XEPDB1/testmig01.dbf      oracle@ocitargetIP:/u01/app/oracle/admin/export               

pdb24

pdb25

pdb26

 

16. Make the testmig tablespace read-write on the on-premises XEPDB1 database.

SQL> alter tablespace testmig read write; 

pdb27

 

OCI-DB System

17. Connect to the PDB1 database on the OCI DB System and create the directory.

# mkdir -p /u01/app/oracle/admin/export

SQL> create directory dpump_dir as ‘/u01/app/oracle/admin/export

pdb28

pdb29

 

18. Get the location of the PDB1 data files.

SQL> select file_name from dba_data_files;

pdb30

 

19. As a grid user run asmcmd and copy the datafile to the PDB1 datafile location

cp /u01/app/oracle/admin/export/testmig01.dbf    +DATA/DBMIG_PTV_YYZ/19EF3B5E56DC3E7BE0632100000AE0E3/DATAFILE/

pdb31

 

20. #Create the user on the destination environment PDB1

SQL> create user miguser identified by xxxxxxxx temporary tablespace temp;

SQL> grant create a session to miguser;

pdb32

 

21. Create an alias on the tnsnames.ora for the pdb1.sub06021948220.vndbmigration.oraclevcn.com service.

pdb33

 

22. Perform the full Transportable tablespace on the OCI PDB1 target.

 impdp system/xxxxxx@PDB1 directory=dpump_dir full=Y transport_Datafiles=’+DATA/DBMIG_PTV_YYZ/19EF3B5E56DC3E7BE0632100000AE0E3/DATAFILE/testmig01.dbf’  dumpfile=exp_full_tts.dmp

pdb34

 

23. Check the data after the full transportable space is completed.

pdb35

 

24. Connect to the PDB1 instance on the OCI and check if the source data was migrated.

pdb36

Leave a Comment