Wednesday, July 1, 2020

Install Oracle Database 19c in docker container

9:07 PM Posted by Dilli Raj Maharjan , No comments



Docker is a set of platform as a service (PaaS) product that uses OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and therefore use fewer resources than virtual machines. The software that hosts the containers is called Docker Engine.  It was first started in 2013 and is developed by Docker, Inc.

All versions of Oracle databases are now available as a container in Oracle official Github.

Before starting the installation, install the Docker on your computer. I have already downloaded and installed Docker for Mac. Make sure your Docker app is up and running before start installation.

Following is the step by step guide to install Oracle Database 19c in a docker container.

Open URL https://github.com/oracle/docker-images in the browser and click on Clone.



Click on copy icon to copy the web URL.



Open terminal and change directory to one where you want to clone this git URL. 
Type git clone https://github.com/oracle/docker-images to clone docker images from Oracle.



Once docker files are fully cloned it displayes 100% done.



Change directory to docker-images. There are a lot of directories for Oracle software docker image files.
cd docker-images



Change Directory to OracleDatabase and SingleInstance. There is a directory for RAC also but we are installing the Single Instance Oracle 19c database. 
cd OracleDatabase
cd SingleInstance



Change directory to Dockerfiles and you will notice the database versions there. Change directory to 19.3.0 for Oracle 19c installation.
cd dockerfiles
cd 19.3.0



Download Oracle database version 19c from Oracle official site. Copy Oracle 19c source file to the current directory. Do not extract file over here. Just copy the compressed source file.
cp ~/Documents/Software/Oracle/Oracle_19c/LINUX.X64_193000_db_home.zip .


List all the available files on the directory. Validate Oracle19c source file has been copied successfully.



Select the content of db_inst.rsp response file. Use the following command to exclude blank lines and comments from the response file. We can see that only Oracle software will be installed. Oracle Base location, Oracle Home location, and Oracle Edition will be set via environment variables.
grep -v ^# db_inst.rsp | grep -v ^$



List the content of dbca.rsp.tmpl file. Use the command below to exclude blank lines and comments from the dbca response file. A container database with one pluggable database will be installed using this dbca response file. Pluggable database name, Oracle sid, and sys password will be set via environment variables.
grep -v ^# dbca.rsp.tmpl | grep -v ^$



Change directory to parent directory and execute buildDockerImage.sh executable binary with -v and -e option. Specify the version number with v option and -e for enterprise edition image.



Building Image in progress #####



Building Image in progress ###############



Once Oracle Software Installation is complete it will display the message as Successfully setup Software. Few pre-requisites before Oracle software installation failed so there are warning messages with the successful setup.



Finally Oracle image build is complete and tagged as name oracle/database:19.3.0-ee



Execute docker run to start docker container with Oracle 19c image. During its first run, it will create a database using dbca so it may take 15-20 min to complete dbca task. The following are the options used and their description. 

docker run \
--name oracle19c \
-p 1521:1521 \
-p 5500:5500 \
-e ORACLE_PDB=orcl \
-e ORACLE_PWD=password \
-e ORACLE_MEM=2000 \
-v /opt/oracle/oradata \
-d \
oracle/database:19.3.0-ee

run   : Command docker to run specified Image.
-p.    : Publish port in the form of local port:docker container port.
-e     : Set environment variable
-v     : Bind mount a volume
-d     : Detach. Run container in background and print container ID
oracle/database:19.3.0-ee : Name of image.



If you list the currently running docker container you may notice the health of the container is starting. The database creation process is in progress now.



While checking the docker log we can notice oracle dbca is in progress. Docker log can be checked from the command line as well as from the Docker dashboard. We can see dbca outputs in the docker log file.

Checking the docker log from the command line. We can noticed listener status and dbca ongoing.




Checking log via Docker GUI. We can notice database configuration is on progress.

Oracle 19c database configuration in progress. #####



Oracle 19c database configuration in progress. ##########



# Oracle Database installation complete.



Logged in to the container with the command below and check the listener status. We can notice the listener is up and running.
docker exec -it oracle19c /bin/bash


lsnrctl status


Provide username, password, Service Name, and click on Test. It will return success if the installation completes successfully.



 Now we can execute Oracle SQL commands in the SQLDeveloper workspace.

 


List current running docker containers.








docker ps



Stopping Docker container.


Starting Docker container.


Execute /bin/bash for docker container.



0 comments:

Post a Comment