Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).

Test Drive Multitenant Feature with Oracle 12C Enterprise Edition Docker Store Image

3 min read

At Dockercon last month, Oracle released  its flagship databases, middleware and developer tools into the Docker Store marketplace via the Docker Certification Program. What does it mean to developers like me? It means that now you can pull OFFICIAL images of Oracle products in Docker and quickly start developing, testing and deploying modern enterprise applications. Isn’t it cool?

The Docker Certification Program (DCP)  framework is gaining  a lot of attention among partners which is a single platform allowing them to integrate and certify their technology to the Docker EE commercial platform. As of today, Oracle published Oracle Instant Client, Oracle Java 8 SE (Server JRE), Oracle Coherence, Oracle Database Enterprise Edition & Oracle Linux. You can directly view the solutions offered under this link.

Docker_Store

 

Under this post, I will demonstrate how to get started with Oracle Database Enterprise Edition 12.1.0.2 in very simplified way:

Step-1:  Logging / Registering to Docker Store

You will need Dockerhub Account to login to Docker Store and pull Oracle Database EE Docker Image as shown below:

[simterm]

$sudo  docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don’t have a Docker ID, head over to https://hub.docker.com to create one.
Username (ajeetraina): ajeetraina
Password:
Login Succeeded
[root@pxemaster ~]#

[/simterm]

 

Step-2: Pulling Oracle Database Enterprise Docker Image

[simterm]

$sudo docker pull store/oracle/database-enterprise:12.1.0.2

[/simterm]

Let us verify once the image has been pulled:

ora1

Its 5.27 GB in size and hence might take long time based on your network connectivity.  I have pulled other Oracle products too as shown above.

Step-3:  Preparing Environment File

To create a database container, we need to use the environment file below to pass configuration parameters into container:

##——————————————————————
## Specify the basic DB parameters
##——————————————————————

## db sid (name)
## default : ORCL
## cannot be longer than 8 characters

DB_SID=OraDoc

## db passwd
## default : Oracle

DB_PASSWD=MyPasswd123

## db domain
## default : localdomain

DB_DOMAIN=my.domain.com

## db bundle
## default : basic
## valid : basic / high / extreme
## (high and extreme are only available for enterprise edition)

DB_BUNDLE=basic

## end

The above is just an example file. You can make changes accordingly. I have changed DB_DOMAIN, DB_SID and DB_PASSWD according to my infrastructure. Save the file by name “env”.

 

Step-4: Running the Oracle Database Enterprise Container

[simterm]
$sudo docker run -d --env-file env -p 1527:1521 -p 5507:5500 -it --name oracleDB --shm-size="12g" store/oracle/database-enterprise:12.1.0.2

[/simterm]

where,

env is the path to the environment file you created using above example.
1521 is the port on host machine to map the container’s 1521 port (listener port).
5500 is the port on host machine to map the container’s 5500 port (http service port).
oracledb is the container name you want to create.
12g is the memory size for the container to run. The minimum requirement is 4GB (–shm-size=”4g”).
store/oracle/database-enterprise:12.1.0.2 is the image that you use to create a container.

Step-5:  Verify that the oracleDB container is running or not:

[simterm]

$sudo docker ps

[/simterm]

oracle_1

As shown above, the container ID starting with d88 indicates Oracle Database container running.

“…We are not yet done. ..”

You can enter into the container and verify that Oracle Linux Server is the base image for this container.

ora112

 

Step-6:  Running the required script to start Oracle Database

The database setup and startup are executed by running “/bin/bash /home/oracle/setup/dockerInit.sh“, which is the default CMD instruction in the images. 

[simterm]

$docker exec -it <container_name> /bin/bash

[/simterm]

[simterm] 

[root@localhost ~]# docker exec -it d88 /bin/bash /home/oracle/setup/dockerInit.sh
User check : root.
Start up Oracle Database
Last login: Fri May 26 07:20:07 UTC 2017
Fri May 26 07:21:13 UTC 2017
start database
start listener
The database is ready for use .
Fri May 26 07:18:51 UTC 2017
User check : root.
Setup Oracle Database
Fri May 26 07:21:13 UTC 2017
User check : root.

Start up Oracle Database…

[/simterm]

This will take about 5 to 8 minutes to be up and running. You can check logs which are kept under /home/oracle/setup/log location.

You can verify log file placed under “/home/oracle/setup/log/setupDB.log“. If “Done ! The database is ready for use .” is shown, the database setup was successful.

Let us switch to oracle user and try testing the DB connectivity using SQLPLUS command:

oracle112

 

Multitenant: Connecting to Container Databases (CDB) & Pluggable Databases (PDB) 

If you are new to Oracle D12c, the multitenant option introduced in Oracle Database 12c allows a single container database (CDB) to host multiple separate pluggable databases (PDB). I couldn’t just wait to test this out & see how to connect to container databases (CDB) and pluggable databases (PDB).

By default, PDB1 gets automatically created during the database installation. You can check that through the below command:

pdb_oracle

The V$SERVICES views can be used to display available services from the database as shown below:

Let us see how to connect to one of the container database.

Before you connect to the container database, let us setup a user first:

[simterm]

SQL> create user raina identified by raina;

User created.

[/simterm]

 

[simterm]

SQL> grant dba to raina;

Grant succeeded.

[/simterm]

 

[simterm]

SQL> grant create session to raina;

Grant succeeded.

[/simterm]

 

[simterm]

SQL> grant connect to raina;

Grant succeeded.

[/simterm]

 

[simterm]

SQL> conn raina/raina@pdb1
Connected.
SQL>

[/simterm]

Follow the below commands to connect to PDB1 using the above user account:

[simterm]

SQL> ALTER SESSION SET container = pdb1;

[/simterm]

ora21

[simterm]

SQL> SHOW CON_NAME

[/simterm]

ora22

[simterm]

SQL> conn raina/raina@pdb1

[/simterm]

 

ora23

 

Hence, we are now connected to one of database container running inside Oracle Database Enterprise Edition.

In the future post, we will look how does Oracle Client Instant connect to Oracle Database Enterprise Docker container.

 

 

 

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server