Docker Installation
Before you can consider creating an Oracle Database docker container you need to install Docker. If you yet to install Docker you can visit one of my previous posts Docker installation on Oracle Linux 7.2 to get started.
Oracle on Docker
Since last year Oracle have provided build files to assist in the creation of Oracle Database Docker images. Gerald Venzl produced an excellent Blog post Creating an Oracle Database Docker Image for Oracle 12.1.0.2, however now that Oracle 12.2.0.1 is available for on-premises I thought I would try and and create an Oracle 12.2.0.1 container.
Please note, before you start deploying Oracle on Docker it’s probably advisable to check the latest Oracle support position for running Oracle on Docker (see below)
Oracle Support Document 2216342.1 (Oracle Support for Database Running on Docker)
Applies To:
Oracle Database – Enterprise Edition – Version 12.1.0.2 and later
Oracle Database – Standard Edition – Version 12.1.0.2 and later
Linux OS – Version Oracle Linux 7.3 to Oracle Linux 7.3 [Release OL7U3]
Linux x86-64
Details
Oracle will support customers running Oracle Database (single instance) in Docker containers. Oracle will only provide support when running the database in Docker containers running on Oracle Linux and Red Hat RHEL. Supported versions of these Linux distributions are
- Oracle Linux 7
- Red Hat Enterprise Linux 7 (RHEL)
Oracle does not support Oracle Database running in a Real Application Clusters (RAC) configuration in Docker containers.
If your satisfied with your support position you will need the following:
The Oracle Database 12.2.0.1 zip file, which you can get from Oracle Technology Network and the Oracle Docker build files which you can download or clone from GitHub
For this Blog I am using my Vagrant managed Oracle Linux 7.3 Server
[vagrant@localhost ~]$ uname -r
4.1.12-61.1.28.el7uek.x86_64
[vagrant@localhost ~]$ cat /etc/oracle-release
Oracle Linux Server release 7.3
[vagrant@localhost ~]$ docker –version
Docker version 1.12.6, build ac13b2b
Preparation
If you plan to run the docker container out of an Oracle OS account you can use the oracle-database-server-12cR2-preinstall package to create your OS accounts and groups if missing.
I then edited the /etc/sysconfig/docker-storage file adding the following entry to increase the storage space available to my container.
DOCKER_STORAGE_OPTIONS=–storage-opt dm.basesize=20G
As my Vagrant VirtualBox OL73 server had a small root file system I added another 40G disk via VirtualBox for my Docker image via the loopback storage mounting at /var/lib/docker as this is where Docker will create the container file systems.
e.g.
service docker stop
fdisk /dev/sdb
mkfs.xfs /dev/sdb1
cd /var/lib
rm -Rf docker
mkdir docker
mount /dev/sdb1 /var/lib/docker
service docker start
To allow to Oracle to sudo and run docker commands I then added oracle to the /etc/sudoers file.
e.g.
visudo
oracle ALL = NOPASSWD: ALL
You can now switch user to oracle (su – oracle) and download the Oracle build files and database zip file if you have not already obtained them
[oracle@localhost ~]$ wget https://github.com/oracle/docker-images/archive/master.zip
[oracle@localhost ~]$ unzip master.zip
[oracle@localhost ~]$ cd docker-images-master/OracleDatabase/dockerfiles/12.2.0.1/
Now copy linuxx64_12201_database.zip from its download location to the 12.2.0.1 directory.
Oracle Docker image creation
Usage: buildDockerImage.sh -v [version] [-e | -s | -x] [-i]
Builds a Docker Image for Oracle Database.Parameters:
-v: version to build
Choose one of: 11.2.0.2 12.1.0.2 12.2.0.1
-e: creates image based on ‘Enterprise Edition’
-s: creates image based on ‘Standard Edition 2’
-x: creates image based on ‘Express Edition’
-i: ignores the MD5 checksums* select one edition only: -e, -s, or -x
[oracle@localhost 12.2.0.1]$ cd ..
[oracle@localhost dockerfiles]$ sudo ./buildDockerImage.sh -v 12.2.0.1 -e
Checking if required packages are present and valid…
linuxx64_12201_database.zip: OK
==========================
DOCKER info:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 6
Server Version: 1.12.6
Storage Driver: devicemapper
Pool Name: docker-8:17-134299776-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: 3.62 GB
Data Space Total: 107.4 GB
Data Space Available: 35.81 GB
Metadata Space Used: 2.535 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.145 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-09-28)
Logging Driver: json-file
…
==========================
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
33a3a5e469a8: Pull complete
Digest: sha256:f3a78afd456061bb897b9f2b54b568dec3973efccf2b086d602fabb94069fb6d
Status: Downloaded newer image for oraclelinux:7-slim
—> f005b5220b05
Step 2 : MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
—> Running in 64041116d1b3
—> 7cf919c3ab70
Removing intermediate container 64041116d1b3
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” INSTALL_DB_BINARIES_FILE “installDBBinaries.sh”
—> Running in 25142567c49e
—> 35ff7ea319fa
Removing intermediate container 25142567c49e
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 2b0c17414781
—> 1eb28b0769f2
Removing intermediate container 2b0c17414781
Step 5 : COPY $INSTALL_FILE_1 $INSTALL_RSP $PERL_INSTALL_FILE $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
—> aff425e9295c
Removing intermediate container 8f310fa167cf
Step 6 : COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $ORACLE_BASE/
—> 30a46bcfb092
Removing intermediate container 392cda966aaf
Step 7 : RUN chmod ug+x $INSTALL_DIR/*.sh && sync && $INSTALL_DIR/$CHECK_SPACE_FILE && $INSTALL_DIR/$SETUP_LINUX_FILE
—> Running in ce2d69a6fc72
Loaded plugins: ovl
Resolving Dependencies
…
Complete!
Loaded plugins: ovl
Cleaning repos: ol7_UEKR4 ol7_latest
Cleaning up everything
—> 4cc34d72a3be
Removing intermediate container ce2d69a6fc72
Step 8 : USER oracle
—> Running in 012bc240b15c
—> 90c7fd83f732
Removing intermediate container 012bc240b15c
Step 9 : RUN $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE
—> Running in a669bd56a701
Archive: linuxx64_12201_database.zip
creating: database/
…
inflating: database/runInstaller
Starting Oracle Universal Installer…
Checking Temp space: must be greater than 500 MB. Actual 16493 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-03-27_03-55-03PM. 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-03-27_03-55-03PM.log
The installation of Oracle Database 12c was successful.
Please check ‘/opt/oracle/oraInventory/logs/silentInstall2017-03-27_03-55-03PM.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.
—> 0902cfc62543
Removing intermediate container a669bd56a701
Step 10 : USER root
—> Running in 29796c72580a
—> 09b24f80b740
Removing intermediate container 29796c72580a
Step 11 : RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh && rm -rf $INSTALL_DIR
—> Running in b4e812ee2e1b
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_d301de87c50a_2017-03-27_16-01-04-445406140.log for the output of root script
—> afc8f9ef0a10
Removing intermediate container b4e812ee2e1b
Step 12 : USER oracle
—> Running in 6244a9a22dec
—> 8a41f54d71ae
Removing intermediate container 6244a9a22dec
Step 13 : WORKDIR /home/oracle
—> Running in c52fa2e4164f
—> b9daa3897d15
Removing intermediate container c52fa2e4164f
Step 14 : VOLUME $ORACLE_BASE/oradata
—> Running in 847ca5208e7f
—> 2f897f1adbda
Removing intermediate container 847ca5208e7f
Step 15 : EXPOSE 1521 5500
—> Running in d73768c39961
—> 9fd63d1fd413
Removing intermediate container d73768c39961
Step 16 : CMD exec $ORACLE_BASE/$RUN_FILE
—> Running in 34d6f31bb5b7
—> efa2e9d7cc87
Removing intermediate container 34d6f31bb5b7
Successfully built efa2e9d7cc87
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 840 seconds.
Starting Oracle Docker instance
We are now ready to start the Oracle databases inside a Docker container. To do this we use the docker run command passing the required parameters.
e.g.
-p Port
–name Docker container name, note this is not the database name.
[oracle@localhost dockerfiles]$ sudo docker run -p 1521:1521 –name pure oracle/database:12.2.0.1-ee
ORACLE AUTO GENERATED PASSWORD FOR SYS, SYSTEM AND PDBAMIN: FH0EoJP7dYo=1
LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 27-MAR-2017 16:10:45
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/f4c614207382/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 27-MAR-2017 16:10:45
Uptime 0 days 0 hr. 0 min. 0 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/f4c614207382/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 Mon Mar 27 16:17:18 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!
#########################
Completed: alter pluggable database ORCLPDB1 open
2017-03-27T16:17:17.923085+00:00
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
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-03-27T16:17:18.753847+00:00
ALTER SYSTEM SET control_files=’/opt/oracle/oradata/ORCLCDB/control01.ctl’ SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2017-03-27T16:27:02.711804+00:00
ORCLPDB1(3):Resize operation completed for file# 10, old size 337920K, new size 358400K
Resetting the Oracle Database passwords
During the build a default password was allocated, however it’s a good idea to update the passwords now, fortunately the build includes a utility to update the Oracle SYS, SYSYEM & PDBADMIN.
[oracle@localhost dockerfiles]$ sudo docker exec pure ./setPassword.sh Docker
The Oracle base remains unchanged with value /opt/oracle
SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 28 14:56:13 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
Stopping the Oracle Database Docker
[oracle@localhost dockerfiles]$ sudo docker stop pure
pure
[oracle@localhost dockerfiles]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Restarting the Oracle Database Docker
[oracle@localhost dockerfiles]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f4c614207382 oracle/database:12.2.0.1-ee “/bin/sh -c ‘exec $OR” 22 hours ago Up 2 seconds 0.0.0.0:1521->1521/tcp, 5500/tcp pure
[oracle@localhost bin]$ ./sql system/Docker@//localhost:1521/ORCLPDB1
SQLcl: Release 4.2.0 Production on Tue Mar 28 15:20:02 2017
Copyright (c) 1982, 2017, Oracle. All rights reserved.
Last Successful login time: Tue Mar 28 2017 15:20:03 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production
SQL> select name from v$database;
NAME
———
ORCLCDB
SQL>
Using the Docker Log
The docker logs command will perform a tail -f of /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/alert_ORCLCDB.log which can be useful to diagnose problems or just to review status.
[oracle@localhost ~]$ sudo docker logs -f pure
ORACLE AUTO GENERATED PASSWORD FOR SYS, SYSTEM AND PDBAMIN: FH0EoJP7dYo=1
LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 27-MAR-2017 16:10:45
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/f4c614207382/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 27-MAR-2017 16:10:45
Uptime 0 days 0 hr. 0 min. 0 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/f4c614207382/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
The docker start command runs the container automatically into the background.
…
[twitter-follow screen_name=’RonEkins’ show_count=’yes’]