More Related Content Similar to Dockerizing Oracle Database (20) Dockerizing Oracle Database 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is Docker?
• A software container platform
• Originated from Linux / Linux Containers
– Also available on Windows and Mac OS X
• Part of the Linux Open Container Initiative (OCI)
– Part of Open Source Linux
• Editions:
– Commercial Edition (EE) – Sold by Docker Corp
– Community Edition (CE) – Part of Open Source Linux
7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is Docker?
• docker-engine: The engine running containers
• Images: Collection of software to be run as a container
• Containers: A container on the Linux host
• Registry: Place to store and download images
• Volumes: Place to persist data outside the container
Terminology
8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Docker Key Components
Source: https://docs.docker.com/engine/docker-overview/
• Registry
• Images
• Containers
• Docker
daemon/engine
9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Docker Key Components - Volumes
Source: https://docs.docker.com/engine/docker-overview/
• Registry
• Images
• Containers
• Docker
daemon/engine
10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is Docker?
• Containers are non-persistent
– Once a container is deleted, all files inside that container are gone
Concepts
11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is Docker?
• Containers are non-persistent
– Once a container is deleted, all files inside that container are gone
• Images are immutable
– Changes to an image require to build a new image
– Data to be persisted has to be stored in volumes
Concepts
12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is Docker?
• Containers are non-persistent
– Once a container is deleted, all files inside that container are gone
• Images are immutable
– Changes to an image require to build a new image
– Data to be persisted has to be stored in volumes
• Containers are spun up from images
Concepts
13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why is Docker cool?
• Abstracts virtual environment (container) creation
into simple steps:
– docker create …
– docker run …
– docker rm …
• Runs directly on the Linux kernel (cgroups)
– Avoids the hypervisor overhead
14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why is Docker cool?
• Abstracts virtual environment (container) creation
into simple steps:
– docker create …
– docker run …
– docker rm …
• Runs directly on the Linux kernel (cgroups)
– Avoids the hypervisor overhead
17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why is Docker actually cool?
• Allows abstraction of environments into images
• Allows creation of hierarchical images
18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why is Docker actually cool?
• Allows abstraction of environments into images
• Allows creation of hierarchical images
19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why is Docker actually cool?
• Allows abstraction of environments into images
• Allows creation of hierarchical images
• Supports multi-layered image registries
20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Oracle CDB architecture & Docker architecture
Same concept applied on DB and OS level
App B App CApp A
App A App B App C
21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Oracle Database on Docker
• Oracle Database is fully supported on Docker
– Oracle Linux 7 - UEK 4
– Red Hat Enterprise Linux 7
• Oracle images on Oracle Container Registry & Docker Store
• Docker build files on GitHub
• RAC is not yet supported
22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Oracle Database on Docker
• Docker container contains single-PDB CDB (no MTO license required)
• PDB can be plugged, unplugged, etc.
• PDB can move bi-directional
23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Installing Docker
1) Enable OL7 addons repo
2) Install docker-engine
3) Enable non-root user (optional)
4) Increase base image size (optional)
5) Start and enable Docker service
25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Enable OL7 addons repo
[root@localhost ~]# yum-config-manager --enable *addons
Loaded plugins: langpacks
============ repo: ol7_addons ============
[ol7_addons]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/
...
...
...
26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Enable OL7 addons repo - check
[root@localhost ~]# yum repolist
Loaded plugins: langpacks, ulninfo
repo id repo name status
ol7_UEKR4/x86_64 Latest Unbreakable Enterprise 544
ol7_addons/x86_64 Oracle Linux 7Server Add ons (x86_64) 251
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 23,671
repolist: 24,466
27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Install docker-engine
[root@localhost ~]# yum install docker-engine
Loaded plugins: langpacks, ulninfo
--> Running transaction check
---> Package docker-engine.x86_64 0:17.06.2.ol-1.0.1.el7 will be installed
...
...
...
Running transaction
Installing :2:container-selinux-2.21-1.el7.noarch
Installing : docker-engine-17.06.2.ol-1.0.1.el7.x86_64
Verifying : docker-engine-17.06.2.ol-1.0.1.el7.x86_64
Verifying :2:container-selinux-2.21-1.el7.noarch
Installed:
docker-engine.x86_64 0:17.06.2.ol-1.0.1.el7
28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Install docker-engine - check
[root@localhost ~]# docker version
Client:
Version: 17.06.2-ol
API version: 1.30
Go version: go1.8.3
Git commit: d02b7ab
Built: Fri Oct 6 00:02:23 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the
docker daemon running?
29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Enable non-root user (optional)
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1001(oracle) groups=1001(oracle),1000(dba)
[root@localhost ~]# usermod -a -G docker oracle
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1001(oracle) groups=1001(oracle),1000(dba),981(docker)
30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Increase base image size (optional)
[root@localhost ~]# 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.
DOCKER_STORAGE_OPTIONS= --storage-driver devicemapper --storage-opt
dm.basesize=25G
31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Start and enable Docker service
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-
user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Start and enable Docker service - check
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor
preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
└─docker-sysconfig.conf
Active: active (running) since Mon 2018-01-15 21:21:22 EST; 49s ago
Docs: https://docs.docker.com
Main PID: 2013 (dockerd)
33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Start and enable Docker service - check
[root@localhost ~]# docker version
Client: Version: 17.06.2-ol
API version: 1.30
Go version: go1.8.3
Git commit: d02b7ab
Built: Fri Oct 6 00:02:23 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.2-ol
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: d02b7ab
Built: Fri Oct 6 00:03:48 2017
OS/Arch: linux/amd64
Experimental: false
34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Building an Oracle Database Docker image
1) Download GitHub build files
2) Download Oracle DB Installer zip file
3) Run image build script
37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Download GitHub build files
[oracle@localhost docker]$ wget https://github.com/oracle/docker-
images/archive/master.zip
Length: unspecified [application/zip]
Saving to: ‘master.zip’
[oracle@localhost docker]$ unzip master.zip
[oracle@localhost OracleDatabase]$ cd docker-images-master/OracleDatabase/
39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Run Image build
[oracle@localhost ~]$ mv linuxx64_12201_database.zip docker/docker-images-
master/OracleDatabase/dockerfiles/12.2.0.1/
[oracle@localhost ~]$ cd docker/docker-images-
master/OracleDatabase/dockerfiles
[oracle@localhost dockerfiles]$ ./buildDockerImage.sh –e
Checking if required packages are present and valid...
linuxx64_12201_database.zip: OK
...
...
...
Successfully built 14e4a95bf3d3
Successfully tagged oracle/database:12.2.0.1-ee
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 896 seconds.
40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Running an Oracle Database - simple
[oracle@localhost docker]$ docker run -p 1521:1521 oracle/database:12.2.0.1-ee
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: PGWrXXpL3Us=1
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-JAN-2018 19:27:38
...
...
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Completed: alter pluggable database ORCLPDB1 open
43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Running an Oracle Database - reusable
[oracle@localhost ~]$ docker volume create oradata
oradata
[oracle@localhost ~]$ docker run --name oracle-ee -p 1521:1521 -v
oradata:/opt/oracle/oradata oracle/database:12.2.0.1-ee
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: aUlBB4E0Rj4=1
...
...
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Completed: alter pluggable database ORCLPDB1 open
[oracle@localhost ~]$ docker exec oracle-ee ./setPassword.sh LetsDocker
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
User altered.
SQL>
User altered.
44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Running an Oracle Database - advanced
docker run --name <container name>
-p <host port>:1521 -p <host port>:5500
-e ORACLE_SID=<your SID>
-e ORACLE_PDB=<your PDB name>
-e ORACLE_PWD=<your database passwords>
-e ORACLE_CHARACTERSET=<your character set>
-v [<host mount point>:]/opt/oracle/oradata
oracle/database:12.2.0.1-ee
45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
What is Docker
Installing Docker
Building an Oracle Database Docker image
Running an Oracle Database inside Docker
Tips and Tricks
1
2
3
4
5
46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Run small Image build – requires exper. features
[root@localhost ~]# cat /etc/docker/daemon.json
{
"experimental": true
}
[root@localhost ~]# docker info
...
...
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: true
47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Run small Image build – requires exper. features
[oracle@localhost ~]$ mv linuxx64_12201_database.zip docker/docker-images-
master/OracleDatabase/dockerfiles/12.2.0.1/
[oracle@localhost ~]$ cd docker/docker-images-
master/OracleDatabase/dockerfiles
[oracle@localhost dockerfiles]$ ./buildDockerImage.sh –e –o --squash
Checking if required packages are present and valid...
linuxx64_12201_database.zip: OK
...
...
...
Successfully built 14e4a95bf3d3
Successfully tagged oracle/database:12.2.0.1-ee
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 896 seconds.
48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Proxy settings
[root@localhost ~]# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://www-proxy.example.com:80”
[root@localhost ~]# cat /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=https://www-proxy.example.com:80”
[root@localhost ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 17
Http Proxy: http://www-proxy.example.com:80
Https Proxy: https://www-proxy.example.com:80
49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
User defined passwords
[oracle@localhost ~]$ docker run --name <container name>
-p <host port>:1521 -p <host port>:5500
-e ORACLE_SID=<your SID>
-e ORACLE_PDB=<your PDB name>
-e ORACLE_PWD=<your database passwords>
-e ORACLE_CHARACTERSET=<your character set>
-v [<host mount point>:]/opt/oracle/oradata
oracle/database:12.2.0.1-ee
50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
User defined passwords
[oracle@localhost ~]$ docker run -p 1521:1521
-e ORACLE_PWD=LetsDocker oracle/database:12.2.0.1-ee
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: LetsDocker
gvenzl-mac:~ gvenzl$ sql sys/LetsDocker@//localhost:1521/ORCLCDB as sysdba
SQLcl: Release 17.2.0 Production on Sat Jan 20 13:16:47 2018
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Custom SID and PDB names
docker run --name <container name>
-p <host port>:1521 -p <host port>:5500
-e ORACLE_SID=<your SID>
-e ORACLE_PDB=<your PDB name>
-e ORACLE_PWD=<your database passwords>
-e ORACLE_CHARACTERSET=<your character set>
-v [<host mount point>:]/opt/oracle/oradata
oracle/database:12.2.0.1-ee
52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Custom SID and PDB names
[oracle@localhost ~]$ docker run
--name gerald
-p 1521:1521
-e ORACLE_SID=GERALD
-e ORACLE_PDB=GeraldPod1
-v oradata:/opt/oracle/oradata oracle/database:12.2.0.1-ee
gvenzl-mac:~ gvenzl$ sql sys/OfgF4jjhB9U=1@//localhost:1521/GeraldPod1 as
sysdba
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
GERALD
53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Passwords reset
[oracle@localhost ~]$ docker exec -ti gerald ./setPassword.sh LetsDocker
SQL*Plus: Release 12.2.0.1.0 Production on Sat Jan 20 11:19:36 2018
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