Oracle EE DB 11gR2 Docker Ubuntu 14.04

This blog is about the easiest way to get Oracle 11gR2 Enterprise Edition running on your Ubuntu 14.04 Desktop or Server edition (64-bit required) that I personally have ever used. In past I have used Oracle XE on Ubuntu, but the install is not totally straighforward, as described here. There is a good howto at Pythian for 11gR2 EE install on Ubuntu (albeit dated), but again it is not straightforward. In both cases, there are a number of tweaks needed to put it down on Ubuntu.

Linux Containers (e.g LXC and OpenVZ) show promise to liberate DBAs from install trickery for by putting DB's on Linux Containers.

In this example, Docker has an image that installs in minutes with very minimal steps, and that's putting it mildly. This is so easy it's scary. Admittedly, it's not an ASM database. Docker's motto at that home page in the link is " Build, Ship and Run Any App, Anywhere" and by "Any App" they also mean databases, including Oracle database. The database runs in a Docker container (appears to be the post-LXC type of Docker container which does not have a config.lxc file). The OS inside the container is CentOS release 6.5 (Final). Here are the steps to deploy it, use it, start it and stop it. There is a page by the contributor and builder of this container here.

Install Docker on Ubuntu 14.04 Desktop

Install the Docker software according to the instructions provided here at Liquid Web.

Pull the Container Image from Repository

gstanden@vmem1:~$ sudo docker run -d --name oracle -p 1521:1521 filemon/oracle_11g

[sudo] password for gstanden:

Unable to find image 'filemon/oracle_11g' locally

Pulling repository filemon/oracle_11g

ebbcc09572e9: Download complete

cff199166afa: Download complete

c29f45c80999: Download complete

89ccf38283f2: Download complete

e8e46c627452: Download complete

8ac02616f6bb: Download complete

c024b44bf80d: Download complete

397455b76b6d: Download complete

533cf3aead67: Download complete

b364984a8be5: Download complete

46725ee16b7d: Download complete

575efea48928: Download complete

256221da04ad: Download complete

26d1ad0421e9: Download complete

0df530cfa3c0: Download complete

e963ad7b5078de14b78e18e52bf0617ade5bd744b677b1cc1a92cd6930c7756e

Record the first 12 characters of the long string that is displayed at the bottom of the output at the very end of the container pull. In this case that string is e963ad7b5078. That string will be needed to start and stop the containerized Oracle 11gR2 (11.2.0.1.0) Enterprise Edition DB that is in the container.

