Prequisites
- Download Oracle Database 19c Linux Package here
- Installed K8S
- Installed Docker
- Docker Images Oracle Database 19c hereLangkah Penginstalan
- Install Docker and K8S
- Clone Docker Images
$ git clone https://github.com/oracle/docker-images.git
- Copy Oracle Database 19c Linux Package to the same location of dockerfile directory
$ mv LINUX.X64_193000_db_home.zip ~/docker-images/OracleDatabase/SingleInstance/dockerfiles/19.3.0/
$ ls docker-images/OracleDatabase/SingleInstance/dockerfiles/19.3.0/
- Build Container Image
$ cd ~/docker-images/OracleDatabase/SingleInstance/dockerfiles/
$ ./buildContainerImage.sh -e -v 19.3.0 -t oracle19c:1.0.0 -o '--build-arg SLIMMING=false'
// Note
Usage: buildContainerImage.sh -v [version] -t [image_name:tag] [-e | -s | -x | -f] [-i] [-p] [-b] [-o] [container build option]
Builds a container image for Oracle Database.
Parameters:
-v: version to build
Choose one of: 11.2.0.2 12.1.0.2 12.2.0.1 18.3.0 18.4.0 19.3.0 21.3.0 23.3.0
-t: image_name:tag for the generated docker image
-e: creates image based on 'Enterprise Edition'
-s: creates image based on 'Standard Edition 2'
-x: creates image based on 'Express Edition'
-f: creates image based on Database 'Free'
-i: ignores the MD5 checksums
-p: creates and extends image using the patching extension
-b: build base stage only (Used by extensions)
-o: passes on container build option
- Running Oracle Database in a Container
docker run --name oracle-19c -p 127.0.0.1::1521 -p 127.0.0.1::5500 -e ORACLE_SID=POLIUPGORA -e ORACLE_PDB=POLIUPGPDB1 -e ORACLE_PWD=poliup9 oracle19c:1.0.0
// Note
Parameters
--name: The name of the container (default: auto generated).
-p: The port mapping of the host port to the container port.
The following ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express), 2484 (TCPS Listener Port if TCPS is enabled).
--ulimit: Resource limits. Update according to Oracle Database documentation.
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB).
-e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1).
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated).
- Set Password for User sys Oracle
$ cd ~/docker-images/OracleDatabase/SingleInstance/dockerfiles/19.3.0/
$ docker exec oracle-19c ./setPassword.sh pnup01
- Push Image to your Repository for used to Kubernetes
$ docker login
$ docker commit oracle-19c poliupgora-19c
$ docker tag poliupgora-19c:latest andhy2502/poliupgora-19c:v1.0
$ docker push andhy2502/poliupgora-19c:v1.0
Setup Kubernetes
- Encrypt Base64 Password for Oracle Root Password
$ echo 'poliupg01' | base64
cG9saXVwZzAxCg==
- Create file namespace.yaml and apply
$ nano namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: oradb-kube
labels:
name: oradb-kube
$ kubectl apply -f namespace.yaml
- Create file oracle-db-secret.yml and apply
$ nano oracle-db-secret.yml
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: oracledb-secret
namespace: oradb-kube
data:
oracleRootPassword: cG9saXVwZzAxCg==
$ kubectl apply -f oracle-db-secret.yml
- Create file oradb-deployment.yaml and apply
$ nano oradb-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: oracle-19c
namespace: oradb-kube
spec:
replicas: 1
selector:
matchLabels:
app: oracle-19c
template:
metadata:
labels:
app: oracle-19c
selector: oracle-19c
spec:
containers:
- name: oracle-19c
image: andhy2502/poliupgora-19c:v1.0
resources:
limits:
cpu: 1
memory: 2500Mi
requests:
cpu: 1
memory: 2000Mi
ports:
- name: main-port
containerPort: 1521
- name: em-port
containerPort: 5500
$ kubectl apply -f oradb-deployment.yaml
- Create file service.yaml and apply
$ nano service.yaml
apiVersion: v1
kind: Service
metadata:
name: srv-nodeport-oradb
namespace: oradb-kube
labels:
app: oracle-19c
spec:
type: NodePort
ports:
- port: 1521
name: listener-poliupgora
nodePort: 30211
- port: 5500
name: em-poliupgora
nodePort: 30212
selector:
app: oracle-19c
$ kubectl apply -f service.yaml
Additional Access OracleDB on K8S using SQL Plus
$ wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip
$ wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip
$ sudo mkdir -p /opt/oracle
$ sudo unzip -d /opt/oracle instantclient-basic-linux.x64-21.4.0.0.0dbru.zip
$ sudo unzip -d /opt/oracle instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip
$ nano ~/.bashrc
-- ADD on END OF LINE --
export LD_LIBRARY_PATH=/opt/oracle/instantclient_21_4:$LD_LIBRARY_PATH
export PATH=$LD_LIBRARY_PATH:$PATH
$ source ~/.bashrc
$ sqlplus -V
$ sqlplus sys/pnup01@10.1.18.14:1521/POLIUPGORA as sysdba
0 Comments