Monday, August 5, 2024

Migration of on-premises Oracle 18c PDB to OCI 19c PDB using Full Transportable Tablespace.

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 preferrable 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                 



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

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




       3.  Install the oracle database using the below command as root user
                   yum -y localinstall oracle-database*18c*


     

                4. Configure the database using the below command.
                    /etc/init.d/oracle-xe-18c configure.  


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


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

               

1.                               

                   

              6Copy 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.                     

                                                                         

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


              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               

                                                                                                                                     


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



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

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

                  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;



                       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;


                  13.   #Make Tablespace read only

                      SQL> alter tablespace testmig read only;


                         

                      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')"

                  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               




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

                          SQL> alter tablespace testmig read write; 


         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

     

                      18.   Get the location of the PDB1 datafiles.

                      SQL> select file_name from dba_data_files;

               19.   As 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/


             20. #Create the user on the destination environment PDB1

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

                   SQL> grant create session to miguser;


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



                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

                                          

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


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














































Wednesday, July 17, 2024

How to enable Cloud Guard on an OCI Tenancy.

 

Introduction

Oracle Cloud Guard is a comprehensive security service on Oracle Cloud Infrastructure (OCI) designed to provide continuous monitoring, detection, and remediation of security threats. It helps organizations maintain a robust security posture by identifying potential vulnerabilities, misconfigurations, and suspicious activities across their OCI environment. Therefore, organizations are encouraged to enable Cloud Guard to ensure they maintain a proper security posture of their OCI tenancy.

This blog showcases the procedure to enable Cloud Guard on an OCI tenancy.

1. From the navigation menu, go to Identity and Security. Under Access Governance, click on Cloud Guard. The interface below will appear. Then, click on Enable Cloud Guard.


 2. If enabling Cloud Guard for the first time, you will be provided with a list of permissions to create a policy that allows Cloud Guard to manage resources on the tenancy. This must be done as the Administrator user



  3. Click Next, then you will be required to choose the region and indicate whether you will be enabling Cloud Guard for all compartments or a specific compartment. Create a detector recipe or choose the default detector recipe. Finally, choose the default activity recipe and click Enable.


 4.        Below is a screenshot of the security posture after enabling Cloud Guard on your tenancy.






Tuesday, June 4, 2024

How to create a CentOS 7 Virtual Machine on Windows using Vagrant

Vagrant is an open-source command-line tool for creating and managing virtual machine environments. Although virtualization can be time-consuming, especially with open-source software, using Vagrant and VirtualBox can help you virtualize more efficiently and save time.

In this blog, I have outlined the procedures to create a CentOS 7 virtual machine without the need for operating system installation procedures.


Pre-requisites

The following prerequisites must be met before proceeding with the steps to create a CentOS 7 virtual machine using Vagrant:

- VirtualBox installed on your Windows machine. 
- Windows 10/x64 operating system.

1. Download and execute the Vagrant 2.4.0 for windows from google.


 2. Accept the user license agreement and click next


3. Wait for the installation to complete




4. Create a directory to store the Vagrant files. 

I created a vagrant directory on C:\Users\workuser\.

5. Add the CentOS7 image to local Vagrant environment. 

Change to the newly created directory and execute "vagrant box add centos/7" to download the CentOS7 image. 


6. Run the Vagrant init command
This command initializes the CentOS7 image OS from the repository that has been downloaded in step 5.


7. Modify the vagrantfile 

Edit the newly created Vagrant File and add the following entry. Ensure that the IP address is in the same subnet as the network interface of your existing VirtualBox setup. Specify the desired hostname; in this demo, I have used "oracleprem" as the hostname of my VM. Also, indicate the provider and the amount of memory to be used.

                  

8. Update the /etc/hosts file with the IP address


9. Bring up the CentOS7 virtual machine. 

Execute "vagrant up" command from the command prompt to configure and startup the VM.


10. Confirm that the CentOS7 is running on the Virtualbox.

Check on the Virtual box interface and you will see the newly created CentOS7 virtual machine.

 

11. Confirm that the CentOS7 VM is reachable.

Ping the IP address of the newly created CentOS7 VM to confirm that it is reachable.


12. Connect to the CentOS7 Virtual Machine from command prompt. 

From the command prompt, run "vagrant ssh" to login to the newly created VM.


13. Switch to root user 

You can execute "sudo su –" from the vagrant user to switch to the root user. 



Fixing OCI Base DB GI Precheck Error DCS-10045 Caused by Metastore Duplication after OS Upgrade from Linux 7 to 8.

If you are upgrading an Oracle Cloud Infrastructure (OCI) Base Database Service operating system from Oracle Linux 7 to Oracle Linux 8, yo...