Deploy Oracle 18c Enterprise Edition or XE on Docker

  1. Download Oracle 18c XE from Oracles Website :
    https://www.oracle.com/database/technologies/xe-downloads.html
  2. Create Oracle Docker Project Directory

$ mkdir -p ~/oracle_docker

$ cd oracle_docker

$ git clone https://github.com/oracle/docker-images.git

$ cd docker-images

$ pwd
/Users/shadmha/oracle_docker/docker-images

$ cd ./OracleDatabase/SingleInstance/dockerfiles

  1. Copy the RPM downloaded for Oracle 18c from Oracle Website to 18.4.0 folder

$ cp ~/Downloads/oracle-database-xe-18c-1.0-1.x86_64.rpm ./18.4.0

$ pwd
/Users/shadmha/oracle_docker/docker-images/OracleDatabase/SingleInstance/dockerfiles

  1. Build the Oracle 18c XE Docker Image

$ sh buildDockerImage.sh -x -v 18.4.0

Checking Docker version.

DOCKER info:
Client:
Debug Mode: false
….
Successfully tagged oracle/database:18.4.0-xe

version: “3”
Oracle Database Docker Image for ‘xe’ version 18.4.0 is ready to be extended:

--> oracle/database:18.4.0-xe

Build completed in 752 seconds.

You will now have a docker image named oracle/database:18.4.0-xe which you can deploy to Docker as a container. The Oracle 18c XE image can be up-to 10GB so ensure you have the requisite space.

  1. Create a docker-compose.yml file and deploy the container
version: '3'
services:
 oracle:
 image: oracle/database:18.4.0-xe
 environment:
 - ORACLE_PWD=testing12345
 ports:
 - "11521:1521"

$ docker-compose up

Creating network “dockerfiles_default” with the default driver
Creating dockerfiles_oracle_1 … done
Attaching to dockerfiles_oracle_1

oracle_1 | Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
oracle_1 | The Oracle base remains unchanged with value /opt/oracle
oracle_1 | #########################
oracle_1 | DATABASE IS READY TO USE!
oracle_1 | #########################
oracle_1 | The following output is now a tail of the alert.log:
oracle_1 | Pluggable database XEPDB1 opened read write
oracle_1 | Completed: alter pluggable database XEPDB1 open

The process can take up-to 15-20 mins for the container to start

  1. Connect using SQL Developer to your Oracle Xe Docker DB

Username : sys
Password : testing12345
Role : SYSDBA

Hostname : localhost
Port : 11521
Service Name : XE

== Connect to the Pluggable DB part of Oracle XE ==

Username : sys
Password : testing12345
Role : SYSDBA

Hostname : localhost
Port : 11521
Service Name : XEPDB1

=================================================================================================

Docker Procedure for Enteprise Edition Oracle. Only change is in Steps 3,4,5,6

=================================================================================================

  1. Download and Build the Oracle 18c EE Docker Image
    == Enterprise Edition Oracle Database 18c 18.3.0 ==
    Download Enterprise Edition Oracle Database Binary from Oracle Website For eg: 18.3 Linux : https://www.oracle.com/database/technologies/oracle18c-linux-180000-downloads.html

$ cp -p ~/Downloads/LINUX.X64_180000_db_home.zip ~/oracle_docker/docker-images/OracleDatabase/SingleInstance/dockerfiles/18.3.0/

$ cd ..

$ sh buildDockerImage.sh -e -v 18.3.0

-e Flag to install Enterprise Edition

Checking Docker version.

DOCKER info:
….
Successfully built fda25b164cd4
Successfully tagged oracle/database:18.3.0-ee

Oracle Database Docker Image for ‘ee’ version 18.3.0 is ready to be extended:
–> oracle/database:18.3.0-ee
Build completed in 2265 seconds.

  1. Now the Image build has been completed, now time to deploy the Enterprise Edition Oracle DB Container

