Tales From A Lazy Fat DBA

Den of an Oracle DB Performance freak & a fan of PostgreSQL & Cassandra …. \,,/

  • Likes

    • 149,227
  • Archives

  • Categories

  • Subscribe

  • Advertisements
  • Prashant Dixit is the FatDBA

  • Follow Tales From A Lazy Fat DBA on WordPress.com
  • My Twitter Feeds

  • Disclaimer!

    FatDBA or Oracle ‘Ant’ is an independent web-blog/site.The experiences, Test cases, views, and opinions expressed in this website are my own and does not reflect the views or opinions of my employer.

    This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content.
    Product and company names mentioned in this website may be the trademarks of their respective owners.

How to create a DOCKER Image for Oracle Database!

Posted by FatDBA on June 18, 2017

Hey Mates,
I am back! 🙂 🙂

I was little free this weekend hence i planned to wet my hands to containerize Oracle 12c R2 using DOCKER!
I have already tried few of the possibilities with Dockers lately but this is my first time to create an Image for an Oracle Database 12c inside a Docker Container and was able to do with quite ease.

Before i start with the steps/methods, i would like to explain little nitty gritty of Docker.

What is a Docker?
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer.

Now a question might be asked — Who needs Docker ?
Docker is a tool that is designed to benefit both developers and system administrators, making it a part of many DevOps (developers + operations) toolchains. For developers, it means that they can focus on writing code without worrying about the system that it will ultimately be running on. It also allows them to get a head start by using one of thousands of programs already designed to run in a Docker container as a part of their application. For operations staff, Docker gives flexibility and potentially reduces the number of systems needed because of its small footprint and lower overhead.

Let’s start with the steps to create docker for Oracle 12.2.0.1 EE database.

I tried this test on Oracle Linux 7.3 using Docker build files for the Oracle Database (You can download them from Docker website, Github etc.).

I have divided the entire exercise in Four pointers:
1. Pre Activities
2. Installation
3. Creation of Container and Images.
4. Post Checks & Test Cases.

STEP 1: Pre Activities

If your system is registered with ULN, disable access to the ol7_x86_64_UEKR3 channel and enable access to the ol7_x86_64_UEKR4 channel.
If you use the Oracle Yum repository, disable the ol7_UEKR3 repository and enable the ol7_UEKR4 repository in the /etc/yum.repos.d/public-yum-ol7.repo file, for example:

[ol7_UEKR3]
name=Latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux $releasever ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/UEKR3/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=0

