Skip to content

Commit

Permalink
Start Oracle Database health check only after startup is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Oct 21, 2024
1 parent 801bdcb commit 40a875a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ENV ORACLE_BASE=/opt/oracle \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh" \
RELINK_BINARY_FILE="relinkOracleBinary.sh" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ENV ORACLE_BASE=/opt/oracle \
CONF_FILE="oracle-xe-21c.conf" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CONFIG_TCPS_FILE="configTcps.sh" \
INSTALL_DIR="$HOME/install" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ EOF
################ MAIN #######################
#############################################

if [ "$IGNORE_DB_STARTED_MARKER" != true ] && [ ! -f "$DB_STARTED_MARKER_FILE" ]; then
echo "Database was not started yet." >&2
exit 1
fi

# Setting up ORACLE_PWD if podman secret is passed on
if [ -e '/run/secrets/oracle_pwd' ]; then
export ORACLE_PWD="$(cat '/run/secrets/oracle_pwd')"
Expand Down
8 changes: 5 additions & 3 deletions OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ else
"$ORACLE_BASE"/"$CREATE_DB_FILE" $ORACLE_SID "$ORACLE_PDB" "$ORACLE_PWD" || exit 1;

# Check whether database is successfully created
if "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
if IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
# Create a checkpoint file if database is successfully created
# Populate the checkpoint file with the current date to avoid timing issue when using NFS persistence in multi-replica mode
echo "$(date -Iseconds)" > "$ORACLE_BASE"/oradata/.${ORACLE_SID}"${CHECKPOINT_FILE_EXTN}"
Expand All @@ -303,7 +303,7 @@ else
fi;

# Check whether database is up and running
"$ORACLE_BASE"/"$CHECK_DB_FILE"
IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"
status=$?

# Check whether database is up and running
Expand All @@ -317,7 +317,9 @@ if [ $status -eq 0 ]; then

# Execute custom provided startup scripts
"$ORACLE_BASE"/"$USER_SCRIPTS_FILE" "$ORACLE_BASE"/scripts/startup


# Create marker file for the health check
touch "$DB_STARTED_MARKER_FILE"
else
echo "#####################################"
echo "########### E R R O R ###############"
Expand Down

0 comments on commit 40a875a

Please sign in to comment.