Search code examples
javadockerkubernetesoracle11g

oracle database cannot run on kubernetes


I use local docker image and deploy oracle database to kubernetes from .yaml file with StatefulSet.

The image is 100GB , after running with kubectl apply -f file.yaml , database is mounted and when finish the installation the container is shutting down and the pod create new container with same result and so on.

If i run the container from docker with docker run ..... the container work and i can enter and use the database , only in k8s cluster get the problem , Its tested from 3 computers , local and on cloud(eks) the result is the same.

Dockerfile is : CMD exec $ORACLE_HOME/startup.sh

startup.sh file is:

sqlplus SYS/SYS as sysdba <<EOF
   startup
   exit
EOF
/bin/bash

In the logs i see starting up and then finished the exit; command and pod instance crashed: Database mounted. ORA-03113: end-of-file on communication channel Process ID: 124 Session ID: 261 Serial number:23381 SQL> Disconnected from Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production

I expect someone to give me advice.


Solution

  • The problem is with the command execution. Container will stop as soon as your startup process is finished. You'll be required to run your process forever. If it's a http server,then it'll run forever. So it's better to start the main service or you can put

    command: ["sleep","infinity"]
    

    In your container spec inside your deployment yaml. Please refer this https://devopscube.com/keep-docker-container-running/