[ol7_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

Run the following command to upgrade the system to UEK R4:

# yum update

Replaced:
PackageKit-device-rebind.x86_64 0:0.8.9-11.0.1.el7 adwaita-gtk3-theme.x86_64 0:3.8.4-3.el7 firefox.x86_64 0:31.4.0-1.0.1.el7_0
gdm-libs.x86_64 1:3.8.4-32.0.1.el7 gnome-settings-daemon-updates.x86_64 0:3.8.6.1-12.el7 iwl100-firmware.noarch 0:39.31.5.1-36.el7
iwl1000-firmware.noarch 1:39.31.5.1-36.el7 iwl105-firmware.noarch 0:18.168.6.1-36.el7 iwl135-firmware.noarch 0:18.168.6.1-36.el7
iwl2000-firmware.noarch 0:18.168.6.1-36.el7 iwl2030-firmware.noarch 0:18.168.6.1-36.el7 iwl3160-firmware.noarch 0:22.0.7.0-36.el7
iwl3945-firmware.noarch 0:15.32.2.9-36.el7 iwl4965-firmware.noarch 0:228.61.2.24-36.el7 iwl5000-firmware.noarch 0:8.83.5.1_1-36.el7
iwl5150-firmware.noarch 0:8.24.2.2-36.el7 iwl6000-firmware.noarch 0:9.221.4.1-36.el7 iwl6000g2a-firmware.noarch 0:17.168.5.3-36.el7
iwl6000g2b-firmware.noarch 0:17.168.5.2-36.el7 iwl6050-firmware.noarch 0:41.28.5.1-36.el7 iwl7260-firmware.noarch 0:22.0.7.0-36.el7
nautilus-open-terminal.x86_64 0:0.20-3.el7 obex-data-server.x86_64 1:0.4.6-6.el7 totem-mozplugin.x86_64 1:3.8.2-5.el7
xorg-x11-drv-modesetting.x86_64 0:0.8.0-13.el7 xorg-x11-glamor.x86_64 0:0.6.0-2.20140918git347ef4f.el7

Complete!

Reboot the system, selecting the UEK R4 kernel if this is not the default boot kernel.
# systemctl reboot

If you use the Oracle Yum repository, enable the ol7_addons repository in the /etc/yum.repos.d/public-yum-ol7.repo file, for example:

[root@fatdba ~]# vi /etc/yum.repos.d/public-yum-ol7.repo

[ol7_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

STEP 2: Installation:

[root@fatdba ~]# yum install docker-engine
Loaded plugins: langpacks, ulninfo
ol7_UEKR4 | 1.2 kB 00:00:00
ol7_addons | 1.2 kB 00:00:00
ol7_latest | 1.4 kB 00:00:00
(1/2): ol7_addons/x86_64/updateinfo | 30 kB 00:00:00
(2/2): ol7_addons/x86_64/primary | 71 kB 00:00:01
ol7_addons 232/232
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.12.6-1.0.3.el7 will be installed
--> Processing Dependency: docker-engine-selinux >= 1.12.6-1.0.3.el7 for package: docker-engine-1.12.6-1.0.3.el7.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.12.6-1.0.3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
docker-engine x86_64 1.12.6-1.0.3.el7 ol7_addons 19 M
Installing for dependencies:
docker-engine-selinux noarch 1.12.6-1.0.3.el7 ol7_addons 28 k

Transaction Summary
=============================================================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 19 M
Installed size: 79 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): docker-engine-selinux-1.12.6-1.0.3.el7.noarch.rpm | 28 kB 00:00:01
(2/2): docker-engine-1.12.6-1.0.3.el7.x86_64.rpm | 19 MB 00:00:34
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 563 kB/s | 19 MB 00:00:34
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-engine-selinux-1.12.6-1.0.3.el7.noarch 1/2
Installing : docker-engine-1.12.6-1.0.3.el7.x86_64 2/2
Verifying : docker-engine-selinux-1.12.6-1.0.3.el7.noarch 1/2
Verifying : docker-engine-1.12.6-1.0.3.el7.x86_64 2/2

Installed:
docker-engine.x86_64 0:1.12.6-1.0.3.el7

Dependency Installed:
docker-engine-selinux.noarch 0:1.12.6-1.0.3.el7

Complete!

With above step successfully completed, we are done with the docker installation. Before we start creating images on this container its best to modify the parameters as per our needs for applications or software’s. For example we have to modify the storage size for container (Default of 10GB), I have increased the size of the container to 20GB which will be quite enough for Oracle database 12c.

[root@fatdba ~]# vi /etc/sysconfig/docker-storage
[root@fatdba ~]# cat /etc/sysconfig/docker-storage
# This file may be automatically generated by an installation program.

# By default, Docker uses a loopback-mounted sparse file in
# /var/lib/docker. The loopback makes it slower, and there are some
# restrictive defaults, such as 100GB max storage.

# If your installation did not set a custom storage for Docker, you
# may do it below.

# Example: Use a custom pair of raw logical volumes (one for metadata,
# one for data).
# DOCKER_STORAGE_OPTIONS = --storage-opt dm.metadatadev=/dev/mylogvol/my-docker-metadata --storage-opt dm.datadev=/dev/mylogvol/my-docker-data

DOCKER_STORAGE_OPTIONS=--storage-opt dm.basesize=20G

Lets start the Docker via systemctl command.

[root@fatdba ~]#
[root@fatdba ~]# systemctl start docker
[root@fatdba ~]#

[root@fatdba ~]# ps -ef|grep docker
root 1984 1 0 16:59 ? 00:00:00 /usr/bin/dockerd --selinux-enabled --storage-opt dm.basesize=20G
root 1987 1984 0 16:59 ? 00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
root 2210 1799 0 17:04 pts/0 00:00:00 grep --color=auto docker

Lets verify if the size of the container; what we have modified in last step is reflecting now.

[root@fatdba ~]#
[root@fatdba ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.6
Storage Driver: devicemapper
Pool Name: docker-249:0-201730898-pool
Pool Blocksize: 65.54 kB
Base Device Size: 21.47 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 11.8 MB
Data Space Total: 107.4 GB
Data Space Available: 39.47 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp selinux
Kernel Version: 4.1.12-94.3.6.el7uek.x86_64
Operating System: Oracle Linux Server 7.3
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 974.3 MiB
Name: fatdba.localdomain
ID: ZUT5:J4TI:5BRZ:UQDM:5XMY:V4BS:VUDY:X7S6:3WT7:FPIA:SJ57:EHOY
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
127.0.0.0/8
[root@fatdba ~]#
[root@fatdba ~]#
[root@fatdba ~]#

I have already downloaded the Docker built files from dockers website and Oracle Database software from Oracle’s website.

[oracle@fatdba ~]$ ls -ltrh
total 3.3G
-rw-r--r--. 1 oracle oinstall 3.3G Mar 23 15:52 linuxx64_12201_database.zip
-rw-r--r--. 1 oracle oinstall 4.2M Jun 17 17:12 master.zip
[oracle@fatdba ~]$

Lets un compress the docker file.

[oracle@fatdba ~]$ unzip master.zip
Archive: master.zip
7db020b25ea9d603b2fa97ed850ef4b372c1821e
creating: docker-images-master/
extracting: docker-images-master/.gitattributes
inflating: docker-images-master/.gitignore
inflating: docker-images-master/.gitmodules
creating: docker-images-master/ContainerCloud/
inflating: docker-images-master/ContainerCloud/.gitignore
inflating: docker-images-master/ContainerCloud/README.md
creating: docker-images-master/ContainerCloud/imag
..................
........................
..............................

inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/21_start_managed_servers.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/22_start_webtier.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/23_start_webtier2.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/24_start_webtier_running.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/25_webtier_container_onmaster.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/26_call_sample.png
inflating: docker-images-master/OracleWebLogic/workshops/multihost/images/28_docker_rmi.png
inflating: docker-images-master/README.md

[oracle@fatdba ~]$ ls -ltrh
total 3.3G
-rw-r--r--. 1 oracle oinstall 3.3G Mar 23 15:52 linuxx64_12201_database.zip
drwxr-xr-x. 15 oracle oinstall 4.0K Jun 15 20:40 docker-images-master
-rw-r--r--. 1 oracle oinstall 4.2M Jun 17 17:12 master.zip

Now next we need to move/copy the database software to docker version directory. As we are doing for oracle database 12.2.0.1, lets move it to releavnt directory under docker home.

[oracle@fatdba ~]$ cp linuxx64_12201_database.zip docker-images-master/OracleDatabase/dockerfiles/12.2.0.1/

Step 3: Creation of Container and Images.
With all preparation is done, lets invoke the build docker script (buildDockerImage.sh).
There are few of the arguments which can be used for example -v for the version and -e for enterprise editions.

In order to communicate with the docker process from oracle user we need to sudo and run commands.

[oracle@fatdba dockerfiles]$ sudo ./buildDockerImage.sh -v 12.2.0.1 -e
[sudo] password for oracle:
Checking if required packages are present and valid...
linuxx64_12201_database.zip: OK
==========================
DOCKER info:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.6
Storage Driver: devicemapper
Pool Name: docker-253:0-69348515-pool
Pool Blocksize: 65.54 kB
Base Device Size: 21.47 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 11.8 MB
Data Space Total: 107.4 GB
Data Space Available: 32.52 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp selinux
Kernel Version: 3.10.0-514.21.1.el7.x86_64
Operating System: Oracle Linux Server 7.3
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 976.5 MiB
Name: fatdba.localdomain
ID: ZUT5:J4TI:5BRZ:UQDM:5XMY:V4BS:VUDY:X7S6:3WT7:FPIA:SJ57:EHOY
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
==========================
Building image 'oracle/database:12.2.0.1-ee' ...
Sending build context to Docker daemon 3.454 GB
Step 1 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
497341ef9d71: Pull complete
Digest: sha256:c5ead12c82851e6b316cbcabe8ddef18f42949484a0625b030ddbf726cc4bcdb
Status: Downloaded newer image for oraclelinux:7-slim
---> 0b44f4e6980d
Step 2 : MAINTAINER Prashant Dixit http://www.prashant.d.dixit.ericsson.com
---> Running in 46896f5576db
---> a914b944c9aa
Removing intermediate container 46896f5576db
Step 3 : ENV ORACLE_BASE /opt/oracle ORACLE_HOME /opt/oracle/product/12.2.0.1/dbhome_1 INSTALL_FILE_1 "linuxx64_12201_database.zip" INSTALL_RSP "db_inst.rsp" CONFIG_RSP "dbca.rsp.tmpl" PWD_FILE "setPassword.sh" PERL_INSTALL_FILE "installPerl.sh" RUN_FILE "runOracle.sh" START_FILE "startDB.sh" CREATE_DB_FILE "createDB.sh" SETUP_LINUX_FILE "setupLinuxEnv.sh" CHECK_SPACE_FILE "checkSpace.sh" CHECK_DB_FILE "checkDBStatus.sh" INSTALL_DB_BINARIES_FILE "installDBBinaries.sh"
---> Running in 34fba01bac8e
---> 8d660ec5fe0b
Removing intermediate container 34fba01bac8e
Step 4 : ENV INSTALL_DIR $ORACLE_BASE/install PATH $ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib CLASSPATH $ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
---> Running in ad3781a5a953
---> 483beb390a16
Removing intermediate container ad3781a5a953
Step 5 : COPY $INSTALL_FILE_1 $INSTALL_RSP $PERL_INSTALL_FILE $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
---> 4131886586e3
Removing intermediate container 4ac4ced73bf6
Step 6 : COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $ORACLE_BASE/
---> 2938c306b151
Removing intermediate container d5b3c7095bc1
Step 7 : RUN chmod ug+x $INSTALL_DIR/*.sh && sync && $INSTALL_DIR/$CHECK_SPACE_FILE && $INSTALL_DIR/$SETUP_LINUX_FILE
---> Running in f04b4d3ec11e
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 1:1.0.1e-60.el7_3.1 will be installed
--> Processing Dependency: make for package: 1:openssl-1.0.1e-60.el7_3.1.x86_64
............
.......................
---> Package libtevent.x86_64 0:0.9.28-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
openssl x86_64 1:1.0.1e-60.el7_3.1 ol7_latest 713 k
oracle-database-server-12cR2-preinstall
x86_64 1.0-2.el7 ol7_latest 18 k
tar x86_64 2:1.26-31.el7 ol7_latest 843 k
.........
..............
xz x86_64 5.2.2-1.el7 ol7_latest 228 k

Transaction Summary
================================================================================
Install 5 Packages (+109 Dependent packages)

Total download size: 43 M
Installed size: 129 M
Downloading packages:
--------------------------------------------------------------------------------
Total 584 kB/s | 43 MB 01:15
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libuuid-2.23.2-33.0.1.el7_3.2.x86_64 1/114
Installing : libblkid-2.23.2-33.0.1.el7_3.2.x86_64 2/114
Installing : tcp_wrappers-libs-7.6-77.el7.x86_64 3/114
..............
.........................
Installing : wget-1.14-13.el7.x86_64 114/114
Verifying : libXext-1.3.3-3.el7.x86_64 1/114
Verifying : libnfsidmap-0.25-15.el7.x86_64 2/114
Verifying : libXtst-1.2.2-2.1.el7.x86_64 3/114
Verifying : 2:ethtool-4.5-3.el7.x86_64 4/114
...............
.........................
Verifying : iputils-20160308-8.el7.x86_64 114/114

Installed:
openssl.x86_64 1:1.0.1e-60.el7_3.1
oracle-database-server-12cR2-preinstall.x86_64 0:1.0-2.el7

Dependency Installed:
GeoIP.x86_64 0:1.5.0-11.el7
acl.x86_64 0:2.2.51-12.el7
bind-libs.x86_64 32:9.9.4-38.el7_3.3
.................
............................
xorg-x11-utils.x86_64 0:7.5-14.el7
xorg-x11-xauth.x86_64 1:1.0.9-1.el7
xz.x86_64 0:5.2.2-1.el7

Complete!
Loaded plugins: ovl
Cleaning repos: ol7_UEKR4 ol7_latest
Cleaning up everything
---> 101bf83e6a49
Removing intermediate container f04b4d3ec11e

Step 8 : USER oracle
---> Running in 254ccd228112
---> 287e020fa0ed
Removing intermediate container 254ccd228112
Step 9 : RUN $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE
---> Running in 5469cd105f01
Archive: linuxx64_12201_database.zip
creating: database/
creating: database/sshsetup/
inflating: database/sshsetup/sshUserSetup.sh
creating: database/rpm/
inflating: database/rpm/cvuqdisk-1.0.10-1.rpm
.................
...........................
inflating: database/stage/install1.jar
inflating: database/runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB. Actual 16480 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1828 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-06-17_07-18-01PM. Please wait ...[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/opt/oracle/oraInventory/logs/installActions2017-06-17_07-18-01PM.log
The installation of Oracle Database 12c was successful.
Please check '/opt/oracle/oraInventory/logs/silentInstall2017-06-17_07-18-01PM.log' for more details.

As a root user, execute the following script(s):
1. /opt/oracle/oraInventory/orainstRoot.sh
2. /opt/oracle/product/12.2.0.1/dbhome_1/root.sh

Successfully Setup Software.

This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-linux-thread-multi

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

---> db1aebac731b
Removing intermediate container 5469cd105f01
Step 10 : USER root
---> Running in 40c84cd51204
---> dadbabb39b54
Removing intermediate container 40c84cd51204
Step 11 : RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh && rm -rf $INSTALL_DIR
---> Running in f290a72da88d
Changing permissions of /opt/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/oraInventory to dba.
The execution of the script is complete.
Check /opt/oracle/product/12.2.0.1/dbhome_1/install/root_3c014b3eef40_2017-06-17_20-43-44-737487272.log for the output of root script
---> 281e843af9d6
Removing intermediate container f290a72da88d
Step 12 : USER oracle
---> Running in 3bbff924c8fe
---> a6da7b879840
Removing intermediate container 3bbff924c8fe
Step 13 : WORKDIR /home/oracle
---> Running in 4ed5aa548eec
---> f081c5739e78
Removing intermediate container 4ed5aa548eec
Step 14 : VOLUME $ORACLE_BASE/oradata
---> Running in 6c808b5e0678
---> 0050ad20c1fe
Removing intermediate container 6c808b5e0678
Step 15 : EXPOSE 1521 5500
---> Running in 23a52c4ba0d4
---> fe2aa564cde9
Removing intermediate container 23a52c4ba0d4
Step 16 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in ca819e2f43d3
---> fb879885b6cf
Removing intermediate container ca819e2f43d3
Successfully built fb879885b6cf

Oracle Database Docker Image for 'ee' version 12.2.0.1 is ready to be extended:

--> oracle/database:12.2.0.1-ee

Build completed in 7290 seconds.

[oracle@fatdba dockerfiles]$

Alright, so the creation of the container is successfully completed with that last success message, it was created under 7290 seconds and the name of the image is 12.2.0.1-ee and with image id fb879885b6cf.
Lets conform the same using docker commands.

[root@fatdba /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 12.2.0.1-ee fb879885b6cf 4 hours ago 14.84 GB
oraclelinux 7-slim 0b44f4e6980d 2 weeks ago 114.4 MB

Now next step is to create Oracle database instance inside of this container and to start the same in the end. For that we have to run the ‘docker run’ command with few of the necessary arguments i.e. -p for port, –name which is to give any understandable name to the container,

[oracle@fatdba ~]$
[oracle@fatdba ~]$ sudo docker run -p 1521:1521 --name pdixit1 oracle/database:12.2.0.1-ee
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: fp7rcB5yT6w=1

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-JUN-2017 01:51:40

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/3546456aff5c/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 18-JUN-2017 01:51:42
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/3546456aff5c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
[WARNING] [DBT-10102] The listener configuration is not selected for the database. EM DB Express URL will not be accessible.
CAUSE: The database should be registered with a listener in order to access the EM DB Express URL.
ACTION: Select a listener to be registered or created with the database.
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
47% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 18 02:19:57 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
System altered.

SQL>
Pluggable database altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
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
2017-06-18T02:19:41.269624+00:00
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
ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2017-06-18T02:19:58.014477+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2017-06-18T02:20:03.021412+00:00
Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2017-06-18T02:23:27.637232+00:00
ORCLPDB1(3):Resize operation completed for file# 10, old size 358400K, new size 368640K

Great, we are done with the DB Instance creation. The message text “DATABASE IS READY TO USE” is the conformation that all went successfull.
Note: The other entries next to that OK message is the snippet from database alert log to show current status of the database.

Next we can try creating a new password for DB Image because if you remember the default password what docker created during ‘docker run’ command was little complicated “fp7rcB5yT6w=1“.

[oracle@fatdba ~]$ sudo docker exec pdixit1 ./setPassword.sh oracle90
The Oracle base remains unchanged with value /opt/oracle

SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 18 02:31:10 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
User altered.

SQL>
User altered.

SQL>
Session altered.

SQL>
User altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

STEP 4: “Post Checks & Test Cases”.

In order to see running containers, use docker ps:

[oracle@fatdba ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3546456aff5c oracle/database:12.2.0.1-ee "/bin/sh -c 'exec $OR" 51 minutes ago Up 13 minutes 0.0.0.0:1521->1521/tcp, 5500/tcp pdixit1
[oracle@fatdba ~]$

If you wonder what is going on inside the container, you can create a shell in it using the ‘docker exec’ command. This can not be done if the container is stopped, only if the container is running:
Unlike an attached start, a docker exec bash session can exit without interrupting the container.

[oracle@fatdba ~]$ sudo docker exec -ti pdixit1 bash
[oracle@3546456aff5c ORCLCDB]$ pwd
/opt/oracle/oradata/ORCLCDB

[oracle@3546456aff5c ORCLCDB]$ ls -ltr
total 2000808
drwxr-x---. 2 oracle oinstall 4096 Jun 18 01:57 pdbseed
-rw-r-----. 1 oracle oinstall 34611200 Jun 18 01:59 temp01.dbf
drwxr-x---. 2 oracle oinstall 4096 Jun 18 02:19 ORCLPDB1
-rw-r-----. 1 oracle oinstall 209715712 Jun 18 02:30 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Jun 18 02:30 redo03.log
-rw-r-----. 1 oracle oinstall 5251072 Jun 18 02:30 users01.dbf
-rw-r-----. 1 oracle oinstall 838868992 Jun 18 02:40 system01.dbf
-rw-r-----. 1 oracle oinstall 492838912 Jun 18 02:45 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 62922752 Jun 18 02:45 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 209715712 Jun 18 02:45 redo02.log
-rw-r-----. 1 oracle oinstall 18726912 Jun 18 02:46 control01.ctl

[oracle@3546456aff5c ~]$ . oraenv
ORACLE_SID = [] ? ORCLCDB
The Oracle base remains unchanged with value /opt/oracle
[oracle@3546456aff5c ~]$ !sql
bash: !sql: event not found
[oracle@3546456aff5c ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sun Jun 18 02:50:36 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select name, open_mode, log_mode from v$database;

NAME OPEN_MODE LOG_MODE
--------- -------------------- ------------
ORCLCDB READ WRITE NOARCHIVELOG

SQL>
SQL>
SQL>
SQL>
SQL> show user
USER is "SYS"
SQL> COLUMN name FORMAT A30
SQL> SELECT name, pdb FROM v$services ORDER BY name;

NAME PDB
------------------------------ --------------------------------------------------------------------------------------------------------------------------------
ORCLCDB CDB$ROOT
ORCLCDBXDB CDB$ROOT
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
orclpdb1 ORCLPDB1

SQL> alter session set container=orclpdb1;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
ORCLPDB1
SQL> show user
USER is "SYS"

SQL> create user dixit identified by oracle90;

User created.

SQL> grant connect, create session, grant create any table, alter any table, select any dictionary to dixit;

Grant succeeded.

SQL> conn dixit/oracle90@orclpdb1
Connected.
SQL>
SQL> show user
USER is "DIXIT"

SQL>
SQL> conn dixit/oracle90@orclpdb1
Connected.
SQL> CREATE TABLE DIXIT.WLSLOG(time_stamp VARCHAR2(45) PRIMARY KEY,category VARCHAR2(25),type VARCHAR2(25),servername VARCHAR2(25),code VARCHAR2(25),msg VARCHAR2(45));

Table created.

SQL> select * from tab;

TNAME
--------------------------------------------------------------------------------
TABTYPE CLUSTERID
------- ----------
WLSLOG
TABLE

Some more checks on this new DOCKER container.

[oracle@fatdba ~]$
[oracle@fatdba ~]$ sudo docker stats 3546456aff5c
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
3546456aff5c 0.70% 1.889 GiB / 2.889 GiB 65.40% 1.386 kB / 1.086 kB 1.326 GB / 88.57 MB 52
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
3546456aff5c 0.70% 1.889 GiB / 2.889 GiB 65.40% 1.386 kB / 1.086 kB 1.326 GB / 88.57 MB 52
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
3546456aff5c 0.69% 1.889 GiB / 2.889 GiB 65.40% 1.386 kB / 1.086 kB 1.326 GB / 88.6 MB 52
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
3546456aff5c 0.69% 1.889 GiB / 2.889 GiB 65.40% 1.386 kB / 1.086 kB 1.326 GB / 88.6 MB 52
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
3546456aff5c 0.39% 1.889 GiB / 2.889 GiB 65.40% 1.386 kB / 1.086 kB 1.326 GB / 88.6 MB 52
[oracle@fatdba ~]$
[oracle@fatdba ~]$

[oracle@fatdba ~]$
[oracle@fatdba ~]$ sudo docker top 3546456aff5c
[sudo] password for oracle:
UID PID PPID C STIME TTY TIME CMD
oracle 6399 6388 0 08:00 ? 00:00:00 /bin/bash /opt/oracle/runOracle.sh
oracle 6423 6399 0 08:00 ? 00:00:00 /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 6430 6399 0 08:00 ? 00:00:00 ora_pmon_ORCLCDB
oracle 6432 6399 0 08:00 ? 00:00:00 ora_clmn_ORCLCDB
oracle 6434 6399 0 08:00 ? 00:00:00 ora_psp0_ORCLCDB
oracle 6436 6399 0 08:00 ? 00:00:00 ora_vktm_ORCLCDB
oracle 6440 6399 0 08:00 ? 00:00:00 ora_gen0_ORCLCDB
oracle 6442 6399 0 08:00 ? 00:00:00 ora_mman_ORCLCDB
oracle 6446 6399 0 08:00 ? 00:00:00 ora_gen1_ORCLCDB
oracle 6450 6399 0 08:00 ? 00:00:00 ora_diag_ORCLCDB
oracle 6452 6399 0 08:00 ? 00:00:00 ora_ofsd_ORCLCDB
oracle 6456 6399 0 08:00 ? 00:00:00 ora_dbrm_ORCLCDB
oracle 6458 6399 0 08:00 ? 00:00:00 ora_vkrm_ORCLCDB
oracle 6460 6399 0 08:00 ? 00:00:00 ora_svcb_ORCLCDB
oracle 6462 6399 0 08:00 ? 00:00:00 ora_pman_ORCLCDB
oracle 6464 6399 0 08:00 ? 00:00:00 ora_dia0_ORCLCDB
oracle 6466 6399 0 08:00 ? 00:00:00 ora_dbw0_ORCLCDB
oracle 6468 6399 0 08:00 ? 00:00:00 ora_lgwr_ORCLCDB
oracle 6470 6399 0 08:00 ? 00:00:00 ora_ckpt_ORCLCDB
oracle 6472 6399 0 08:00 ? 00:00:00 ora_smon_ORCLCDB
oracle 6474 6399 0 08:00 ? 00:00:00 ora_smco_ORCLCDB
oracle 6476 6399 0 08:00 ? 00:00:00 ora_w000_ORCLCDB
oracle 6478 6399 0 08:00 ? 00:00:00 ora_reco_ORCLCDB
oracle 6480 6399 0 08:00 ? 00:00:00 ora_w001_ORCLCDB
oracle 6482 6399 0 08:00 ? 00:00:00 ora_lreg_ORCLCDB
oracle 6484 6399 0 08:00 ? 00:00:00 ora_pxmn_ORCLCDB
oracle 6488 6399 0 08:00 ? 00:00:01 ora_mmon_ORCLCDB
oracle 6490 6399 0 08:00 ? 00:00:00 ora_mmnl_ORCLCDB
oracle 6492 6399 0 08:00 ? 00:00:00 ora_d000_ORCLCDB
oracle 6494 6399 0 08:00 ? 00:00:00 ora_s000_ORCLCDB
oracle 6496 6399 0 08:00 ? 00:00:00 ora_tmon_ORCLCDB
oracle 6506 6399 0 08:00 ? 00:00:00 ora_tt00_ORCLCDB
oracle 6508 6399 0 08:00 ? 00:00:00 ora_tt01_ORCLCDB
oracle 6510 6399 0 08:00 ? 00:00:00 ora_tt02_ORCLCDB
oracle 6512 6399 0 08:00 ? 00:00:00 ora_aqpc_ORCLCDB
oracle 6516 6399 0 08:00 ? 00:00:00 ora_p000_ORCLCDB
oracle 6518 6399 0 08:00 ? 00:00:00 ora_p001_ORCLCDB
oracle 6520 6399 0 08:00 ? 00:00:00 ora_p002_ORCLCDB
oracle 6522 6399 0 08:00 ? 00:00:00 ora_p003_ORCLCDB
oracle 6526 6399 0 08:00 ? 00:00:00 ora_qm02_ORCLCDB
oracle 6530 6399 0 08:00 ? 00:00:00 ora_q002_ORCLCDB
oracle 6532 6399 0 08:00 ? 00:00:00 ora_q003_ORCLCDB
oracle 6745 6399 0 08:01 ? 00:00:01 ora_cjq0_ORCLCDB
oracle 6750 6399 0 08:01 ? 00:00:00 tail -f /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/alert_ORCLCDB.log
oracle 6869 6399 0 08:01 ? 00:00:00 ora_w002_ORCLCDB
oracle 6917 6399 0 08:02 ? 00:00:00 ora_w003_ORCLCDB
oracle 7058 6399 0 08:06 ? 00:00:00 ora_w004_ORCLCDB
[oracle@fatdba ~]$

Hope It Helps
Prashant Dixit

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: