I have recently created a number of blogs posts on running containerised Oracle databases on Kubernetes using the Oracle provided Docker build scripts and the Pure Storage Container Storage Interface (CSI) Driver Pure Service Orchestrator (PSO) to provide persistent storage to my Oracle database containers.
In this Blog I am going to show how easy it is to run on Oracle 19c database on Kubernetes with persistent storage using the Pure Service Orchestrator CSI Driver.
You can find all the example Kubernetes manifest files for Oracle 19c, and other database versions at my GitHub repo.
kubernetes Database Management
Database deployment Deletion
$ kubectl delete deployments/oracle19c -n oracle-namespace deployment.apps "oracle19c" deleted
Database deployment Creation
$ kubectl apply -f database19c.yaml -n oracle-namespace deployment.apps/oracle19c created service/oracle19c created
list Database Deployments
$ kubectl get deployments -n oracle-namespace
NAME READY UP-TO-DATE AVAILABLE AGE
oracle12c 0/0 0 0 5d21h
oracle18xe 0/0 0 0 73m
oracle19c 1/1 1 1 4m24s
Show Running DatabaseS
$ kubectl get pods -n oracle-namespace -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE
oracle19c-64d6bb4f7-vpztn 1/1 Running 0 5m21s 10.1.92.82 z-re-uk8s02 <none>
Stop Database
$ kubectl scale -n oracle-namespace deployment oracle19c --replicas=0
Start Database
$ kubectl scale -n oracle-namespace deployment oracle19c --replicas=
1
Shell into Database Container
$ kubectl exec -it oracle19c-64d6bb4f7-vrq6d -n oracle-namespace -- /bin/bash
[oracle@oracle19c-64d6bb4f7-vrq6d ~]$
Review Console Output
$ kubectl logs oracle19c-64d6bb4f7-vrq6d -n oracle-namespace LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 13-MAY-2020 10:06:17 Copyright (c) 1991, 2019, Oracle. All rights reserved. Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 19.0.0.0.0 - Production System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/oracle19c-64d6bb4f7-vrq6d/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 19.0.0.0.0 - Production Start Date 13-MAY-2020 10:06:18 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/19c/dbhome_1/network/admin/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/oracle19c-64d6bb4f7-vrq6d/listener/alert/log.xml Listening Endpoints Summary...
Connect to a Database
We can also connect remotely to our database with sqlplus using the node and service details.
Get Database service details for deployment
$ kubectl get svc/oracle19c -n oracle-namespace NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE oracle19c NodePort 10.152.183.53 <none> 1521:32495/TCP,5500:32219/TCP 137m
Connect to database remotely with sqlplus
$ sqlplus system/Kube#2020@z-re-uk8s01:32495/ORCL
SQL*Plus: Release 19.0.0.0.0 - Production on Wed May 13 13:10:28 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed May 13 2020 13:10:05 +01:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Database relocation / move / fail-over
Determine which node the pod is running on
$ kubectl get pods -n oracle-namespace -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE oracle19c-64d6bb4f7-vpztn 1/1 Running 0 5m21s 10.1.92.82 z-re-uk8s02 <none>
Make node unavailable for scheduling
$ kubectl cordon z-re-uk8s02 node/z-re-uk8s02 cordoned
Review status of node
$ kubectl get node/z-re-uk8s02
NAME STATUS ROLES AGE VERSION
z-re-uk8s02 Ready,SchedulingDisabled <none> 17d v1.18.2-41+b5cdb79a4060a3
Delete Database pod
$ kubectl delete pod/oracle19c-64d6bb4f7-vpztn -n oracle-namespace
pod "oracle19c-64d6bb4f7-vpztn" deleted
Determine which node the pod has moved to
$ kubectl get pods -n oracle-namespace -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE oracle19c-64d6bb4f7-vrq6d 1/1 Running 0 2m20s 10.1.46.43 z-re-uk8s04 <none>
Make node available again for scheduling
$ kubectl uncordon z-re-uk8s02 node/z-re-uk8s02 already uncordoned
Show node status
$ kubectl get nodes NAME STATUS ROLES AGE VERSION z-re-uk8s01 Ready <none> 17d v1.18.2-41+b5cdb79a4060a3 z-re-uk8s02 Ready <none> 17d v1.18.2-41+b5cdb79a4060a3 z-re-uk8s03 Ready <none> 17d v1.18.2-41+b5cdb79a4060a3 z-re-uk8s04 Ready <none> 17d v1.18.2-41+b5cdb79a4060a3
If you’re just getting started with Kubernetes, or have missed my previous posts, here you go.
- Running Oracle 12c on Kubernetes with MiniKube
- Getting Started with Oracle 12c on Kubernetes using Persistent Storage
- How to run Oracle 18c Express Edition (XE) on Kubernetes using Persistent Storage
- Relocating / moving and Oracle Database automated failover with Kubernetes
- Performing Kubernetes Persistent Storage snapshots and clones
[twitter-follow screen_name=’RonEkins’ show_count=’yes’]
Hi Ron,
Your blog is pretty much the only resource I can find about running an Oracle database in Kubernetes. Is this supported by Oracle? Is there any official documentation about this? In any case, this and several of your other blog posts have been very helpful. Thank you.
Hi Greg, thanks for the feedback.
Yes, Oracle supports database containerisation.
You may find the this link useful: https://www.oracle.com/a/tech/docs/running-and-licensing-programs-in-containers-and-kubernetes.pdf
Kind regards
Hello Ron,
Very informative 👏 great article much appreciated effort