Now on the host OS system (your laptop, desktop, server whatever) i.e. NOT inside the container, but on your "regular" running OS, check to see the database is running in the usual way, as shown below. It should be running at this point if everything went well with the container pull and installation step above. Both the database processes and the tns listener should be running, as shown below. Nice, huh? Database is already up and running, on Ubuntu (if you've ever worked with installing Oracle Enterprise Edition on Ubuntu, or even Oracle XE on Ubuntu (which is much easier), well, compared to that this is as easy as it ever gets, and all that has been done so far was to press a button basically. Nice.

gstanden@vmem1:~$ ps -ef | grep orcl

500 8751 8652 0 20:26 ? 00:00:00 ora_pmon_orcl

500 8753 8652 0 20:26 ? 00:00:00 ora_vktm_orcl

500 8757 8652 0 20:26 ? 00:00:00 ora_gen0_orcl

500 8759 8652 0 20:26 ? 00:00:00 ora_diag_orcl

500 8761 8652 0 20:26 ? 00:00:00 ora_dbrm_orcl

500 8763 8652 0 20:26 ? 00:00:00 ora_psp0_orcl

500 8765 8652 0 20:26 ? 00:00:00 ora_dia0_orcl

500 8767 8652 0 20:26 ? 00:00:00 ora_mman_orcl

500 8769 8652 0 20:26 ? 00:00:00 ora_dbw0_orcl

500 8771 8652 0 20:26 ? 00:00:00 ora_lgwr_orcl

500 8773 8652 0 20:26 ? 00:00:00 ora_ckpt_orcl

500 8775 8652 0 20:26 ? 00:00:00 ora_smon_orcl

500 8777 8652 0 20:26 ? 00:00:00 ora_reco_orcl

500 8779 8652 0 20:26 ? 00:00:00 ora_mmon_orcl

500 8781 8652 0 20:26 ? 00:00:00 ora_mmnl_orcl

500 8783 8652 0 20:26 ? 00:00:00 ora_d000_orcl

500 8785 8652 0 20:26 ? 00:00:00 ora_s000_orcl

500 8789 8652 0 20:26 ? 00:00:00 ora_p000_orcl

500 8791 8652 0 20:26 ? 00:00:00 ora_p001_orcl

500 8793 8652 0 20:26 ? 00:00:00 ora_p002_orcl

500 8795 8652 0 20:26 ? 00:00:00 ora_p003_orcl

500 8797 8652 0 20:26 ? 00:00:00 ora_p004_orcl

500 8799 8652 0 20:26 ? 00:00:00 ora_p005_orcl

500 8801 8652 0 20:26 ? 00:00:00 ora_p006_orcl

500 8860 8652 0 20:26 ? 00:00:00 ora_qmnc_orcl

500 8891 8652 0 20:26 ? 00:00:00 ora_cjq0_orcl

500 8913 8652 0 20:26 ? 00:00:00 ora_q000_orcl

500 8915 8652 0 20:26 ? 00:00:00 ora_q001_orcl

gstanden 8986 4323 0 20:30 pts/2 00:00:00 grep --color=auto orcl

gstanden@vmem1:~$

gstanden@vmem1:~$ ps -ef | grep tns

500 8707 8652 0 20:26 ? 00:00:00 /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr LISTENER -inherit

Install Oracle Instant Client

To connect to the database, a sqlplus client will be needed. The Oracle Instantclient works fine for this. Nice recent instructions at Ubuntu Community Documentation are described here. Follow those instructions they are very accurate. For completeness, those instructions at that link are basically:

Download the required RPM files from this link here. An Oracle Technology Network account will be needed. They are free and useful to have. Sign up then return to the download and download the RPM files anywhere. On Ubuntu by default the files will be downloaded to /home/username/Downloads which is fine. Once they are downloaded, convert these .rpm files into .deb packages and install using "alien" ("sudo apt-get install alien" if you don't have it). For example, for version 12.1.0.2.0-1 for Linux x86_64 (64-bit) as shown below.

alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

alien -i oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

alien -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

Configure Environment Variables

The environment variables needed were setup on this system as shown below. This is Ubuntu 14.04 Desktop Edition 64-bit. The actual directory paths of environment variables could be different for Oracle client depending on distro of Linux.

First create the /home/username/.bash_oracle file as shown below.

gstanden@vmem1:~$ cat .bash_oracle

#!/bin/bash

export ORACLE_HOME=/usr/lib/oracle/12.1/client64

export PATH=$PATH:$ORACLE_HOME/bin

export PATH=$PATH:/usr/lib/oracle/12.1/client64/lib

export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/

gstanden@vmem1:~$

Next edit the "/home/username/.bashrc" file as shown below adding the small stanza at the end of the .bashrc file.

# Oracle Instantclient

if [ -f ~/.bash_oracle ]; then

. ~/.bash_oracle

fi

Test Connectivity to Database

Logon to the database as shown below for both the "sys" user and the "system" user. The passwords as shown are the defaults set for this Oracle DB running in a Linux container.

gstanden@vmem1:~$ sqlplus system/admin@//vmem1.vmem.org:1521/orcl

SQL*Plus: Release 12.1.0.2.0 Production on Sun Sep 7 21:40:06 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME OPEN_MODE

--------- --------------------

ORCL READ WRITE

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

gstanden@vmem1:~$ sqlplus sys/admin@//vmem1.vmem.org:1521/orcl as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sun Sep 7 21:40:20 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME OPEN_MODE

--------- --------------------

ORCL READ WRITE

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

gstanden@vmem1:~$

Display Information About Running Container

The generic command to show information about running Docker containers is shown below, and the running Oracle DB container is listed. Notice it lists that container ID that was mentioned at the beginning of this post as needed for starting and stopping the DB, so if it got lost or was forgotten, it can be reaquired this way too.

gstanden@vmem1:~$ sudo docker ps

[sudo] password for gstanden:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

e963ad7b5078 filemon/oracle_11g:latest "bash -c 'sed -i -E About an hour ago Up 39 minutes 0.0.0.0:1521->1521/tcp oracle

gstanden@vmem1:~$

Start and Stop the Database

The database is managed from the main host OS in this case Ubuntu 14.04 (and NOT the container OS) using commands as shown below.

gstanden@vmem1:~$ sudo docker ps

[sudo] password for gstanden:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

e963ad7b5078 filemon/oracle_11g:latest "bash -c 'sed -i -E About an hour ago Up 39 minutes 0.0.0.0:1521->1521/tcp oracle

gstanden@vmem1:~$ sudo docker stop e963ad7b5078

e963ad7b5078

gstanden@vmem1:~$ ps -ef | grep orcl

gstanden 10924 4517 0 21:45 pts/14 00:00:00 grep --color=auto orcl

gstanden@vmem1:~$ ps -ef | grep tns

root 64 2 0 20:02 ? 00:00:00 [netns]

gstanden 10926 4517 0 21:45 pts/14 00:00:00 grep --color=auto tns

gstanden@vmem1:~$ sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

gstanden@vmem1:~$ sudo docker start e963ad7b5078

e963ad7b5078

gstanden@vmem1:~$ sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

e963ad7b5078 filemon/oracle_11g:latest "bash -c 'sed -i -E About an hour ago Up 6 seconds 0.0.0.0:1521->1521/tcp oracle

gstanden@vmem1:~$ ps -ef | grep tns

root 64 2 0 20:02 ? 00:00:00 [netns]

500 10999 10946 0 21:45 ? 00:00:00 /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr LISTENER -inherit

gstanden 11137 4517 0 21:46 pts/14 00:00:00 grep --color=auto tns

gstanden@vmem1:~$ ps -ef | grep orcl

500 11043 10946 0 21:45 ? 00:00:00 ora_pmon_orcl

500 11045 10946 0 21:45 ? 00:00:00 ora_vktm_orcl

500 11049 10946 0 21:45 ? 00:00:00 ora_gen0_orcl

500 11051 10946 0 21:45 ? 00:00:00 ora_diag_orcl

500 11053 10946 0 21:45 ? 00:00:00 ora_dbrm_orcl

500 11055 10946 0 21:45 ? 00:00:00 ora_psp0_orcl

500 11057 10946 0 21:45 ? 00:00:00 ora_dia0_orcl

500 11059 10946 0 21:45 ? 00:00:00 ora_mman_orcl

500 11061 10946 0 21:45 ? 00:00:00 ora_dbw0_orcl

500 11063 10946 0 21:45 ? 00:00:00 ora_lgwr_orcl

500 11065 10946 0 21:45 ? 00:00:00 ora_ckpt_orcl

500 11067 10946 0 21:45 ? 00:00:00 ora_smon_orcl

500 11069 10946 0 21:45 ? 00:00:00 ora_reco_orcl

500 11071 10946 1 21:45 ? 00:00:00 ora_mmon_orcl

500 11073 10946 0 21:45 ? 00:00:00 ora_mmnl_orcl

500 11075 10946 0 21:45 ? 00:00:00 ora_d000_orcl

500 11077 10946 0 21:45 ? 00:00:00 ora_s000_orcl

500 11088 10946 0 21:46 ? 00:00:00 ora_p000_orcl

500 11090 10946 0 21:46 ? 00:00:00 ora_p001_orcl

500 11092 10946 0 21:46 ? 00:00:00 ora_p002_orcl

500 11094 10946 0 21:46 ? 00:00:00 ora_p003_orcl

500 11096 10946 0 21:46 ? 00:00:00 ora_p004_orcl

500 11098 10946 0 21:46 ? 00:00:00 ora_p005_orcl

500 11100 10946 0 21:46 ? 00:00:00 ora_p006_orcl

500 11104 10946 0 21:46 ? 00:00:00 ora_qmnc_orcl

500 11135 10946 1 21:46 ? 00:00:00 ora_cjq0_orcl

gstanden 11139 4517 0 21:46 pts/14 00:00:00 grep --color=auto orcl

gstanden@vmem1:~$

That's it! Enjoy and use the Oracle 11gR2 Enterprise Edition running on Ubuntu 14.04 version 3.13.0-35 kernel (in this example).

Don't believe it's possible that it could be running on an Ubuntu kernel that easily ? Believe it, as shown below.

Linux containers always run on the same kernel as the container host because they are processes, not full virtualizations. It can be proven by logging in to the container which holds the database and running "uname -a" on both the host OS and insider the container (but this is always true by the definition of what Linux containers actually are).

gstanden@vmem1:~$ hostname

vmem1.vmem.org

gstanden@vmem1:~$ cat /etc/lsb-release

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=14.04

DISTRIB_CODENAME=trusty

DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"

gstanden@vmem1:~$ uname -a

Linux vmem1.vmem.org 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

gstanden@vmem1:~$ sudo docker run -i -t filemon/oracle_11g /bin/bash

bash-4.1$ hostname

8921a52a2b62

bash-4.1$ cat /etc/redhat-release

CentOS release 6.5 (Final)

bash-4.1$ uname -a

Linux 8921a52a2b62 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

bash-4.1$ exit

exit

gstanden@vmem1:~$