Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Oracle Database health check only after startup is finished #2882

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ ENV ORACLE_BASE=/u01/app/oracle \
CONFIG_RSP="xe.rsp" \
RUN_FILE="runOracle.sh" \
PWD_FILE="setPassword.sh" \
CHECK_DB_FILE="checkDBStatus.sh"
CHECK_DB_FILE="checkDBStatus.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started"

# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

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

POSITIVE_RETURN="OPEN"
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ if [ "$?" == "0" ]; then
fi;

# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
IGNORE_DB_STARTED_MARKER=true $ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
Expand All @@ -199,6 +199,8 @@ if [ $? -eq 0 ]; then
# Execute custom provided startup scripts
runUserScripts $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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

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

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
Expand All @@ -187,6 +187,8 @@ if [ $? -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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ENV ORACLE_BASE=/opt/oracle \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

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

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
Expand All @@ -187,6 +187,8 @@ if [ $? -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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

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

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
Expand All @@ -187,6 +187,8 @@ if [ $? -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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

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

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ if [ "$?" == "0" ]; then
fi;

# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
IGNORE_DB_STARTED_MARKER=true $ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
Expand All @@ -210,6 +210,8 @@ if [ $? -eq 0 ]; then
# Execute custom provided startup scripts
runUserScripts $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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,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
date -Iseconds > "$ORACLE_BASE"/oradata/."${ORACLE_SID}""${CHECKPOINT_FILE_EXTN}"
Expand All @@ -295,7 +295,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=$?

if [ $status -eq 0 ]; then
Expand All @@ -308,6 +308,8 @@ 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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ENV ORACLE_BASE=/opt/oracle \
CONF_FILE="oracle-free-23ai.conf" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
DECRYPT_PWD_FILE="decryptPassword.sh" \
CONFIG_TCPS_FILE="configTcps.sh" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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

ORACLE_PWD=$($ORACLE_BASE/$DECRYPT_PWD_FILE)
export ORACLE_PWD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ else
"$ORACLE_BASE"/"$CREATE_DB_FILE" $ORACLE_SID "$ORACLE_PDB" "$ORACLE_PWD" || exit 1;

for i in 1 2 4 8; do
"$ORACLE_BASE"/"$CHECK_DB_FILE";
IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE";
ret=$?
# Check whether database is successfully created
if [ $ret -eq 0 ]; then
Expand Down Expand Up @@ -308,7 +308,7 @@ fi;

for i in 1 2 4 8; do
# Check whether database is up and running
"$ORACLE_BASE"/"$CHECK_DB_FILE"
IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"
status=$?
if [ $status -eq 5 ]; then
# PDB is in mounted state
Expand All @@ -331,6 +331,8 @@ 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