$ pwd
/Users/shadmha/oracle_docker/docker-images/OracleDatabase/SingleInstance/dockerfiles

$ mkdir oracle_ee_18c
$ cd oracle_ee_18c
$ vim docker-compose.yml

version: '3'
services:
oracle:
image: oracle/database:18.3.0-ee
environment:
- ORACLE_PWD=testing12345
ports:
- "11522:1521"

$ docker-compose up

Creating network “oracle_ee_18c_default” with the default driver
Creating oracle_ee_18c_oracle_1 … done
Attaching to oracle_ee_18c_oracle_1
oracle_1 | ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: testing12345

Database creation complete. For details check the logfiles at:
oracle_1 | /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
oracle_1 | Database Information:
oracle_1 | Global Database Name:ORCLCDB
oracle_1 | System Identifier(SID):ORCLCDB
racle_1 | #########################
oracle_1 | DATABASE IS READY TO USE!
oracle_1 | #########################
oracle_1 | The following output is now a tail of the alert.log:
oracle_1 | ORCLPDB1(3):CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
oracle_1 | ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
oracle_1 | ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE “USERS”
oracle_1 | ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE “USERS”
oracle_1 | 2020-02-16T04:47:06.581223+00:00
oracle_1 | ALTER SYSTEM SET control_files=’/opt/oracle/oradata/ORCLCDB/control01.ctl’ SCOPE=SPFILE;
oracle_1 | 2020-02-16T04:47:06.789543+00:00
oracle_1 | ALTER SYSTEM SET local_listener=” SCOPE=BOTH;
oracle_1 | ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
oracle_1 | Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE

  1. Connect with SQL Developer

Username : sys
Password : testing12345
Role : SYSDBA

Hostname : localhost
Port : 11522
Service Name : ORCLCDB

== Connect to the Pluggable DB part of Oracle 18c EE ==

Username : sys
Password : testing12345
Role : SYSDBA

Hostname : localhost
Port : 11522
Service Name : ORCLPDB1

=================================================================================================

=================================================================================================

Move Oracle Database 12c from On-Premise to AWS RDS Oracle Instance using SQL Developer

Amazon Web Services has been gaining popularity in the last few years since cloud computing has been in the spotlight. Slowly the Traditional Enterprises are making the journey to the cloud. Oracle is considered one of the most mission critical application in the Enterprise. Moving Oracle Database to cloud can bring its own benefits both from an operational and financial perspective.

In this exercise we will move an on-premise Oracle DB schema to an AWS RDS Instance running Oracle 12cR1

Pre-requisites :

1. You already have a source Oracle database installed

2. You know how to provision an AWS RDS Oracle Instance

3. You have access to both instances

4. You have basic understanding of AWS S3 and AWS console

5. You have the latest version of SQL Developer installed on your machine

Source DB:

Oracle 12cR1 (12.1.0.2) running on CentOS 7.1

Destination DB:

Oracle 12cR1 running on AWS RDS Instance

High Level Steps to Migrate:

1. Create the destination Oracle 12CR1 instance on AWS. It is one of the easiest things to provision an Oracle DB on AWS RDS

2.  Connect to Both Source(on-Prem) and Destination(AWS) Database from SQL Developer

3. Go to Tools > Database Copy and Select Source and Destination Databases

I prefer to do Tablespace Copy since most of the Apps i work reside in a single tablespace. But this depends on your choice. You can either chose Objects, Schemas or even entire Tablespaces to be copied across.

IMPORTANT : Make sure you have created the source schema in destination database before proceeding to next step else you will get an error “User does not exist”

In Destination AWS RDS run below commands

SQL> create user <source-schema-name> identified by <password123>;

SQL> grant dba to <source-schema-name>;

4. Start the Database Copy

5. Check from Performance Insights Console to Check whats happening in the background

6. Query the Destination Database to See if the Objects are valid and have arrived

SQL> select * from user_tables;

SQL> select * from dba_objects where status=’INVALID’;