From a5c2b1b39bb7da35cd5ee2762da0862b6be58c16 Mon Sep 17 00:00:00 2001 From: Saurabh Ahuja Date: Mon, 1 Sep 2025 06:47:02 +0000 Subject: [PATCH 1/2] latest scripts for oracle restart --- .../containerfiles/19.3.0/Checksum | 4 +- .../containerfiles/19.3.0/Containerfile | 2 +- .../containerfiles/19.3.0/GridHomeCleanup.sh | 5 +- .../19.3.0/OracleHomeCleanup.sh | 3 +- .../containerfiles/19.3.0/applyGridPatch.sh | 3 +- .../containerfiles/19.3.0/checkSpace.sh | 1 + .../containerfiles/19.3.0/enableRAC.sh | 3 +- .../containerfiles/19.3.0/fixupPreq.sh | 1 + .../19.3.0/installDBBinaries.sh | 3 +- .../19.3.0/installGridBinaries.sh | 2 +- .../containerfiles/19.3.0/runOracle.sh | 3 +- .../containerfiles/19.3.0/setupDB.sh | 1 + .../containerfiles/19.3.0/setupGrid.sh | 4 +- .../containerfiles/19.3.0/setupLinuxEnv.sh | 10 +- .../containerfiles/19.3.0/tempfile | 0 .../containerfiles/21.3.0/Checksum | 2 +- .../containerfiles/21.3.0/GridHomeCleanup.sh | 5 +- .../21.3.0/OracleHomeCleanup.sh | 5 +- .../containerfiles/21.3.0/applyGridPatch.sh | 3 +- .../containerfiles/21.3.0/checkSpace.sh | 1 + .../containerfiles/21.3.0/enableRAC.sh | 3 +- .../containerfiles/21.3.0/fixupPreq.sh | 1 + .../21.3.0/installDBBinaries.sh | 3 +- .../21.3.0/installGridBinaries.sh | 2 +- .../containerfiles/21.3.0/runOracle.sh | 5 +- .../containerfiles/21.3.0/setupDB.sh | 3 +- .../containerfiles/21.3.0/setupGrid.sh | 6 +- .../containerfiles/21.3.0/setupLinuxEnv.sh | 1 + .../containerfiles/scripts/cmdExec | 5 +- .../containerfiles/scripts/main.py | 12 +- .../containerfiles/scripts/oraasmca.py | 6 +- .../containerfiles/scripts/oracommon.py | 730 +++++++++++++----- .../containerfiles/scripts/oracvu.py | 66 +- .../containerfiles/scripts/oraenv.py | 12 +- .../containerfiles/scripts/oragiadd.py | 97 ++- .../containerfiles/scripts/oragiprov.py | 190 ++++- .../containerfiles/scripts/oramachine.py | 2 +- .../containerfiles/scripts/oramiscops.py | 58 +- .../containerfiles/scripts/oraracadd.py | 8 +- .../containerfiles/scripts/oraracdel.py | 25 +- .../containerfiles/scripts/oraracprov.py | 178 +++-- .../containerfiles/scripts/oraracstdby.py | 2 +- .../containerfiles/scripts/orasetupenv.py | 64 +- .../containerfiles/scripts/orasshsetup.py | 2 +- 44 files changed, 1160 insertions(+), 382 deletions(-) delete mode 100644 OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/tempfile diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum index 8bcb13f056..cb4a9752e5 100644 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum @@ -1,2 +1,2 @@ -b7c4c66f801f92d14faa0d791ccda721 19.3.0/LINUX.X64_193000_grid_home.zip -1858bd0d281c60f4ddabd87b1c214a4f 19.3.0/LINUX.X64_193000_db_home.zip +b7c4c66f801f92d14faa0d791ccda721 19.3.0/LINUX.X64_193000_db_home.zip +1858bd0d281c60f4ddabd87b1c214a4f 19.3.0/LINUX.X64_193000_grid_home.zip diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Containerfile b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Containerfile index 8980f26f38..2a19579205 100644 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Containerfile +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Containerfile @@ -20,7 +20,7 @@ # $ docker build -t oracle/database:19c-rac . -ARG BASE_OL_IMAGE=oraclelinux:8 +ARG BASE_OL_IMAGE=oraclelinux:9 ARG SLIMMING=false # Pull base image # --------------- diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/GridHomeCleanup.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/GridHomeCleanup.sh index 42f33d4f70..0036cff9e4 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/GridHomeCleanup.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/GridHomeCleanup.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2019,2025 Oracle and/or its affiliates. @@ -11,9 +12,9 @@ # # Image Cleanup Script -# shellcheck disable=SC1090 + source /home/"${GRID_USER}"/.bashrc -# shellcheck disable=SC2034 + ORACLE_HOME=${GRID_HOME} rm -rf /u01/app/grid/* diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/OracleHomeCleanup.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/OracleHomeCleanup.sh index bd46f5012e..4712056499 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/OracleHomeCleanup.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/OracleHomeCleanup.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2019,2025 Oracle and/or its affiliates. @@ -11,7 +12,7 @@ # # Image Cleanup Script -# shellcheck disable=SC1090 + source /home/"${DB_USER}"/.bashrc ORACLE_HOME=${DB_HOME} diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/applyGridPatch.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/applyGridPatch.sh index 247edd87f6..21126b4e22 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/applyGridPatch.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/applyGridPatch.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -34,7 +35,7 @@ if [ "$GRID_HOME" == "" ]; then fi; # Install Oracle binaries -# shellcheck disable=SC2115 + unzip -q "$INSTALL_SCRIPTS"/"$PATCH" -d "$GRID_USER_HOME" && \ rm -f "$INSTALL_SCRIPTS"/"$GRID_PATCH" && \ cd "$GRID_USER_HOME"/"$PATCH_NUMBER"/"$PATCH_NUMBER" && \ diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/checkSpace.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/checkSpace.sh index de8568f350..e00910e3c4 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/checkSpace.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/checkSpace.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/enableRAC.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/enableRAC.sh index 15e36e22fb..03e0eeaaaf 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/enableRAC.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/enableRAC.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -8,7 +9,7 @@ # Description: Enable RAC feature in Oracle Software # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# shellcheck disable=SC1090 + source /home/"${DB_USER}"/.bashrc export ORACLE_HOME=${DB_HOME} diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/fixupPreq.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/fixupPreq.sh index 1e051dfaa8..c2b87a4088 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/fixupPreq.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/fixupPreq.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installDBBinaries.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installDBBinaries.sh index c898a24df1..39dbf928a7 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installDBBinaries.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installDBBinaries.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -20,7 +21,6 @@ if [ "$EDITION" == "" ]; then fi; # Check whether correct edition has been passed on -# shellcheck disable=SC2166 if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then echo "ERROR: Wrong edition has been passed on!" echo "Edition $EDITION is no a valid edition!" @@ -60,6 +60,5 @@ fi # Install Oracle binaries -# shellcheck disable=SC2015 unzip -q "$INSTALL_SCRIPTS"/"$INSTALL_FILE_2" -d "$DB_HOME" && \ "$DB_HOME"/runInstaller -silent -force -waitforcompletion -responsefile "$INSTALL_SCRIPTS"/"$DB_INSTALL_RSP" -ignorePrereqFailure || true diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installGridBinaries.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installGridBinaries.sh index ebab8e91d8..c924b9ea3e 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installGridBinaries.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/installGridBinaries.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -11,7 +12,6 @@ # EDITION=$1 -# shellcheck disable=SC2034 PATCH_NUMBER=$2 # Check whether edition has been passed on diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/runOracle.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/runOracle.sh index 34b6808475..667a02b04e 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/runOracle.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/runOracle.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -33,7 +34,7 @@ fi if [ -z ${EXECUTOR} ]; then EXECUTOR="python3" fi -# shellcheck disable=SC2164 + cd $BASE_DIR $EXECUTOR $SCRIPT_NAME diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupDB.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupDB.sh index 2ee6797d2e..ae7e6a9855 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupDB.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupDB.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupGrid.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupGrid.sh index 1788a0d8ec..671cffc595 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupGrid.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupGrid.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -9,7 +10,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # -# shellcheck disable=SC2034 + EDITION=$1 # Create Directories @@ -33,7 +34,6 @@ if [ "${SLIMMING}x" != 'truex' ] ; then chown -R "${GRID_USER}":oinstall "$GRID_HOME" mkdir -p "$INVENTORY" chown -R "${GRID_USER}":oinstall "$INVENTORY" - # shellcheck disable=SC2129 echo "export PATH=$GRID_PATH" >> /home/"${GRID_USER}"/.bashrc echo "export LD_LIBRARY_PATH=$GRID_LD_LIBRARY_PATH" >> /home/"${GRID_USER}"/.bashrc echo "export SCRIPT_DIR=$SCRIPT_DIR" >> /home/"${GRID_USER}"/.bashrc diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupLinuxEnv.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupLinuxEnv.sh index 2c60f2ce41..a54e40f808 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupLinuxEnv.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/setupLinuxEnv.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -20,9 +21,14 @@ if [ -n "$region" ]; then for proxy in $(printenv | grep -i _proxy | cut -d= -f1); do unset $proxy; done echo "-$region" > /etc/yum/vars/ociregion fi - +# Refer Doc ID 2760289.1 for error- "libxcrypt-compat compat-openssl11" only available in OL9 +# Error in invoking target 'libasmclntsh19.ohso libasmperl19.ohso client_sharedlib' of makefile '/u01/app/oracle/product/19c/dbhome_1/rdbms/lib/ins_rdbms.mk'. mkdir /asmdisks && \ mkdir /responsefiles && \ chmod ug+x /opt/scripts/startup/*.sh && \ -yum -y install systemd oracle-database-preinstall-19c net-tools which zip unzip tar openssl expect e2fsprogs openssh-server vim-minimal passwd which sudo hostname policycoreutils-python-utils python3 lsof rsync && \ +yum -y install systemd oracle-database-preinstall-19c net-tools which zip \ +unzip tar openssl expect e2fsprogs openssh-server vim-minimal passwd which \ +sudo hostname policycoreutils-python-utils python3 lsof rsync libxcrypt-devel \ +libxcrypt fontconfig libvirt-libs librdmacm libibverbs liblsan libasan \ +libxcrypt-compat compat-openssl11 && \ yum clean all diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/tempfile b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/tempfile deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/Checksum b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/Checksum index 039f9e9edc..5b9f30d49d 100644 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/Checksum +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/Checksum @@ -1,2 +1,2 @@ 8ac915a800800ddf16a382506d3953db 21.3.0/LINUX.X64_213000_db_home.zip -b3fbdb7621ad82cbd4f40943effdd1be 21.3.0/LINUX.X64_213000_grid_home.zip \ No newline at end of file +b3fbdb7621ad82cbd4f40943effdd1be 21.3.0/LINUX.X64_213000_grid_home.zip diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/GridHomeCleanup.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/GridHomeCleanup.sh index 42f33d4f70..0036cff9e4 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/GridHomeCleanup.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/GridHomeCleanup.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2019,2025 Oracle and/or its affiliates. @@ -11,9 +12,9 @@ # # Image Cleanup Script -# shellcheck disable=SC1090 + source /home/"${GRID_USER}"/.bashrc -# shellcheck disable=SC2034 + ORACLE_HOME=${GRID_HOME} rm -rf /u01/app/grid/* diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/OracleHomeCleanup.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/OracleHomeCleanup.sh index 8087835575..4712056499 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/OracleHomeCleanup.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/OracleHomeCleanup.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2019,2025 Oracle and/or its affiliates. @@ -11,7 +12,7 @@ # # Image Cleanup Script -# shellcheck disable=SC1090 + source /home/"${DB_USER}"/.bashrc ORACLE_HOME=${DB_HOME} @@ -32,4 +33,4 @@ rm -rf "$ORACLE_HOME"/inventory/Scripts/comps.xml.* rm -rf "$ORACLE_HOME"/inventory/Scripts/oraclehomeproperties.xml.* rm -rf "$ORACLE_HOME"/inventory/Scripts/oraInst.loc.* rm -rf "$ORACLE_HOME"/inventory/Scripts/inventory.xml.* -rm -rf "$INVENTORY"/logs/* \ No newline at end of file +rm -rf "$INVENTORY"/logs/* diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/applyGridPatch.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/applyGridPatch.sh index 247edd87f6..21126b4e22 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/applyGridPatch.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/applyGridPatch.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -34,7 +35,7 @@ if [ "$GRID_HOME" == "" ]; then fi; # Install Oracle binaries -# shellcheck disable=SC2115 + unzip -q "$INSTALL_SCRIPTS"/"$PATCH" -d "$GRID_USER_HOME" && \ rm -f "$INSTALL_SCRIPTS"/"$GRID_PATCH" && \ cd "$GRID_USER_HOME"/"$PATCH_NUMBER"/"$PATCH_NUMBER" && \ diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/checkSpace.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/checkSpace.sh index de8568f350..e00910e3c4 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/checkSpace.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/checkSpace.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/enableRAC.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/enableRAC.sh index 15e36e22fb..03e0eeaaaf 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/enableRAC.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/enableRAC.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -8,7 +9,7 @@ # Description: Enable RAC feature in Oracle Software # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# shellcheck disable=SC1090 + source /home/"${DB_USER}"/.bashrc export ORACLE_HOME=${DB_HOME} diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/fixupPreq.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/fixupPreq.sh index 1e051dfaa8..c2b87a4088 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/fixupPreq.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/fixupPreq.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installDBBinaries.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installDBBinaries.sh index c898a24df1..39dbf928a7 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installDBBinaries.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installDBBinaries.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -20,7 +21,6 @@ if [ "$EDITION" == "" ]; then fi; # Check whether correct edition has been passed on -# shellcheck disable=SC2166 if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then echo "ERROR: Wrong edition has been passed on!" echo "Edition $EDITION is no a valid edition!" @@ -60,6 +60,5 @@ fi # Install Oracle binaries -# shellcheck disable=SC2015 unzip -q "$INSTALL_SCRIPTS"/"$INSTALL_FILE_2" -d "$DB_HOME" && \ "$DB_HOME"/runInstaller -silent -force -waitforcompletion -responsefile "$INSTALL_SCRIPTS"/"$DB_INSTALL_RSP" -ignorePrereqFailure || true diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installGridBinaries.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installGridBinaries.sh index ebab8e91d8..c924b9ea3e 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installGridBinaries.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/installGridBinaries.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -11,7 +12,6 @@ # EDITION=$1 -# shellcheck disable=SC2034 PATCH_NUMBER=$2 # Check whether edition has been passed on diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/runOracle.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/runOracle.sh index f1ff5cc3e3..667a02b04e 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/runOracle.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/runOracle.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -33,8 +34,8 @@ fi if [ -z ${EXECUTOR} ]; then EXECUTOR="python3" fi -# shellcheck disable=SC2164 + cd $BASE_DIR $EXECUTOR $SCRIPT_NAME -# Tail on alert log and wait (otherwise container will exit) \ No newline at end of file +# Tail on alert log and wait (otherwise container will exit) diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupDB.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupDB.sh index 053d234541..ae7e6a9855 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupDB.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupDB.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -39,4 +40,4 @@ if [ "${SLIMMING}x" != 'truex' ]; then echo "export PATH=$GRID_HOME/bin:$DB_PATH" >> /home/"${DB_USER}"/.bashrc echo "export LD_LIBRARY_PATH=$GRID_HOME/lib:$DB_LD_LIBRARY_PATH" >> /home/"${DB_USER}"/.bashrc fi -fi \ No newline at end of file +fi diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupGrid.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupGrid.sh index f37cf8c01a..671cffc595 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupGrid.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupGrid.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. @@ -9,7 +10,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # -# shellcheck disable=SC2034 + EDITION=$1 # Create Directories @@ -33,11 +34,10 @@ if [ "${SLIMMING}x" != 'truex' ] ; then chown -R "${GRID_USER}":oinstall "$GRID_HOME" mkdir -p "$INVENTORY" chown -R "${GRID_USER}":oinstall "$INVENTORY" - # shellcheck disable=SC2129 echo "export PATH=$GRID_PATH" >> /home/"${GRID_USER}"/.bashrc echo "export LD_LIBRARY_PATH=$GRID_LD_LIBRARY_PATH" >> /home/"${GRID_USER}"/.bashrc echo "export SCRIPT_DIR=$SCRIPT_DIR" >> /home/"${GRID_USER}"/.bashrc echo "export GRID_HOME=$GRID_HOME" >> /home/"${GRID_USER}"/.bashrc echo "export GRID_BASE=$GRID_BASE" >> /home/"${GRID_USER}"/.bashrc echo "export DB_HOME=$DB_HOME" >> /home/"${GRID_USER}"/.bashrc -fi \ No newline at end of file +fi diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupLinuxEnv.sh b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupLinuxEnv.sh index 31f7394caa..f05723aa21 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupLinuxEnv.sh +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/setupLinuxEnv.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all # LICENSE UPL 1.0 # # Copyright (c) 2018,2025 Oracle and/or its affiliates. diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/cmdExec b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/cmdExec index c06148708c..34e7a27e76 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/cmdExec +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/cmdExec @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=all ############################# # Copyright 2025, Oracle Corporation and/or affiliates. All rights reserved. @@ -8,9 +9,9 @@ # Author: paramdeep.saini@oracle.com TIMESTAMP=`date "+%Y-%m-%d"` LOGFILE="/tmp/oracle_rac_cmd_${TIMESTAMP}.log" -# shellcheck disable=SC2046,SC2068 + echo $(date -u) " : " $@ >> $LOGFILE -# shellcheck disable=SC2124 + cmd=$@ $cmd diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/main.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/main.py index 8a44b0f370..f17ddd5a44 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/main.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/main.py @@ -22,7 +22,7 @@ def main(): # Checking Comand line Args opts="" try: - opts, args = getopt.getopt(sys.argv[1:], '', ['help','resetpassword=','delracnode=','addtns=', 'checkracinst=', 'checkgilocal=','checkdbrole=','checkracdb=','checkracstatus','checkconnstr=','checkpdbconnstr=','setupdblsnr=','setuplocallsnr=','checkdbsvc=','modifydbsvc=','checkdbversion=','updatelsnrendp=','updateasmcount=','modifyscan=','updateasmdevices=','getasmdiskgroup=','getasmdisks=','getdgredundancy=','getasminstname=','getasminststatus=','rundatapatch=']) + opts, args = getopt.getopt(sys.argv[1:], '', ['help','resetpassword=','delracnode=','addtns=', 'checkracinst=', 'checkgilocal=','checkdbrole=','checkracdb=','checkracstatus','checkconnstr=','checkpdbconnstr=','setupdblsnr=','setuplocallsnr=','checkdbsvc=','modifydbsvc=','checkdbversion=','updatelsnrendp=','updateasmcount=','modifyscan=','updateasmdevices=','getasmdiskgroup=','getasmdisks=','getdgredundancy=','getasminstname=','getasminststatus=','rundatapatch=','ons=']) except getopt.GetoptError: pass @@ -294,6 +294,16 @@ def main(): oenv.update_key("OP_TYPE","miscops") else: oenv.add_custom_variable("OP_TYPE","miscops") + elif opt in ('--ons'): + file_name = oenv.logfile_name("ONS") + oralogger.filename_ = file_name + ocommon.log_info_message("=======================================================================",file_name) + oenv.add_custom_variable("ONS",arg) + oenv.add_custom_variable("CUSTOM_RUN_FLAG","true") + if ocommon.check_key("OP_TYPE",oenv.get_env_dict()): + oenv.update_key("OP_TYPE","miscops") + else: + oenv.add_custom_variable("OP_TYPE","miscops") else: pass diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraasmca.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraasmca.py index ca456d1425..c17e18630f 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraasmca.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraasmca.py @@ -57,7 +57,7 @@ def validate_dg(self,device_list,device_prop,type): """ giuser,gihome,gbase,oinv=self.ocommon.get_gi_params() device_prop,cname,cred,casm,crdbms,asdvm,cuasize=self.get_device_prop(device_prop,type) - self.ocommon.log_info_message("device prop set to :" + device_prop + " DG Name: " + cname + " Redudancy : " + cred, self.file_name) + self.ocommon.log_info_message("device prop set to :" + device_prop + " DG Name: " + cname + " Redundancy : " + cred, self.file_name) cmd='''su - {0} -c "{1}/bin/asmcmd lsdg {2}"'''.format(giuser,gihome,cname) output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.check_os_err(output,error,retcode,None) @@ -74,7 +74,7 @@ def create_dg(self,device_list,device_prop,type): disk_lst=self.get_device_list(device_list) self.ocommon.log_info_message("The type is set to :" + type,self.file_name) device_prop,cname,cred,casm,crdbms,asdvm,cuasize=self.get_device_prop(device_prop,type) - self.ocommon.log_info_message("device prop set to :" + device_prop + " DG Name: " + cname + " Redudancy : " + cred, self.file_name) + self.ocommon.log_info_message("device prop set to :" + device_prop + " DG Name: " + cname + " Redundancy : " + cred, self.file_name) cmd='''su - {0} -c "{1}/bin/asmca -silent -createDiskGroup {3} {2}"'''.format(giuser,gihome,disk_lst,device_prop) output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.check_os_err(output,error,retcode,True) @@ -107,7 +107,7 @@ def get_device_prop(self,device_prop,type): self.ocommon.log_info_message("The type is set to :" + type,self.file_name) if device_prop: - cvar_dict=dict(item.split("=") for item in device_prop.split(";")) + cvar_dict=dict(item.split(":") for item in device_prop.split(";")) for ckey in cvar_dict.keys(): if ckey == 'name': cname = cvar_dict[ckey] diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracommon.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracommon.py index a1d463445c..030df6cb5f 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracommon.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracommon.py @@ -182,9 +182,6 @@ def check_sql_err(self,output,err,retcode,status): msg2='''Sql command failed.Flag is set not to ignore this error.Please Check the logs,Exiting the Program!''' msg3='''Sql command failed.Flag is set to ignore this error!''' self.log_info_message("output : " + str(output or "no Output"),self.file_name) - # self.log_info_message("Error : " + str(err or "no Error"),self.file_name) - # self.log_info_message("Sqlplus return code : " + str(retcode),self.file_name) - # self.log_info_message("Command Check Status Set to :" + str(status),self.file_name) if status: if (retcode!=0): @@ -294,7 +291,7 @@ def add_key(self,key,value,env_dict): env_dict[key] = value self.oenv.update_env_vars(env_dict) else: - msg='''Variable {0} value is not defilned to add in the env variables. Exiting!'''.format(value) + msg='''Variable {0} value is not defined to add in the env variables. Exiting!'''.format(value) self.log_error_message(msg,self.file_name) self.prog_exit(self) @@ -626,19 +623,28 @@ def populate_rac_env_vars(self): newstr=None d=None newstr=line.replace("export ","").strip() - self.log_info_message(newstr + " newstr is populated: ",self.file_name) + self.log_info_message(newstr + " newstr is populated: ", self.file_name) + parts = newstr.split("=") + if len(parts) >= 2: + key = parts[0] + if key in ['DB_ASMDG_PROPERTIES', 'REDO_ASMDG_PROPERTIES', 'RECO_ASMDG_PROPERTIES'] and len(parts) >= 3: + value = '='.join(parts[1:]) + if not self.check_key(key, self.ora_env_dict): + self.ora_env_dict = self.add_key(key, value, self.ora_env_dict) + self.log_info_message(key + " key is populated: " + self.ora_env_dict[key], self.file_name) + else: + self.log_info_message(key + " key exist with value " + self.ora_env_dict[key], self.file_name) + pass if len(newstr.split("=")) == 2: key=newstr.split("=")[0] - value=newstr.split("=")[1] - # self.log_info_message(key + " key is populated: " + self.ora_env_dict[key] ,self.file_name) + value=newstr.split("=")[1] if not self.check_key(key,self.ora_env_dict): self.ora_env_dict=self.add_key(key,value,self.ora_env_dict) self.log_info_message(key + " key is populated: " + self.ora_env_dict[key] ,self.file_name) else: self.log_info_message(key + " key exist with value " + self.ora_env_dict[key] ,self.file_name) pass - # self.ora_env_dict=self.ora_env_dict - # print(self.ora_env_dict + ########### Get the install Node ####### def get_installnode(self): @@ -1034,14 +1040,18 @@ def get_nwifaces(self): netmask_address=pubmask.split(".") netmask=netmask_address[0] + "." + netmask_address[1] + ".0.0" - privnwlist,privnetmasklist=self.get_priv_nwlist() - if nwname: - self.log_info_message("The network card: " + nwname + " for the ip: " + ipcidr,self.file_name) - nwlist='''{0}:{1}:1,{2}'''.format(nwname,ipcidr,privnwlist) - netmasklist='''{0}:{1},{2}'''.format(nwname,netmask,privnetmasklist) + if self.check_key("CRS_GPC", self.ora_env_dict): + pubmask, pubsubnet, pubnwname = self.get_nwlist("public") + nwlist = '''{0}:{1}:6'''.format(pubnwname, pubsubnet) else: - self.log_error_message("Failed to get network card matching for the subnet:" + ipcidr ,self.file_name) - self.prog_exit("127") + privnwlist, privnetmasklist = self.get_priv_nwlist() + if nwname: + self.log_info_message("The network card: " + nwname + " for the ip: " + ipcidr, self.file_name) + nwlist = '''{0}:{1}:1,{2}'''.format(nwname, ipcidr, privnwlist) + netmasklist = '''{0}:{1},{2}'''.format(nwname, netmask, privnetmasklist) + else: + self.log_error_message("Failed to get network card matching for the subnet:" + ipcidr, self.file_name) + self.prog_exit("127") elif self.check_key("SINGLE_NETWORK",self.ora_env_dict): pubmask,pubsubnet,pubnwname=self.get_nwlist("public") nwlist='''{0}:{1}:1,{0}:{1}:5'''.format(pubnwname,pubsubnet) @@ -1409,101 +1419,156 @@ def get_db_params(self): return dbuser,dbhome,dbbase,oinv ######## Get the cmd ############### - def get_sw_cmd(self,key,rspfile,node,netmasklist): - """ - This function return the installation cmd - """ - cmd="" - copyflag="" - pwdparam='''oracle.install.asm.SYSASMPassword={0} oracle.install.asm.monitorPassword={0}'''.format("HIDDEN_STRING") - - if self.check_key("COPY_GRID_SOFTWARE",self.ora_env_dict): - copyflag=" -noCopy " + def get_sw_cmd(self, key, rspfile, node, netmasklist): + """ + This function returns the installation command. + """ + giuser, gihome, gbase, oinv = self.get_gi_params() + pwdparam = f'''oracle.install.asm.SYSASMPassword={"HIDDEN_STRING"} oracle.install.asm.monitorPassword={"HIDDEN_STRING"}''' + copyflag = " -noCopy " if self.check_key("COPY_GRID_SOFTWARE", self.ora_env_dict) else "" + prereq = " -ignorePreReq " if self.check_key("IGNORE_CRS_PREREQS", self.ora_env_dict) else " " + prereqfailure = " -ignorePrereqFailure " if self.check_key("IGNORE_CRS_PREREQS", self.ora_env_dict) else " " + snic = "-J-Doracle.install.crs.allowSingleNIC=true" if self.check_key("SINGLENIC", self.ora_env_dict) else "" + + if key == "INSTALL": + runCmd = "gridSetup.sh" + # Running only in Oracle Restart in RU Patch scenario, else setup fails + # if self.check_key("APPLY_RU_LOCATION", self.ora_env_dict) and self.check_key("CRS_GPC", self.ora_env_dict): + # runCmd += f''' -applyRU "{self.ora_env_dict["APPLY_RU_LOCATION"]}"''' + if self.check_key("DEBUG_MODE", self.ora_env_dict): + runCmd += " -debug" + + self.log_info_message(f"runCmd set to : {runCmd}", self.file_name) + + if self.detect_k8s_env(): + cmd_parts = [] + oraversion = self.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() + distid_env = "" + if int(version) == 19: + distid_env = "export CV_ASSUME_DISTID=OL8; " + if self.check_key("CRS_GPC", self.ora_env_dict): + gridCmd = f'''su - {giuser} -c "{distid_env}{gihome}/{runCmd} -waitforcompletion {copyflag} -silent -responseFile {rspfile} {prereqfailure}"''' + cmd_parts.append(gridCmd) + + if cmd_parts: + cmd = " && ".join(cmd_parts) + else: + param1 = f'''oracle.install.crs.config.netmaskList={netmasklist}''' if netmasklist else \ + '''oracle.install.crs.config.netmaskList=eth0:255.255.0.0,eth1:255.255.255.0,eth2:255.255.255.0''' + cmd = f'''su - {giuser} -c "{distid_env}{gihome}/{runCmd} -waitforcompletion {copyflag} -silent {snic} -responseFile {rspfile} {param1} {pwdparam} {prereqfailure}"''' + else: + cmd = f'''su - {giuser} -c "{gihome}/{runCmd} -waitforcompletion {copyflag} -silent {snic} -responseFile {rspfile} {prereq} {pwdparam}"''' + elif key == 'ADDNODE': + status = self.check_home_inv(None, gihome, giuser) + if status: + copyflag = " -noCopy " + else: + copyflag = " " + cmd = f'''su - {giuser} -c "ssh {node} '{gihome}/gridSetup.sh -silent -waitForCompletion {copyflag} {prereq} -responseFile {rspfile}'"''' + else: + cmd = "" + return cmd - prereq=" " - if self.check_key("IGNORE_CRS_PREREQS",self.ora_env_dict): - prereq=" -ignorePreReq " +########## Installing Grid Software on Individual nodes + def crs_sw_install_on_node(self, giuser, copyflag, crs_nodes, oinv, gihome, gibase, osdba, osoper, osasm, version, node): + """ + This function installs CRS software on each node and registers it with oraInventory + """ + cmd = None + prereq = " " + apply_ru = "" + apply_oneoff= "" + distid_env = "" - giuser,gihome,gbase,oinv=self.get_gi_params() - snic="-J-Doracle.install.crs.allowSingleNIC=true" if self.check_key("SINGLENIC",self.ora_env_dict) else "" - runCmd="" - if key == "INSTALL": - if self.check_key("APPLY_RU_LOCATION",self.ora_env_dict): - self.opatch_apply() - ruLoc=self.ora_env_dict["APPLY_RU_LOCATION"] - runCmd='''gridSetup.sh -applyRU "{0}"'''.format(self.ora_env_dict["APPLY_RU_LOCATION"]) - else: - runCmd='''gridSetup.sh ''' - - - if self.check_key("DEBUG_MODE",self.ora_env_dict): - dbgCmd='''{0} -debug '''.format(runCmd) - runCmd=dbgCmd - - self.log_info_message("runCmd set to : {0}".format(runCmd),self.file_name) - if self.detect_k8s_env(): - #param1="-skipPrereqs -J-Doracle.install.grid.validate.all=false oracle.install.crs.config.netmaskList=eth0:255.255.0.0,eth0:255.255.0.0" - if netmasklist is not None: - param1='''oracle.install.crs.config.netmaskList={0}'''.format(netmasklist) - else: - param1='''oracle.install.crs.config.netmaskList=eth0:255.255.0.0,eth1:255.255.255.0,eth2:255.255.255.0'''.format(netmasklist) + if self.check_key("IGNORE_CRS_PREREQS", self.ora_env_dict): + prereq = " -ignorePreReq " - cmd='''su - {0} -c "{1}/{6} -waitforcompletion {4} -silent {3} -responseFile {2} {5} {7}"'''.format(giuser,gihome,rspfile,snic,copyflag,param1,runCmd,pwdparam) - else: - if self.check_key("APPLY_RU_LOCATION",self.ora_env_dict): - cmd='''su - {0} -c "{1}/{5} -waitforcompletion {4} -silent {6} {3} -responseFile {2} {7}"'''.format(giuser,gihome,rspfile,snic,copyflag,runCmd,prereq,pwdparam) - else: - cmd='''su - {0} -c "{1}/{5} -waitforcompletion {4} -silent {6} {3} -responseFile {2} {7}"'''.format(giuser,gihome,rspfile,snic,copyflag,runCmd,prereq,pwdparam) - elif key == 'ADDNODE': - status=self.check_home_inv(None,gihome,giuser) - if status: - copyflag=" -noCopy " - cmd='''su - {0} -c "ssh {1} '{2}/gridSetup.sh -silent -waitForCompletion {3} {5} -responseFile {4}'"'''.format(giuser,node,gihome,copyflag,rspfile,prereq) - else: - copyflag=" " - cmd='''su - {0} -c "ssh {1} '{2}/gridSetup.sh -silent -waitForCompletion {3} {5} -responseFile {4} '"'''.format(giuser,node,gihome,copyflag,rspfile,prereq) - else: - pass - return cmd + # Determine Oracle version + oraversion = self.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() -########## Installing Grid Software on Individual nodes - def crs_sw_install_on_node(self,giuser,copyflag,crs_nodes,oinv,gihome,gibase,osdba,osoper,osasm,version,node): - """ - This function install crs sw on every node and register with oraInventory - """ - cmd=None - prereq=" " - if self.check_key("IGNORE_CRS_PREREQS",self.ora_env_dict): - prereq=" -ignorePreReq " - if int(version) < 23: - rspdata='''su - {0} -c "ssh {10} {1}/gridSetup.sh {11} -waitforcompletion {2} -silent + self.log_info_message("disk" + version, self.file_name) + self.opatch_apply(node) + + # Returning only in Oracle Restart in RU Patch scenario, else below command fails in Oracle Restart + # if int(version) == 19 and self.check_key("APPLY_RU_LOCATION", self.ora_env_dict): + # if self.check_key("CRS_GPC", self.ora_env_dict): + # self.log_info_message("Oracle Restart RU patch scenario detected. Skipping crs_sw_install_on_node", self.file_name) + # return + + # Handle Oracle 19c (special case) + if int(version) == 19: + distid_env = "export CV_ASSUME_DISTID=OL8; " + + if self.check_key("APPLY_RU_LOCATION", self.ora_env_dict): + self.log_info_message("Oracle RU Patch deployment detected.", self.file_name) + apply_ru = ''' -applyRU "{0}" '''.format(self.ora_env_dict["APPLY_RU_LOCATION"]) + + if self.check_key("ONEOFF_FOLDER_NAME", self.ora_env_dict) and self.check_key("ONEOFF_IDS", self.ora_env_dict): + one_off_ids=self.ora_env_dict["ONEOFF_IDS"] + one_off_ids_with_location="" + for id in one_off_ids: + one_off_ids_with_location=one_off_ids_with_location+","+self.ora_env_dict["APPLY_RU_LOCATION"]+"/"+id + apply_oneoff = ''' --applyOneOffs "{0}" '''.format(one_off_ids_with_location) + + if int(version) < 23: + rspdata = '''su - {0} -c "ssh {10} '{11}{1}/gridSetup.sh {12} {13} {14} -waitforcompletion {2} -silent oracle.install.option=CRS_SWONLY INVENTORY_LOCATION={4} ORACLE_HOME={5} ORACLE_BASE={6} oracle.install.asm.OSDBA={7} oracle.install.asm.OSOPER={8} - oracle.install.asm.OSASM={9}"'''.format(giuser,gihome,copyflag,crs_nodes,oinv,gihome,gibase,osdba,osoper,osasm,node,prereq) - - cmd=rspdata.replace('\n'," ") - else: - cmd='''su - {0} -c "ssh {10} '{1}/gridSetup.sh -silent -setupHome -OSDBA {7} -OSOPER {8} -OSASM {9} -ORACLE_BASE {6} -INVENTORY_LOCATION {4} -clusterNodes {10} {2}\'"'''.format(giuser,gihome,copyflag,crs_nodes,oinv,gihome,gibase,osdba,osoper,osasm,node) + oracle.install.asm.OSASM={9}'"'''.format( + giuser, gihome, copyflag, crs_nodes, oinv, gihome, gibase, osdba, osoper, osasm, node, distid_env, prereq, apply_ru, apply_oneoff + ) - output,error,retcode=self.execute_cmd(cmd,None,None) - self.check_os_err(output,error,retcode,None) - self.check_crs_sw_install(output) + cmd = rspdata.replace('\n', ' ') + else: + # For version 23 and above, you may need to modify the command accordingly + cmd = '''su - {0} -c "ssh {10} '{11}{1}/gridSetup.sh -silent -setupHome -OSDBA {7} -OSOPER {8} -OSASM {9} -ORACLE_BASE {6} -INVENTORY_LOCATION {4} -clusterNodes {10} {2}'"'''.format( + giuser, gihome, copyflag, crs_nodes, oinv, gihome, gibase, osdba, osoper, osasm, node, distid_env + ) + + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + self.check_crs_sw_install(output) + # if int(version) == 19: + # self.log_info_message("Running clean_oracle_dirs()",self.file_name) + # self.clean_oracle_dirs(node) + # self.log_info_message("Ended clean_oracle_dirs()",self.file_name) - def opatch_apply(self): - """This function apply opatch before apply RU - """ - giuser,gihome,gbase,oinv=self.get_gi_params() - today=datetime.date.today() - if self.check_key("OPATCH_ZIP_FILE",self.ora_env_dict): - cmd1='''su - {2} -c "mv {0}/OPatch {0}/OPatch_{1}_old"'''.format(gihome,today,giuser) - cmd2='''su - {2} -c "unzip {0} -d {1}/"'''.format(self.ora_env_dict["OPATCH_ZIP_FILE"],gihome,giuser) - for cmd in cmd1,cmd2: - output,error,retcode=self.execute_cmd(cmd,None,True) - self.check_os_err(output,error,retcode,True) + def opatch_apply(self, node): + """Apply OPatch on both GI and DB homes remotely via SSH.""" + today = datetime.date.today() + + # GI parameters + giuser, gihome, gbase, oinv = self.get_gi_params() + if self.check_key("OPATCH_ZIP_FILE", self.ora_env_dict): + cmd1 = '''su - {2} -c "ssh {3} 'mv {0}/OPatch {0}/OPatch_{1}_old'"'''.format( + gihome, today, giuser, node + ) + cmd2 = '''su - {2} -c "ssh {3} 'unzip -q {0} -d {1}/'"'''.format( + self.ora_env_dict["OPATCH_ZIP_FILE"], gihome, giuser, node + ) + for cmd in (cmd1, cmd2): + output, error, retcode = self.execute_cmd(cmd, None, True) + self.check_os_err(output, error, retcode, True) + + # DB parameters + dbuser, dbhome, dbase, oinv = self.get_db_params() + if self.check_key("OPATCH_ZIP_FILE", self.ora_env_dict): + cmd1 = '''su - {2} -c "ssh {3} 'mv {0}/OPatch {0}/OPatch_{1}_old'"'''.format( + dbhome, today, dbuser, node + ) + cmd2 = '''su - {2} -c "ssh {3} 'unzip -q {0} -d {1}/'"'''.format( + self.ora_env_dict["OPATCH_ZIP_FILE"], dbhome, dbuser, node + ) + for cmd in (cmd1, cmd2): + output, error, retcode = self.execute_cmd(cmd, None, True) + self.check_os_err(output, error, retcode, True) + def check_crs_sw_install(self,swdata): """ @@ -1585,11 +1650,14 @@ def check_gi_installed(self,retcode1,gihome,giuser,node,oinv): return False else: self.run_orainstsh_local(giuser,node,oinv) - status=self.start_crs(gihome,giuser) - if status: - return True + if self.check_key("CRS_GPC", self.ora_env_dict): + return True else: - return False + status=self.start_crs(gihome,giuser) + if status: + return True + else: + return False else: bstr="Grid is not configured on this machine and /etc/oracle does not exist." self.log_info_message(self.print_banner(bstr),self.file_name) @@ -1598,25 +1666,65 @@ def check_gi_installed(self,retcode1,gihome,giuser,node,oinv): self.log_info_message("Grid is not installed on this machine. Proceeding further...",self.file_name) return False -######## Restoring GI FIles ####################### - def restore_gi_files(self,gihome,giuser): + + def restore_gi_files(self, gihome, giuser): + """ + Restoring GI Files + """ + giuser, gihome, gibase, oinv = self.get_gi_params() + srcdir=gibase+"/.etcoraclebackup" + oraversion=self.get_rsp_version("INSTALL",None) + version = oraversion.split(".", 1)[0].strip() + self.log_info_message("restore_gi_files" + version, self.file_name) + if int(version) == 19 and self.check_key("CRS_GPC", self.ora_env_dict): + files = os.listdir(srcdir) + if files: + cmd = 'cp -rp {0}/oracle /etc/'.format(srcdir) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + oracle_home = gihome + cmd = ( + 'export ORACLE_HOME={0} && ' + '{0}/perl/bin/perl -I{0}/perl/lib -I{0}/crs/install -I{0}/xag ' + '{0}/crs/install/roothas.pl -updateosfiles' + ).format(oracle_home) + + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + if retcode == 0: + status = self.start_has(gihome, giuser) + return bool(status) + else: + return False + else: + # If no files, run rootcrs.sh to update os files + cmd = '{0}/crs/install/rootcrs.sh -updateosfiles'.format(gihome) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + if retcode == 0: + return True + else: + return False + +###### Starting Crs ############### + def start_crs(self,gihome,giuser): """ - Restoring GI Files + starting CRS """ - cmd='''{1}/crs/install/rootcrs.sh -updateosfiles'''.format(giuser,gihome) + cmd='''{1}/bin/crsctl start crs'''.format(giuser,gihome) output,error,retcode=self.execute_cmd(cmd,None,None) self.check_os_err(output,error,retcode,None) if retcode == 0: - return True + return True else: - return False + return False -###### Starting Crs ############### - def start_crs(self,gihome,giuser): +###### Starting Has ############### + def start_has(self,gihome,giuser): """ - starting CRS + starting HAS """ - cmd='''{1}/bin/crsctl start crs'''.format(giuser,gihome) + cmd='''{1}/bin/crsctl start has'''.format(giuser,gihome) output,error,retcode=self.execute_cmd(cmd,None,None) self.check_os_err(output,error,retcode,None) if retcode == 0: @@ -1956,8 +2064,9 @@ def process_service_vars(self,key,type): service = cvar_dict[ckey] sparam=sparam + " -service " + service if ckey == 'preferred': - preferred = cvar_dict[ckey] - sparam=sparam +" -modifyconfig -preferred " + preferred + if not self.ora_env_dict.get("CRS_GPC"): + preferred = cvar_dict[ckey] + sparam=sparam +" -modifyconfig -preferred " + preferred if ckey == 'available': available = cvar_dict[ckey] sparam=sparam +" -available " + available @@ -1969,8 +2078,9 @@ def process_service_vars(self,key,type): role = cvar_dict[ckey] sparam=sparam +" -role " + role if ckey == 'preferred': - preferred = cvar_dict[ckey] - sparam=sparam +" -preferred " + preferred + if not self.ora_env_dict.get("CRS_GPC"): + preferred = cvar_dict[ckey] + sparam=sparam +" -preferred " + preferred if ckey == 'available': available = cvar_dict[ckey] sparam=sparam +" -available " + available @@ -2045,22 +2155,23 @@ def process_service_vars(self,key,type): else: pdb = self.ora_env_dict["ORACLE_PDB_NAME"] if self.check_key("ORACLE_PDB_NAME",self.ora_env_dict) else "ORCLPDB" - if preferred is None: - osuser,dbhome,dbbase,oinv=self.get_db_params() - dbname,osid,dbuname=self.getdbnameinfo() - hostname = self.get_public_hostname() - inst_sid=self.get_inst_sid(osuser,dbhome,osid,hostname) - connect_str=self.get_sqlplus_str(dbhome,inst_sid,osuser,"sys",None,None,None,None,None,None,None) - dbsid=self.get_host_dbsid(None,connect_str) - preferred=",".join(dbsid.splitlines()) - if type.lower() == 'modify': - sparam=sparam +" -modifyconfig -preferred " + preferred - else: - sparam=sparam +" -preferred " + preferred + if preferred is None and not self.ora_env_dict.get("CRS_GPC"): + osuser, dbhome, dbbase, oinv = self.get_db_params() + dbname, osid, dbuname = self.getdbnameinfo() + hostname = self.get_public_hostname() + inst_sid = self.get_inst_sid(osuser, dbhome, osid, hostname) + connect_str = self.get_sqlplus_str(dbhome, inst_sid, osuser, "sys", None, None, None, None, None, None, None) + dbsid = self.get_host_dbsid(None, connect_str) + preferred = ",".join(dbsid.splitlines()) + if type.lower() == 'modify': + sparam = sparam + " -modifyconfig -preferred " + preferred + else: + sparam = sparam + " -preferred " + preferred + if db is None: - db=self.ora_env_dict["DB_NAME"] if self.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" - sparam=sparam +" -db " + db + db=self.ora_env_dict["DB_NAME"] if self.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" + sparam=sparam +" -db " + db if service and db and pdb: return service,db,pdb,uniformflag,sparam @@ -2113,11 +2224,9 @@ def check_db_service_exist(self,service_name,osid): cmd='''su - {4} -c "export ORACLE_HOME={0};export PATH={1};export LD_LIBRARY_PATH={2}; {0}/bin/srvctl status service -db {3} -s {5}"'''.format(dbhome,path,ldpath,osid,dbuser,service_name) output,error,retcode=self.execute_cmd(cmd,None,None) self.check_os_err(output,error,retcode,None) - msg='''PRKO-2017'''.format(service_name,osid) - if self.check_substr_match(output.lower(),msg.lower()): - return False - else: - return True + if "does not exist" in output.lower(): + return False + return True ##### check service ###### def check_db_service_status(self,service_name,osid): @@ -2209,18 +2318,113 @@ def update_scan(self,user,home,endpoints,node): output,error,retcode=self.execute_cmd(cmd,None,None) self.check_os_err(output,error,retcode,None) -######### Add RAC DB ######## - def start_scan(self,user,home,node): + def stop_scan(self, user, home, node): """ - Update Scan + Disable and stop only the SCAN VIP not running on the specified node. """ - path='''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) - ldpath='''{0}/lib:/lib:/usr/lib'''.format(home) - scanname=self.ora_env_dict["SCAN_NAME"] - cmd='''su - {3} -c "ssh {5} 'export ORACLE_HOME={0};export PATH={1};export LD_LIBRARY_PATH={2};sudo {0}/bin/srvctl start scan'"'''.format(home,path,ldpath,user,scanname,node) - output,error,retcode=self.execute_cmd(cmd,None,None) - self.check_os_err(output,error,retcode,None) + path = '''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) + ldpath = '''{0}/lib:/lib:/usr/lib'''.format(home) + + # Check SCAN status + status_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};{2}/bin/srvctl status scan'"'''.format(user, node, home, path, ldpath) + output, error, retcode = self.execute_cmd(status_cmd, None, None) + self.check_os_err(output, error, retcode, None) + + for line in output.splitlines(): + if "SCAN VIP" in line and "is running" in line and node in line: + parts = line.strip().split() + if len(parts) >= 4: + scan_vip = parts[2] # scan3 + scan_number = scan_vip.replace("scan", "") # 3 + + # Stop + stop_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};sudo {2}/bin/srvctl stop scan -scannumber {5}'"'''.format(user, node, home, path, ldpath, scan_number) + out2, err2, code2 = self.execute_cmd(stop_cmd, None, None) + self.check_os_err(out2, err2, code2, None) + + # Disable + disable_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};sudo {2}/bin/srvctl disable scan -scannumber {5}'"'''.format(user, node, home, path, ldpath, scan_number) + out1, err1, code1 = self.execute_cmd(disable_cmd, None, None) + self.check_os_err(out1, err1, code1, None) + + + def start_scan(self, user, home, node): + """ + Start only the SCAN VIP that is not running on the given node. + """ + path = '''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) + ldpath = '''{0}/lib:/lib:/usr/lib'''.format(home) + # Check SCAN status + status_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};{2}/bin/srvctl status scan'"'''.format(user, node, home, path, ldpath) + output, error, retcode = self.execute_cmd(status_cmd, None, None) + self.check_os_err(output, error, retcode, None) + + # Check for any SCAN VIP that is not running and start only that one + for line in output.splitlines(): + if "SCAN VIP" in line and "is not running" in line: + parts = line.strip().split() + if len(parts) >= 4: + scan_vip = parts[2] # e.g., scan3 + scan_number = scan_vip.replace("scan", "") # e.g., 3 + + start_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};sudo {2}/bin/srvctl start scan -scannumber {5}'"'''.format(user, node, home, path, ldpath, scan_number) + out, err, code = self.execute_cmd(start_cmd, None, None) + self.check_os_err(out, err, code, None) + + def start_scan_lsnr(self, user, home, node): + """ + Start only the SCAN listener that is not running on the given node. + """ + path = '''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) + ldpath = '''{0}/lib:/lib:/usr/lib'''.format(home) + + # Check SCAN listener status + status_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};{2}/bin/srvctl status scan_listener'"'''.format(user, node, home, path, ldpath) + output, error, retcode = self.execute_cmd(status_cmd, None, None) + self.check_os_err(output, error, retcode, None) + + # Start only not running scan listeners + for line in output.splitlines(): + if "is not running" in line and "SCAN listener" in line: + parts = line.strip().split() + if len(parts) >= 4: + lsnr_name = parts[2] # e.g., LISTENER_SCAN3 + lsnr_number = lsnr_name.replace("LISTENER_SCAN", "") # e.g., 3 + + start_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};{2}/bin/srvctl start scan_listener -scannumber {5}'"'''.format(user, node, home, path, ldpath, lsnr_number) + out, err, code = self.execute_cmd(start_cmd, None, None) + self.check_os_err(out, err, code, None) + def stop_scan_lsnr(self, user, home, node): + """ + Disable and stop only the SCAN listener not running on the specified node. + """ + path = '''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) + ldpath = '''{0}/lib:/lib:/usr/lib'''.format(home) + + # Check scan listener status + status_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};{2}/bin/srvctl status scan_listener'"'''.format(user, node, home, path, ldpath) + output, error, retcode = self.execute_cmd(status_cmd, None, None) + self.check_os_err(output, error, retcode, None) + + for line in output.splitlines(): + if "SCAN listener" in line and "is running" in line and node in line: + parts = line.strip().split() + if len(parts) >= 4: + lsnr_name = parts[2] # LISTENER_SCAN3 + lsnr_number = lsnr_name.replace("LISTENER_SCAN", "") # 3 + # Stop + stop_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};sudo {2}/bin/srvctl stop scan_listener -scannumber {5}'"'''.format(user, node, home, path, ldpath, lsnr_number) + out2, err2, code2 = self.execute_cmd(stop_cmd, None, None) + self.check_os_err(out2, err2, code2, None) + + # Disable + disable_cmd = '''su - {0} -c "ssh {1} 'export ORACLE_HOME={2};export PATH={3};export LD_LIBRARY_PATH={4};sudo {2}/bin/srvctl disable scan_listener -scannumber {5}'"'''.format(user, node, home, path, ldpath, lsnr_number) + out1, err1, code1 = self.execute_cmd(disable_cmd, None, None) + self.check_os_err(out1, err1, code1, None) + + + ######### Add RAC DB ######## def update_scan_lsnr(self,user,home,node): """ @@ -2232,17 +2436,6 @@ def update_scan_lsnr(self,user,home,node): cmd='''su - {3} -c "ssh {4} 'export ORACLE_HOME={0};export PATH={1};export LD_LIBRARY_PATH={2};{0}/bin/srvctl modify scan_listener -update'"'''.format(home,path,ldpath,user,node) output,error,retcode=self.execute_cmd(cmd,None,None) self.check_os_err(output,error,retcode,None) -######### Add RAC DB ######## - def start_scan_lsnr(self,user,home,node): - """ - start Scan listener - """ - path='''/usr/bin:/bin:/sbin:/usr/local/sbin:{0}/bin'''.format(home) - ldpath='''{0}/lib:/lib:/usr/lib'''.format(home) - scanname=self.ora_env_dict["SCAN_NAME"] - cmd='''su - {3} -c "ssh {4} 'export ORACLE_HOME={0};export PATH={1};export LD_LIBRARY_PATH={2};{0}/bin/srvctl start scan_listener'"'''.format(home,path,ldpath,user,node) - output,error,retcode=self.execute_cmd(cmd,None,None) - self.check_os_err(output,error,retcode,None) ######### Set DB Lsnr ######## def setup_db_lsnr(self): @@ -2477,9 +2670,14 @@ def perform_db_check(self,type): self.run_custom_scripts("CUSTOM_DB_SCRIPT_DIR","CUSTOM_DB_SCRIPT_FILE",dbuser) msg='''Oracle Database {0} is up and running on {1}.'''.format(osid,host) self.log_info_message(self.print_banner(msg),self.file_name) - os.system("echo ORACLE RAC DATABASE IS READY TO USE > /dev/pts/0") - msg='''ORACLE RAC DATABASE IS READY TO USE''' - self.log_info_message(self.print_banner(msg),self.file_name) + if self.ora_env_dict.get("CRS_GPC"): + os.system("echo ORACLE DATABASE IS READY TO USE > /dev/pts/0") + msg = '''ORACLE DATABASE IS READY TO USE''' + self.log_info_message(self.print_banner(msg),self.file_name) + else: + os.system("echo ORACLE RAC DATABASE IS READY TO USE > /dev/pts/0") + msg = '''ORACLE RAC DATABASE IS READY TO USE''' + self.log_info_message(self.print_banner(msg),self.file_name) else: msg='''Oracle Database {0} is not up and running on {1}.'''.format(osid,host) self.log_info_message(self.print_banner(msg),self.file_name) @@ -2984,8 +3182,9 @@ def setdgprefix(self,dgname): add dg prefix """ dgflag = dgname.startswith("+") + stype=self.ora_env_dict["DB_STORAGE_TYPE"] if self.check_key("DB_STORAGE_TYPE",self.ora_env_dict) else "ASM" - if not dgflag: + if stype == "ASM" and not dgflag: dgname= "+" + dgname self.log_info_message("The dgname set to : " + dgname, self.file_name) @@ -3198,27 +3397,40 @@ def updatelistenerendp(self,giuser,gihome,listenername,portlist): else: return False - def get_asmsid(self,giuser,gihome): - """ - get the asm sid details - """ - sid=None - cmd='''su - {0} -c "{1}/bin/olsnodes -n"'''.format(giuser,gihome) - output,error,retcode=self.execute_cmd(cmd,None,None) - self.check_os_err(output,error,retcode,None) - if retcode == 0: - pubhost=self.get_public_hostname() - for line in output.splitlines(): - if pubhost in line: - nodeid = line.split() - if len(nodeid) == 2: - sid="+ASM" + nodeid[1] - break - if sid is not None: - self.log_info_message("ASM sid set to :" + sid,self.file_name) - return sid - else: - return None + def get_asmsid(self, giuser, gihome): + """ + get the asm sid details + """ + sid = None + if self.check_key("CRS_GPC", self.ora_env_dict): + # Oracle Restart environment + cmd = '''su - {0} -c "{1}/bin/crsctl status resource ora.asm -f"'''.format(giuser, gihome) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + if retcode == 0: + for line in output.splitlines(): + if line.startswith(("GEN_USR_ORA_INST_NAME=", "USR_ORA_INST_NAME=")): + sid = line.split("=")[1] + break + else: + # RAC environment + cmd = '''su - {0} -c "{1}/bin/olsnodes -n"'''.format(giuser, gihome) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + if retcode == 0: + pubhost = self.get_public_hostname() + for line in output.splitlines(): + if pubhost in line: + nodeid = line.split() + if len(nodeid) == 2: + sid = "+ASM" + nodeid[1] + break + + if sid is not None: + self.log_info_message("ASM sid set to :" + sid, self.file_name) + return sid + else: + return None def check_asminst(self,giuser,gihome): """ @@ -3238,10 +3450,11 @@ def check_asminst(self,giuser,gihome): output,error,retcode=self.run_sqlplus(sqlpluslogincmd,sqlcmd,None) self.log_info_message("Calling check_sql_err() to validate the sql command return status",self.file_name) self.check_sql_err(output,error,retcode,True) - if "STARTED" in ''.join(output.upper()): - return 0 + if "STARTED" in ''.join(output).upper() or "OPEN" in ''.join(output).upper(): + return 0 else: - return 1 + return 1 + def get_asmdg(self,giuser,gihome): """ @@ -3264,7 +3477,7 @@ def get_asmdg(self,giuser,gihome): def get_asmdgrd(self,giuser,gihome,dg): """ - get the asm disk redudancy + get the asm disk redundancy """ sid=self.get_asmsid(giuser,gihome) if sid is not None: @@ -3281,15 +3494,148 @@ def get_asmdgrd(self,giuser,gihome,dg): self.check_sql_err(output,error,retcode,True) return output - def get_asmdsk(self,giuser,gihome,dg): + def get_asmdsk(self, giuser, gihome, dg): """ check asm disks based on dg group """ - sid=self.get_asmsid(giuser,gihome) - cmd='''su - {0} -c "asmcmd lsdsk -G {1} --suppressheader --member"'''.format(giuser,dg) - output,error,retcode=self.execute_cmd(cmd,None,None) - self.check_os_err(output,error,retcode,None) + sid = self.get_asmsid(giuser, gihome) + cmd = '''su - {0} -c "export ORACLE_SID={1};{2}/bin/asmcmd lsdsk --suppressheader --member"'''.format(giuser, sid, gihome, dg) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) if retcode == 0: - return output.strip().replace('\n',',') + return output.strip().replace('\n', ',') else: - return "ERROR OCCURRED" + return "ERROR OCCURRED" + + + def add_cdp(self): + """ + Add one or more CDPs to the existing RAC cluster. + Works if ADD_CDP is a single node or a comma-separated list of nodes. + """ + giuser, gihome, obase, invloc = self.get_gi_params() + self.log_info_message("Adding CDP to the existing RAC cluster details", self.file_name) + + if not self.check_key("ADD_CDP", self.ora_env_dict): + return True # nothing to add + + # Handle single or multiple nodes + node_list = [n.strip() for n in self.ora_env_dict["ADD_CDP"].split(",") if n.strip()] + + success = True + for nodename in node_list: + # Construct and execute the command + cmd = '''su - {0} -c "{1}/bin/srvctl start cdp -node {2}"'''.format(giuser, gihome, nodename) + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + + retvalue = False + if retcode != 0: + # Verify if CDP is already running + cmd = '''su - {0} -c "{1}/bin/srvctl status cdp"'''.format(giuser, gihome) + output, error, retcode = self.execute_cmd(cmd, None, None) + retvalue = nodename in output + else: + retvalue = True # command succeeded + + if not retvalue: + msg = "CDP {0} didn't get added to the existing RAC cluster".format(nodename) + self.log_info_message(msg, self.file_name) + success = False + else: + msg = "New CDP {0} is now added to the RAC cluster".format(nodename) + self.log_info_message(msg, self.file_name) + + if not success: + self.prog_exit("Error occurred while adding CDPs") + + return success + + + def update_ons(self, giuser, gihome, onsstate): + """ + Update ONS details based on the onsstate: + - start : enable and start ONS (skip if already enabled and running) + - stop : stop and disable ONS + - enable : only enable ONS + - disable : only disable ONS + - status : get ONS status + """ + def run_cmd(action): + cmd = f'''su - {giuser} -c "{gihome}/bin/srvctl {action} ons"''' + output, error, retcode = self.execute_cmd(cmd, None, None) + self.check_os_err(output, error, retcode, None) + return output.strip(), retcode + + if onsstate == "start": + # Check current status + status_output, status_ret = run_cmd("status") + if status_ret != 0: + return False + + lower_status = status_output.lower() + # Example: "ons is enabled and running on node(s): ..." + if "enabled" in lower_status and ("running" in lower_status or "online" in lower_status): + # Already enabled and running + return True + + # Enable if not enabled + if "enabled" not in lower_status: + if run_cmd("enable")[1] != 0: + return False + + # Start if not running + return run_cmd("start")[1] == 0 + + elif onsstate == "stop": + return run_cmd("stop")[1] == 0 and run_cmd("disable")[1] == 0 + + elif onsstate in {"enable", "disable", "status"}: + return run_cmd(onsstate)[1] == 0 + + return False + + def clean_oracle_dirs(self, node): + """ + Removes /u01/app/oraInventory and /u01/app/grid on a remote node, + then sets correct ownership and permissions on /u01/app. + """ + try: + giuser, _, _, _ = self.get_gi_params() # GI user for ownership tasks + + cmds = [ + "sudo rm -rf /u01/app/oraInventory", + "sudo rm -rf /u01/app/grid", + "sudo chown -R grid:oinstall /u01/app", + "sudo chmod 775 /u01/app" + ] + + for cmd in cmds: + remote_cmd = '''su - {0} -c "ssh {1} '{2}'"'''.format(giuser, node, cmd) + output, error, retcode = self.execute_cmd(remote_cmd, None, True) + self.check_os_err(output, error, retcode, True) + self.log_info_message("Executed on {}: {}".format(node, cmd), self.file_name) + + except Exception as e: + self.log_error_message( + "Failed to clean and reset /u01/app directories on {}: {}".format(node, str(e)), + self.file_name + ) + + +######## Get the dbversion ############### + def get_ora_version(self): + """ + This function return the complete db version in a.b.c.d.e + """ + cmd="" + giuser,gihome,gbase,oinv=self.get_gi_params() + cmd='''su - {0} -c "{1}/bin/oraversion -compositeVersion"'''.format(giuser,gihome) + + vdata="" + output,error,retcode=self.execute_cmd(cmd,None,None) + self.check_os_err(output,error,retcode,None) + vdata=output.strip() + self.log_info_message("get_ora_version():[" + vdata + "]", self.file_name) + major_version,minor_version,other_version=vdata.split(".",2) + return major_version,minor_version diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracvu.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracvu.py index f7b2b29401..4920931fdf 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracvu.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oracvu.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################# +############################ """ This file contains to the code call different classes objects based on setup type @@ -181,7 +181,7 @@ def check_asm(self,node): self.ocommon.check_os_err(output,error,retcode,None) return retcode - def check_clu(self,node,sshflag): + def check_clu(self,node,sshflag,crsflag): """ This function check if crs is configued properly """ @@ -197,7 +197,11 @@ def check_clu(self,node,sshflag): if sshflag: crs_nodes=" -n " + node cmd='''su - {0} -c "ssh {3} '{1}/bin/cluvfy comp clumgr {2}'"'''.format(giuser,gihome,crs_nodes,node) - + + if crsflag: + crs_nodes=" -n " + node + cmd='''su - {0} -c "ssh {3} '{1}/bin/cluvfy stage -post hacfg'"'''.format(giuser,gihome,crs_nodes,node) + output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.check_os_err(output,error,retcode,None) return retcode @@ -259,3 +263,59 @@ def check_addnode(self): else: self.ocommon.check_os_err(output,error,retcode,None) + def check_db_home(self, node, db_home, user): + """ + This function checks if the Oracle Database home is installed correctly + """ + giuser, gihome, gbase, oinv = self.ocommon.get_gi_params() + oracle_home = db_home + + if not node: + crs_nodes = " -allnodes " + else: + crs_nodes = " -n " + node + + cvufile = '''{0}/bin/cluvfy'''.format(gihome) + if not self.ocommon.check_file(cvufile, True, None, None): + return 1 + + cmd = '''su - {0} -c "{1}/bin/cluvfy stage -post dbinst -d {3}"'''.format(user, gihome, node, db_home) + output, error, retcode = self.ocommon.execute_cmd(cmd, None, None) + if retcode == 0: + return 0 + else: + return 1 + + def check_db_home_has(self, node, db_home, user): + """ + This function checks if the Oracle Database home is installed correctly + by running OPatch lsinventory on each node individually. + """ + + # Get GI params in case needed later + giuser, gihome, gbase, oinv = self.ocommon.get_gi_params() + + if not node: + import socket + node_list = [socket.gethostname()] + else: + node_list = [n.strip() for n in node.split(',')] + + for each_node in node_list: + self.ocommon.log_info_message("Checking DB home inventory on node: " + each_node, self.file_name) + + # Build and run the OPatch lsinventory command remotely + cmd = '''su - {0} -c "ssh {1} '{2}/OPatch/opatch lsinventory'"'''.format(user, each_node, db_home) + output, error, retcode = self.ocommon.execute_cmd(cmd, None, None) + + # Check for execution success + if retcode != 0 or not output or "Oracle Home" not in output: + self.ocommon.log_error_message("OPatch lsinventory failed or output invalid on node: " + each_node, self.file_name) + return 1 + + return 0 + + + + + diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraenv.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraenv.py index b562f5851d..fcfcf208ac 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraenv.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraenv.py @@ -116,13 +116,13 @@ def logfile_name(file_type): """ Static access method to return the logfile name. """ if file_type == "NONE": if "LOGFILE_NAME" not in OraEnv.__env_var_dict: - OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_rac_setup.log" + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_db_setup.log" elif file_type == "DEL_PARAMS": - OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_rac_del.log" + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_db_del.log" elif file_type == "RESET_PASSWORD": - OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_rac_reset_passwd.log" + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_db_reset_passwd.log" elif file_type == "ADD_TNS": - OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_rac_populate_tns_file.log" + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_db_populate_tns_file.log" elif file_type == "CHECK_RAC_INST": OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_check_rac_inst_file.log" elif file_type == "CHECK_GI_LOCAL": @@ -160,7 +160,7 @@ def logfile_name(file_type): elif file_type == "LIST_ASMDISKS": OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_list_asmdisks_status.log" elif file_type == "LIST_ASMDGREDUNDANCY": - OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_list_asmdgredudancy_status.log" + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_list_asmdgredundancy_status.log" elif file_type == "LIST_ASMINSTNAME": OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_list_asminstname_status.log" elif file_type == "LIST_ASMINSTSTATUS": @@ -169,6 +169,8 @@ def logfile_name(file_type): OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_update_listenerendp_status.log" elif file_type == "RUN_DATAPATCH": OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_rundatapatch_status.log" + elif file_type == "ONS": + OraEnv.__env_var_dict["LOG_FILE_NAME"] = OraEnv.logdir__ + "/oracle_ons_status.log" else: pass diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiadd.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiadd.py index fbbfe394b7..b5122d8a89 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiadd.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiadd.py @@ -89,6 +89,10 @@ def setup(self): self.ocommon.start_scan(giuser,gihome,pubhostname) self.ocommon.update_scan_lsnr(giuser,gihome,pubhostname) self.ocommon.start_scan_lsnr(giuser,gihome,pubhostname) + if self.ocommon.check_key("ADD_CDP",self.ora_env_dict): + self.ocommon.log_info_message("Start addcdp()",self.file_name) + self.addcdp() + self.ocommon.log_info_message("End addcdp()",self.file_name) ct = datetime.datetime.now() ets = ct.timestamp() totaltime=ets - bts @@ -131,7 +135,7 @@ def clu_checks(self,hostname): self.ocommon.log_info_message("Performing CVU checks before DB home installation to make sure clusterware is up and running",self.file_name) retcode1=self.ocvu.check_ohasd(hostname) retcode2=self.ocvu.check_asm(hostname) - retcode3=self.ocvu.check_clu(hostname,None) + retcode3=self.ocvu.check_clu(hostname,None,None) if retcode1 == 0: msg="Cluvfy ohasd check passed!" @@ -185,7 +189,7 @@ def crs_sw_configure(self): nodeflag=False existing_crs_nodes=self.ocommon.get_existing_clu_nodes(True) for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True @@ -239,7 +243,7 @@ def prepare_responsefile(self): nodeflag=False existing_crs_nodes=self.ocommon.get_existing_clu_nodes(True) for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True @@ -253,36 +257,51 @@ def prepare_responsefile(self): version=oraversion.split(".",1)[0].strip() if int(version) < 23: - rspdata=''' - oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{3} - oracle.install.option=CRS_ADDNODE - ORACLE_BASE={0} - INVENTORY_LOCATION={1} - oracle.install.asm.OSDBA=asmdba - oracle.install.asm.OSOPER=asmoper - oracle.install.asm.OSASM=asmadmin - oracle.install.crs.config.clusterNodes={2} - oracle.install.crs.rootconfig.configMethod=ROOT - oracle.install.asm.configureAFD=false - oracle.install.crs.rootconfig.executeRootScript=false - oracle.install.crs.configureRHPS=false - '''.format(obase,invloc,clunodes,oraversion,"false") -# fdata="\n".join([s for s in rspdata.split("\n") if s]) - else: - rspdata=''' - oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{3} - oracle.install.option=CRS_ADDNODE - ORACLE_BASE={0} - INVENTORY_LOCATION={1} - OSDBA=asmdba - OSOPER=asmoper - OSASM=asmadmin - clusterNodes={2} - configMethod=ROOT - configureAFD=false - executeRootScript=false - '''.format(obase,invloc,clunodes,oraversion,"false") + rspdata = ''' + oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{3} + oracle.install.option=CRS_ADDNODE + ORACLE_BASE={0} + INVENTORY_LOCATION={1} + oracle.install.asm.OSDBA=asmdba + oracle.install.asm.OSOPER=asmoper + oracle.install.asm.OSASM=asmadmin + oracle.install.crs.config.clusterNodes={2} + oracle.install.crs.rootconfig.configMethod=ROOT + oracle.install.asm.configureAFD=false + oracle.install.crs.rootconfig.executeRootScript=false + oracle.install.crs.configureRHPS=false + '''.format(obase, invloc, clunodes, oraversion) + + elif int(version) == 26: + rspdata = ''' + oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{3} + oracle.install.option=CRS_ADDNODE + ORACLE_BASE={0} + INVENTORY_LOCATION={1} + OSDBA=asmdba + OSOPER=asmoper + OSASM=asmadmin + clusterNodes={2} + configMethod=ROOT + executeRootScript=false + '''.format(obase, invloc, clunodes, oraversion) + else: + rspdata = ''' + oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{3} + oracle.install.option=CRS_ADDNODE + ORACLE_BASE={0} + INVENTORY_LOCATION={1} + OSDBA=asmdba + OSOPER=asmoper + OSASM=asmadmin + clusterNodes={2} + configMethod=ROOT + executeRootScript=false + '''.format(obase, invloc, clunodes, oraversion) + major_ver,minor_ver=self.ocommon.get_ora_version() + if int(minor_ver) < 9: + rspdata+="configureAFD=false\n" self.ocommon.write_file(gridrsp,rspdata) if os.path.isfile(gridrsp): return gridrsp @@ -312,3 +331,17 @@ def run_rootsh(self): cmd='''su - {0} -c "ssh {1} sudo {2}/root.sh"'''.format(giuser,node,gihome) output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.check_os_err(output,error,retcode,True) + + def addcdp(self): + """ + add cdp to existing RAC cluster + """ + msg="" + retvalue=self.ocommon.add_cdp() + if not retvalue: + msg="New CDP didnt added to existing RAC cluster" + self.ocommon.log_info_message(msg,self.file_name) + self.ocommon.prog_exit("Error occurred") + else: + msg="New CDP is now added to the RAC cluster" + self.ocommon.log_info_message(msg,self.file_name) diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiprov.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiprov.py index 8f00de04ae..183adb65b8 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiprov.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oragiprov.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################# """ This file contains to the code call different classes objects based on setup type @@ -89,23 +89,38 @@ def setup(self): self.ocommon.log_info_message("Start crs_sw_instal()",self.file_name) self.crs_sw_install() self.ocommon.log_info_message("End crs_sw_instal()",self.file_name) - self.ocommon.log_info_message("Start run_rootsh() and run_orainstsh()",self.file_name) + # run root should run in RAC all setups and CRS non RU Patch situation, else not + # if not ( + # self.ocommon.check_key("APPLY_RU_LOCATION", self.ora_env_dict) + # and self.ocommon.check_key("CRS_GPC", self.ora_env_dict) + # ): + self.ocommon.log_info_message("Start run_rootsh() and run_orainstsh()", self.file_name) self.run_orainstsh() self.run_rootsh() - self.ocommon.log_info_message("End run_rootsh() and run_orainstsh()",self.file_name) + self.ocommon.log_info_message("End run_rootsh() and run_orainstsh()", self.file_name) self.ocommon.log_info_message("Start install_cvuqdisk_on_all_nodes()",self.file_name) self.install_cvuqdisk_on_all_nodes() self.ocommon.log_info_message("Start crs_config_install()",self.file_name) gridrsp=self.crs_config_install() self.ocommon.log_info_message("End crs_config_install()",self.file_name) self.ocommon.log_info_message("Start run_rootsh()",self.file_name) + # if self.ocommon.check_key("APPLY_RU_LOCATION", self.ora_env_dict) and self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + # self.run_orainstsh() self.run_rootsh() self.ocommon.log_info_message("End run_rootsh()",self.file_name) self.ocommon.log_info_message("Start execute_postconfig()",self.file_name) self.run_postroot(gridrsp) self.ocommon.log_info_message("End execute_postconfig()",self.file_name) retcode1=self.ocvu.check_ohasd(None) - retcode3=self.ocvu.check_clu(None,None) + retcode3=1 + if self.ocommon.check_key("CRS_GPC",self.ora_env_dict): + self.ocommon.log_info_message("Start check_clu() CRS_GPC is set. Check if oracle restart crs is configured properly",self.file_name) + retcode3=self.ocvu.check_clu(pubhostname,None,True) + self.ocommon.log_info_message("End check_clu()",self.file_name) + else: + self.ocommon.log_info_message("Start check_clu() Check if crs is configued properly",self.file_name) + retcode3=self.ocvu.check_clu(None,None,None) + self.ocommon.log_info_message("End check_clu()",self.file_name) if retcode1 != 0 and retcode3 != 0: self.ocommon.log_info_message("Cluster state is not healthy. Exiting..",self.file_name) self.ocommon.prog_exit("127") @@ -113,7 +128,7 @@ def setup(self): self.ora_env_dict=self.ocommon.add_key("CLUSTER_SETUP_FLAG","running",self.ora_env_dict) self.ocommon.run_custom_scripts("CUSTOM_GRID_SCRIPT_DIR","CUSTOM_GRID_SCRIPT_FILE",giuser) - + self.backup_oracle_etc_files() ct = datetime.datetime.now() ets = ct.timestamp() totaltime=ets - bts @@ -188,8 +203,8 @@ def crs_sw_install(self): hostname=self.ocommon.get_public_hostname() lang=self.ora_env_dict["LANGUAGE"] if self.ocommon.check_key("LANGUAGE",self.ora_env_dict) else "en" - #copyflag=" -noCopy " copyflag=" -noCopy " + # copyflag="" if not self.ocommon.check_key("COPY_GRID_SOFTWARE",self.ora_env_dict): copyflag=" -noCopy " @@ -201,7 +216,7 @@ def crs_sw_install(self): mythreads=[] #self.mythread.clear() myproc=[] - + self.ocommon.log_info_message("Running CRS Sw install on node " + pub_nodes,self.file_name) for node in pub_nodes.split(" "): #self.crs_sw_install_on_node(giuser,copyflag,crs_nodes,oinv,gihome,gibase,osdba,osoper,osasm,version,node) self.ocommon.log_info_message("Running CRS Sw install on node " + node,self.file_name) @@ -223,6 +238,7 @@ def crs_sw_install(self): thread.join() # waits until the thread has finished work self.ocommon.log_info_message("Joining the threads ",self.file_name) + def crs_config_install(self): """ This function performs the crs software install on all the nodes @@ -233,18 +249,16 @@ def crs_config_install(self): if self.ocommon.check_key("GRID_RESPONSE_FILE",self.ora_env_dict): gridrsp,netmasklist=self.check_responsefile() else: - gridrsp,netmasklist=self.prepare_responsefile() - + gridrsp,netmasklist=self.prepare_responsefile() if self.ocommon.check_key("PERFORM_CVU_CHECKS",self.ora_env_dict): self.ocvu.cluvfy_checkrspfile(gridrsp,self.ora_env_dict["GRID_HOME"],self.ora_env_dict["GRID_USER"]) cmd=self.ocommon.get_sw_cmd("INSTALL",gridrsp,None,netmasklist) passwd=self.ocommon.get_asm_passwd().replace('\n', ' ').replace('\r', '') - self.ocommon.set_mask_str(passwd) + self.ocommon.set_mask_str(passwd) output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.unset_mask_str() self.ocommon.check_os_err(output,error,retcode,None) self.check_crs_config_install(output) - return gridrsp def parse_gridrsp_file(self, filename): """ @@ -346,12 +360,26 @@ def prepare_responsefile(self): version=oraversion.split(".",1)[0].strip() self.ocommon.log_info_message("disk" + version, self.file_name) - if int(version) < 23: - if self.ocommon.check_key("CRS_GPC",self.ora_env_dict): - clsnodes=None - return self.get_responsefile(obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,disksWithFGNames,oraversion,gridrsp,netmasklist,crsconfig) + if int(version) < 23: # 21,19 etc. versions + if self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + clsnodes = None + return self.get_responsefile( + obase, invloc, scanname, scanport, clutype, cluname, clunodes, + nwiface, gimrflag, passwd, dgname, dgred, fgname, asmdisk, + asmstr, disksWithFGNames, oraversion, gridrsp, netmasklist, crsconfig + ) + elif int(version) >= 26: # 26 onwards versions + return self.get_26ai_responsefile( + obase, invloc, scanname, scanport, clutype, cluname, clunodes, + nwiface, gimrflag, passwd, dgname, dgred, fgname, asmdisk, + asmstr, disksWithFGNames, oraversion, gridrsp, netmasklist, clusterusage + ) else: - return self.get_23c_responsefile(obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,disksWithFGNames,oraversion,gridrsp,netmasklist,clusterusage) + return self.get_23c_responsefile( # Exactly for 23ai version + obase, invloc, scanname, scanport, clutype, cluname, clunodes, + nwiface, gimrflag, passwd, dgname, dgred, fgname, asmdisk, + asmstr, disksWithFGNames, oraversion, gridrsp, netmasklist, clusterusage + ) def get_responsefile(self,obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,disksWithFGNames,oraversion,gridrsp,netmasklist,crsconfig): @@ -427,12 +455,53 @@ def get_23c_responsefile(self,obase,invloc,scanname,scanport,clutype,cluname,clu quorumFailureGroupNames= diskString={14} configMethod=ROOT - configureAFD=false executeRootScript=false ignoreDownNodes=false managementOption=NONE '''.format(obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,oraversion,clusterusage,disksWithFGNames) # fdata="\n".join([s for s in rspdata.split("\n") if s]) + major_ver,minor_ver=self.ocommon.get_ora_version() + if int(minor_ver) < 9: + rspdata+="configureAFD=false\n" + self.ocommon.write_file(gridrsp,rspdata) + if os.path.isfile(gridrsp): + return gridrsp,netmasklist + else: + self.ocommon.log_error_message("Grid response file does not exist at its location: " + gridrsp + ".Exiting..",self.file_name) + self.ocommon.prog_exit("127") + + def get_26ai_responsefile(self,obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,disksWithFGNames,oraversion,gridrsp,netmasklist,clusterusage): + """ + This function prepare the response file if no response file passed + """ + self.ocommon.log_info_message("I am in get_26ai_responsefile", self.file_name) + rspdata=''' + oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v{15} + installOption=CRS_CONFIG + ORACLE_BASE={0} + INVENTORY_LOCATION={1} + OSDBA=asmdba + OSOPER=asmoper + OSASM=asmadmin + clusterUsage={16} + scanName={2} + scanPort={3} + clusterName={5} + clusterNodes={6} + networkInterfaceList={7} + storageOption= + diskGroupName={10} + redundancy={11} + auSize=4 + disksWithFailureGroupNames={17} + diskList={13} + quorumFailureGroupNames= + diskString={14} + configMethod=ROOT + executeRootScript=false + ignoreDownNodes=false + managementOption=NONE + '''.format(obase,invloc,scanname,scanport,clutype,cluname,clunodes,nwiface,gimrflag,passwd,dgname,dgred,fgname,asmdisk,asmstr,oraversion,clusterusage,disksWithFGNames) self.ocommon.write_file(gridrsp,rspdata) if os.path.isfile(gridrsp): return gridrsp,netmasklist @@ -477,28 +546,49 @@ def run_orainstsh(self): self.ocommon.check_os_err(output,error,retcode,True) def run_rootsh(self): - """ - This function run the root.sh after grid setup - """ - giuser,gihome,gbase,oinv=self.ocommon.get_gi_params() - pub_nodes,vip_nodes,priv_nodes=self.ocommon.process_cluster_vars("CRS_NODES") - # Clear the dict - self.mythread.clear() - mythreads=[] - for node in pub_nodes.split(" "): - oraversion=self.ocommon.get_rsp_version("INSTALL",None) + """ + This function runs rsync from first node to other nodes + (when APPLY_RU_LOCATION is set and CRS_GPC is not set) + and then executes root.sh after grid setup + """ + giuser, gihome, gbase, oinv = self.ocommon.get_gi_params() + pub_nodes, vip_nodes, priv_nodes = self.ocommon.process_cluster_vars("CRS_NODES") + node_list = pub_nodes.split(" ") + + # # for RAC RU Setup condition check + # if self.ocommon.check_key("APPLY_RU_LOCATION", self.ora_env_dict) and not self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + # source_node = node_list[0] + # target_nodes = node_list[1:] + + # for node in target_nodes: + # rsync_cmd = '''su - {0} -c "rsync -aHAXxv --progress {1}/ {2}:{1}/"'''.format( + # giuser, gihome, node + # ) + # output, error, retcode = self.ocommon.execute_cmd(rsync_cmd, None, None) + # self.ocommon.check_os_err(output, error, retcode, True) + + # Clear thread tracking + self.mythread.clear() + mythreads = [] + + # Run root.sh on each node + for node in node_list: + oraversion = self.ocommon.get_rsp_version("INSTALL", None) version = oraversion.split(".", 1)[0].strip() - self.ocommon.log_info_message("oraversion" + version, self.file_name) + self.ocommon.log_info_message("oraversion " + version, self.file_name) + if int(version) == 19 or int(version) == 21: - self.run_rootsh_on_node(node,giuser,gihome) + self.run_rootsh_on_node(node, giuser, gihome) else: - self.ocommon.log_info_message("Running root.sh on node " + node,self.file_name) - thread=Process(target=self.run_rootsh_on_node,args=(node,giuser,gihome)) - mythreads.append(thread) - thread.start() - for thread in mythreads: # iterates over the threads - thread.join() # waits until the thread has finished wor - self.ocommon.log_info_message("Joining the root.sh thread ",self.file_name) + self.ocommon.log_info_message("Running root.sh on node " + node, self.file_name) + thread = Process(target=self.run_rootsh_on_node, args=(node, giuser, gihome)) + mythreads.append(thread) + thread.start() + + for thread in mythreads: + thread.join() + self.ocommon.log_info_message("Joining the root.sh thread ", self.file_name) + def run_rootsh_on_node(self,node,giuser,gihome): """ @@ -608,3 +698,31 @@ def install_cvuqdisk(self,node): except subprocess.CalledProcessError as e: self.ocommon.log_error_message("Error installing cvuqdisk. Exiting..." + e,self.file_name) + + + def backup_oracle_etc_files(self): + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + self.ocommon.log_info_message("oraversion: " + str(oraversion), self.file_name) + gridrsp = "/tmp/grid.rsp" + version = oraversion.split(".", 1)[0].strip() + self.ocommon.log_info_message("disk version: " + version, self.file_name) + + if int(version) == 19: + self.ocommon.log_info_message("running backup_oracle_etc_files()", self.file_name) + giuser, gihome, gibase, oinv = self.ocommon.get_gi_params() + node = self.ocommon.get_public_hostname() + targetdir=gibase+"/.etcoraclebackup" + try: + if self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + backup_dir="/etc/oracle" + cmd = '''su - {0} -c "ssh {1} sudo mkdir -p {2}/"'''.format(giuser, node, targetdir) + output, error, retcode = self.ocommon.execute_cmd(cmd, None, None) + self.ocommon.check_os_err(output, error, retcode, None) + cmd = '''su - {0} -c "ssh {1} sudo cp -rp {3} {2}/"'''.format(giuser, node, targetdir, backup_dir) + output, error, retcode = self.ocommon.execute_cmd(cmd, None, None) + self.ocommon.check_os_err(output, error, retcode, None) + self.ocommon.log_info_message( + "Successfully backed up /etc/oracle files on node {0}.".format(node), self.file_name) + except subprocess.CalledProcessError as e: + self.ocommon.log_error_message( + "Error backing up /etc/oracle on node {0}. Exiting... {1}".format(node, str(e)), self.file_name) diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramachine.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramachine.py index 98db72c775..b4753c652b 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramachine.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramachine.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################# from oralogger import * from oraenv import * diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramiscops.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramiscops.py index 0d903f47dd..6f090df702 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramiscops.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oramiscops.py @@ -203,7 +203,10 @@ def setup(self): self.run_datapatch() else: pass - + if self.ocommon.check_key("ONS",self.ora_env_dict): + self.update_ons() + else: + pass ct = datetime.datetime.now() ets = ct.timestamp() @@ -345,7 +348,7 @@ def checkdbrole(self): if (mode == "OPEN") or ( mode == "MOUNT"): osuser,dbhome,dbbase,oinv=self.ocommon.get_db_params() osid=self.ora_env_dict["DB_NAME"] if self.ocommon.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" - scanname=self.ora_env_dict["SCAN_NAME"] + scanname = self.get_scan_name() scanport=self.ora_env_dict["SCAN_PORT"] if self.ocommon.check_key("SCAN_PORT",self.ora_env_dict) else "1521" connect_str=self.ocommon.get_sqlplus_str(dbhome,osid,osuser,"sys",'HIDDEN_STRING',scanname,scanport,osid,None,None,None) status=self.ocommon.get_db_role(osuser,dbhome,osid,connect_str) @@ -362,7 +365,7 @@ def getconnectstr(self): """ osuser,dbhome,dbbase,oinv=self.ocommon.get_db_params() osid=self.ora_env_dict["DB_NAME"] if self.ocommon.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" - scanname=self.ora_env_dict["SCAN_NAME"] + scanname = self.get_scan_name() scanport=self.ora_env_dict["SCAN_PORT"] if self.ocommon.check_key("SCAN_PORT",self.ora_env_dict) else "1521" ##connect_str=self.ocommon.get_sqlplus_str(dbhome,osid,osuser,"sys",'HIDDEN_STRING',scanname,scanport,osid,None,None,None) connect_str='''{0}:{1}/{2}'''.format(scanname,scanport,osid) @@ -377,7 +380,7 @@ def getpdbconnectstr(self): osuser,dbhome,dbbase,oinv=self.ocommon.get_db_params() pdb=self.ora_env_dict["PDB_NAME"] if self.ocommon.check_key("PDB_NAME",self.ora_env_dict) else "ORCLPDB" osid=self.ora_env_dict["DB_NAME"] if self.ocommon.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" - scanname=self.ora_env_dict["SCAN_NAME"] + scanname = self.get_scan_name() scanport=self.ora_env_dict["SCAN_PORT"] if self.ocommon.check_key("SCAN_PORT",self.ora_env_dict) else "1521" sname,osid,opdb,sparams=self.ocommon.get_service_name() status,msg=self.ocommon.check_db_service_status(sname,osid) @@ -398,7 +401,7 @@ def checkracsvc(self): mode="" osuser,dbhome,dbbase,oinv=self.ocommon.get_db_params() osid=self.ora_env_dict["DB_NAME"] if self.ocommon.check_key("DB_NAME",self.ora_env_dict) else "ORCLCDB" - scanname=self.ora_env_dict["SCAN_NAME"] + scanname = self.get_scan_name() scanport=self.ora_env_dict["SCAN_PORT"] if self.ocommon.check_key("SCAN_PORT",self.ora_env_dict) else "1521" connect_str=self.ocommon.get_sqlplus_str(dbhome,osid,osuser,"sys",'HIDDEN_STRING',scanname,scanport,osid,None,None,None) status=self.ocommon.get_dbinst_status(osuser,dbhome,osid,connect_str) @@ -475,7 +478,11 @@ def checkclulocal(self,node): """ This function check the cluster health """ - retcode=self.ocvu.check_clu(node,None) + retcode=1 + if self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + retcode=self.ocvu.check_clu(node,None,True) + else: + retcode=self.ocvu.check_clu(node,None,None) return retcode def checkgihome(self): @@ -493,7 +500,7 @@ def setupdblsnr(self): """ value=self.ora_env_dict["NEW_DB_LSNR_ENDPOINTS"] self.ocommon.log_info_message("lsnr new end Points are set to :" + value,self.file_name ) - if self.check_key("DB_LISTENER_ENDPOINTS",self.ora_env_dict): + if self.ocommon.check_key("DB_LISTENER_ENDPOINTS",self.ora_env_dict): self.ocommon.log_info_message("lsnr old end points were set to :" + self.ora_env_dict["DB_LISTENER_ENDPOINTS"],self.file_name ) self.ora_env_dict=self.update_key("DB_LISTENER_ENDPOINTS",value,self.ora_env_dict) else: @@ -506,7 +513,7 @@ def setuplocallsnr(self): """ value=self.ora_env_dict["NEW_LOCAL_LISTENER"] self.ocommon.log_info_message("local lsnr new end Points are set to :" + value,self.file_name ) - if self.check_key("LOCAL_LISTENER",self.ora_env_dict): + if self.ocommon.check_key("LOCAL_LISTENER",self.ora_env_dict): self.ocommon.log_info_message("lsnr old end points were set to :" + self.ora_env_dict["LOCAL_LISTENER"],self.file_name ) self.ora_env_dict=self.update_key("LOCAL_LISTENER",value,self.ora_env_dict) else: @@ -898,4 +905,37 @@ def run_datapatch(self): if extra_patches: self.ocommon.log_info_message("These patches appear in DBA_REGISTRY_SQLPATCH but not in OPatch: " + str(extra_patches), self.file_name) - self.ocommon.log_info_message("End run_datapatch()", self.file_name) \ No newline at end of file + self.ocommon.log_info_message("End run_datapatch()", self.file_name) + + def get_scan_name(self): + """ + Determine the correct SCAN name based on the environment. + """ + scan_name="" + if self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + return self.ocommon.get_public_hostname() + else: + scanname=self.ora_env_dict["SCAN_NAME"] + return scan_name + + def update_ons(self): + """ + update ons details + """ + status="" + msg="" + giuser,gihome,obase,invloc=self.ocommon.get_gi_params() + self.ocommon.log_info_message("updating ons details params",self.file_name) + onsstate=self.ora_env_dict["ONS"] + retvalue=self.ocommon.update_ons(giuser,gihome,onsstate) + if not retvalue: + status="ONS_NOT_UPDATED" + msg='''ONS Details is not updated to {0}'''.format(onsstate) + self.ocommon.log_info_message(msg,self.file_name) + print(status) + self.ocommon.prog_exit("Error occurred") + else: + msg='''ONS Details is now updated to {0}'''.format(onsstate) + status="ONS_UPDATED_SUCCESSFULLY" + self.ocommon.log_info_message(msg,self.file_name) + print(status) \ No newline at end of file diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracadd.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracadd.py index 6d6c810d70..e4bbb3f256 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracadd.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracadd.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################# """ This file contains to the code call different classes objects based on setup type @@ -115,7 +115,7 @@ def clu_checks(self): hostname=self.ocommon.get_public_hostname() retcode1=self.ocvu.check_ohasd(hostname) retcode2=self.ocvu.check_asm(hostname) - retcode3=self.ocvu.check_clu(hostname,None) + retcode3=self.ocvu.check_clu(hostname,None,None) if retcode1 == 0: msg="Cluvfy ohasd check passed!" self.ocommon.log_info_message(msg,self.file_name) @@ -167,7 +167,7 @@ def db_sw_install(self): nodeflag=False cmd=None for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True @@ -211,7 +211,7 @@ def add_dbinst(self): node="" nodeflag=False for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracdel.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracdel.py index 4eab77a816..80ae203039 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracdel.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracdel.py @@ -56,18 +56,23 @@ def setup(self): if self.ocommon.check_key("EXISTING_CLS_NODE",self.ora_env_dict): if len(self.ora_env_dict["EXISTING_CLS_NODE"].split(",")) == 0: self.ora_env_dict=self.add_key("LAST_CRS_NODE","true",self.ora_env_dict) - + if self.ocommon.detect_k8s_env(): + if self.ocommon.check_key("EXISTING_CLS_NODE", self.ora_env_dict): + node = self.ora_env_dict["EXISTING_CLS_NODE"].split(",")[0] + self.ocommon.stop_scan_lsnr(giuser, gihome, hostname) + self.ocommon.stop_scan(giuser, gihome, hostname) + + # Remove Oracle stack from node to be deleted self.del_dbinst_main(hostname) self.del_dbhome_main(hostname) self.del_gihome_main(hostname) self.del_ginode(hostname) + if self.ocommon.detect_k8s_env(): - if self.ocommon.check_key("EXISTING_CLS_NODE",self.ora_env_dict): - node=self.ora_env_dict["EXISTING_CLS_NODE"].split(",")[0] - self.ocommon.update_scan(giuser,gihome,None,node) - self.ocommon.start_scan(giuser,gihome,node) - self.ocommon.update_scan_lsnr(giuser,gihome,node) - + if self.ocommon.check_key("EXISTING_CLS_NODE", self.ora_env_dict): + node = self.ora_env_dict["EXISTING_CLS_NODE"].split(",")[0] + self.ocommon.update_scan(giuser, gihome, None, node) + self.ocommon.update_scan_lsnr(giuser, gihome, node) ct = datetime.datetime.now() ets = ct.timestamp() totaltime=ets - bts @@ -91,7 +96,7 @@ def clu_checks(self): hostname=self.ocommon.get_public_hostname() retcode1=self.ocvu.check_ohasd(hostname) retcode2=self.ocvu.check_asm(hostname) - retcode3=self.ocvu.check_clu(hostname,None) + retcode3=self.ocvu.check_clu(hostname,None,None) if retcode1 == 0: msg="Cluvfy ohasd check passed!" @@ -152,7 +157,7 @@ def del_dbinst(self): node="" nodeflag=False for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True @@ -258,7 +263,7 @@ def del_ginode(self,hostname): node="" nodeflag=False for cnode in existing_crs_nodes.split(","): - retcode3=self.ocvu.check_clu(cnode,True) + retcode3=self.ocvu.check_clu(cnode,True,None) if retcode3 == 0: node=cnode nodeflag=True diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracprov.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracprov.py index 75d7eb4d67..ff6e8c6002 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracprov.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracprov.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################## """ This file contains to the code call different classes objects based on setup type @@ -66,7 +66,12 @@ def setup(self): for node in crs_nodes.split(","): self.clu_checks(node) dbuser,dbhome,dbase,oinv=self.ocommon.get_db_params() - retcode1=self.ocvu.check_home(None,dbhome,dbuser) + # retcode1=self.ocvu.check_home(None,dbhome,dbuser) + retcode=1 + if self.ocommon.check_key("CRS_GPC",self.ora_env_dict): + retcode1=self.ocvu.check_db_home_has(None,dbhome,dbuser) + else: + retcode1=self.ocvu.check_db_home(None,dbhome,dbuser) status=self.ocommon.check_rac_installed(retcode1) self.ocommon.reset_os_password(dbuser) if not status: @@ -132,7 +137,15 @@ def clu_checks(self,hostname): # hostname=self.ocommon.get_public_hostname() retcode1=self.ocvu.check_ohasd(hostname) retcode2=self.ocvu.check_asm(hostname) - retcode3=self.ocvu.check_clu(hostname,None) + retcode3=1 + if self.ocommon.check_key("CRS_GPC",self.ora_env_dict): + self.ocommon.log_info_message("Start check_clu() CRS_GPC is set. Check if oracle restart crs is configured properly",self.file_name) + retcode3=self.ocvu.check_clu(hostname,None,True) + self.ocommon.log_info_message("End check_clu()",self.file_name) + else: + self.ocommon.log_info_message("Start check_clu() Check if crs is configued properly",self.file_name) + retcode3=self.ocvu.check_clu(hostname,None,None) + self.ocommon.log_info_message("End check_clu()",self.file_name) if retcode1 == 0: msg="Cluvfy ohasd check passed!" @@ -200,6 +213,7 @@ def db_sw_install(self): lang=self.ora_env_dict["LANGUAGE"] if self.ocommon.check_key("LANGUAGE",self.ora_env_dict) else "en" edition= self.ora_env_dict["DB_EDITION"] if self.ocommon.check_key("DB_EDITION",self.ora_env_dict) else "EE" ignoreflag= " -ignorePrereq " if self.ocommon.check_key("IGNORE_DB_PREREQS",self.ora_env_dict) else " " + prereqfailure = " -ignorePrereqFailure " if self.ocommon.check_key("IGNORE_DB_PREREQS", self.ora_env_dict) else " " copyflag=" -noCopy " if not self.ocommon.check_key("COPY_DB_SOFTWARE",self.ora_env_dict): @@ -214,7 +228,7 @@ def db_sw_install(self): mythreads=[] for node in pub_nodes.split(" "): self.ocommon.log_info_message("Running DB Sw install on node " + node,self.file_name) - thread=Process(target=self.db_sw_install_on_node,args=(dbuser,hostname,unixgrp,crs_nodes,oinv,lang,dbhome,dbase,edition,osdba,osbkp,osdgdba,oskmdba,osracdba,copyflag,node,ignoreflag)) + thread=Process(target=self.db_sw_install_on_node,args=(dbuser,hostname,unixgrp,crs_nodes,oinv,lang,dbhome,dbase,edition,osdba,osbkp,osdgdba,oskmdba,osracdba,copyflag,node,ignoreflag,prereqfailure)) #thread.setDaemon(True) mythreads.append(thread) thread.start() @@ -228,14 +242,21 @@ def db_sw_install(self): #self.manage_thread() - def db_sw_install_on_node(self,dbuser,hostname,unixgrp,crs_nodes,oinv,lang,dbhome,dbase,edition,osdba,osbkp,osdgdba,oskmdba,osracdba,copyflag,node,ignoreflag): + def db_sw_install_on_node(self,dbuser,hostname,unixgrp,crs_nodes,oinv,lang,dbhome,dbase,edition,osdba,osbkp,osdgdba,oskmdba,osracdba,copyflag,node,ignoreflag,prereqfailure): """ Perform the db_install """ runCmd="" + export_line="" if self.ocommon.check_key("APPLY_RU_LOCATION",self.ora_env_dict): ruLoc=self.ora_env_dict["APPLY_RU_LOCATION"] + # runCmd='''runInstaller -applyRU "{0}/37960098" -applyOneOffs "{0}/37962946"'''.format(self.ora_env_dict["APPLY_RU_LOCATION"]) runCmd='''runInstaller -applyRU "{0}"'''.format(self.ora_env_dict["APPLY_RU_LOCATION"]) + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() + self.ocommon.log_info_message("disk" + version, self.file_name) + # Add CV_ASSUME_DISTID only if Oracle version is 19 + export_line = "export CV_ASSUME_DISTID=OL8; " if int(version) == 19 else "" else: runCmd='''runInstaller ''' @@ -243,25 +264,53 @@ def db_sw_install_on_node(self,dbuser,hostname,unixgrp,crs_nodes,oinv,lang,dbhom if self.ocommon.check_key("DEBUG_MODE",self.ora_env_dict): dbgCmd='''{0} -debug '''.format(runCmd) runCmd=dbgCmd - - rspdata='''su - {0} -c "ssh {17} {1}/{16} {18} -waitforcompletion {15} -silent - oracle.install.option=INSTALL_DB_SWONLY - ORACLE_HOSTNAME={2} - UNIX_GROUP_NAME={3} - oracle.install.db.CLUSTER_NODES={4} - INVENTORY_LOCATION={5} - SELECTED_LANGUAGES={6} - ORACLE_HOME={7} - ORACLE_BASE={8} - oracle.install.db.InstallEdition={9} - oracle.install.db.OSDBA_GROUP={10} - oracle.install.db.OSBACKUPDBA_GROUP={11} - oracle.install.db.OSDGDBA_GROUP={12} - oracle.install.db.OSKMDBA_GROUP={13} - oracle.install.db.OSRACDBA_GROUP={14} - SECURITY_UPDATES_VIA_MYORACLESUPPORT=false - DECLINE_SECURITY_UPDATES=true"'''.format(dbuser,dbhome,hostname,unixgrp,crs_nodes,oinv,lang,dbhome,dbase,edition,osdba,osbkp,osdgdba,oskmdba,osracdba,copyflag,runCmd,node,ignoreflag) - cmd=rspdata.replace('\n'," ") + rspdata="" + + if self.ocommon.check_key("CRS_GPC", self.ora_env_dict): + rspdata = '''su - {0} -c "ssh {17} '{18}{1}/{16} {19} -waitforcompletion {15} -silent + oracle.install.option=INSTALL_DB_SWONLY + ORACLE_HOSTNAME={2} + UNIX_GROUP_NAME={3} + INVENTORY_LOCATION={5} + SELECTED_LANGUAGES={6} + ORACLE_HOME={7} + ORACLE_BASE={8} + oracle.install.db.InstallEdition={9} + oracle.install.db.OSDBA_GROUP={10} + oracle.install.db.OSBACKUPDBA_GROUP={11} + oracle.install.db.OSDGDBA_GROUP={12} + oracle.install.db.OSKMDBA_GROUP={13} + oracle.install.db.OSRACDBA_GROUP={14} + SECURITY_UPDATES_VIA_MYORACLESUPPORT=false + DECLINE_SECURITY_UPDATES=true'"'''.format( + dbuser, dbhome, hostname, unixgrp, crs_nodes, oinv, lang, dbhome, dbase, + edition, osdba, osbkp, osdgdba, oskmdba, osracdba, copyflag, runCmd, node, export_line, ignoreflag, prereqfailure + ) + + else: + rspdata = '''su - {0} -c "ssh {17} '{18}{1}/{16} {19} -waitforcompletion {15} -silent + oracle.install.option=INSTALL_DB_SWONLY + ORACLE_HOSTNAME={2} + UNIX_GROUP_NAME={3} + oracle.install.db.CLUSTER_NODES={4} + INVENTORY_LOCATION={5} + SELECTED_LANGUAGES={6} + ORACLE_HOME={7} + ORACLE_BASE={8} + oracle.install.db.InstallEdition={9} + oracle.install.db.OSDBA_GROUP={10} + oracle.install.db.OSBACKUPDBA_GROUP={11} + oracle.install.db.OSDGDBA_GROUP={12} + oracle.install.db.OSKMDBA_GROUP={13} + oracle.install.db.OSRACDBA_GROUP={14} + SECURITY_UPDATES_VIA_MYORACLESUPPORT=false + DECLINE_SECURITY_UPDATES=true'"'''.format( + dbuser, dbhome, hostname, unixgrp, crs_nodes, oinv, lang, dbhome, dbase, + edition, osdba, osbkp, osdgdba, oskmdba, osracdba, copyflag, runCmd, node, export_line, ignoreflag, prereqfailure + ) + + cmd = rspdata.replace('\n', ' ') + #dbswrsp="/tmp/dbswrsp.rsp" #self.ocommon.write_file(dbswrsp,rspdata) #if os.path.isfile(dbswrsp): @@ -418,9 +467,14 @@ def create_db(self): if self.ocommon.check_key("IGNORE_DB_PREREQS",self.ora_env_dict): prereq=" -ignorePreReqs " dbuser,dbhome,dbase,oinv=self.ocommon.get_db_params() + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() + self.ocommon.log_info_message("disk" + version, self.file_name) + export_line = "export CV_ASSUME_DISTID=OL8;" if int(version) == 19 else "" + dbca_validate_option = "-J-Doracle.assistants.dbca.validate.ConfigurationParams=false" if int(version) == 19 else "" if self.ocommon.check_key("DBCA_RESPONSE_FILE",self.ora_env_dict): dbrsp=self.check_responsefile() - cmd='''su - {0} -c "{1}/bin/dbca -silent {3} -createDatabase -responseFile {2}"'''.format(dbuser,dbhome,dbrsp,prereq) + cmd = '''su - {0} -c "{1}{2}/bin/dbca -silent {3} {4} -createDatabase -responseFile {5}"'''.format(dbuser, export_line, dbhome, prereq, dbca_validate_option, dbrsp) else: cmd=self.prepare_db_cmd() @@ -458,30 +512,56 @@ def prepare_db_cmd(self): arcmode=self.ora_env_dict["ENABLE_ARCHIVELOG"] if self.ocommon.check_key("ENABLE_ARCHIVELOG",self.ora_env_dict) else "true" pdbsettings=self.get_pdb_params() initparams=self.get_init_params() - if self.ocommon.check_key("SETUP_TDE_WALLET",self.ora_env_dict): - tdewallet='''-configureTDE true -tdeWalletPassword HIDDEN_STRING -tdeWalletRoot {0} -tdeWalletLoginType AUTO_LOGIN -encryptTablespaces all'''.format(dbfiledest) + # if self.ocommon.check_key("SETUP_TDE_WALLET",self.ora_env_dict): + # tdewallet='''-configureTDE true -tdeWalletPassword HIDDEN_STRING -tdeWalletRoot {0} -tdeWalletLoginType AUTO_LOGIN -encryptTablespaces all'''.format(dbfiledest) #memorypct=self.get_memorypct() - - rspdata='''su - {0} -c "{1}/bin/dbca -silent {15} -createDatabase \ - -templateName General_Purpose.dbc \ - -gdbname {2} \ - -createAsContainerDatabase {3} \ - -sysPassword HIDDEN_STRING \ - -systemPassword HIDDEN_STRING \ - -datafileDestination {4} \ - -storageType {5} \ - -characterSet {6} \ - -redoLogFileSize {7} \ - -databaseType {8} \ - -databaseConfigType {9} \ - -nodelist {10} \ - -useOMF true \ - {12} \ - {13} \ - {16} \ - -enableArchive {14}"'''.format(dbuser,dbhome,dbname,cdbflag,dbfiledest,stype,charset,redosize,dbtype,dbctype,crs_nodes,dbname,pdbsettings,initparams,arcmode,prereq,tdewallet) - cmd='\n'.join(line.lstrip() for line in rspdata.splitlines()) - + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + self.ocommon.log_info_message("oraversion: " + oraversion, self.file_name) + + version = oraversion.split(".", 1)[0].strip() + self.ocommon.log_info_message("parsed version: " + version, self.file_name) + + tdewallet = "" # default to empty + + if self.ocommon.check_key("SETUP_TDE_WALLET", self.ora_env_dict): + if int(version) < 21: + tdewallet = "" + else: + tdewallet = '''-configureTDE true -tdeWalletPassword HIDDEN_STRING -tdeWalletRoot {0} -tdeWalletLoginType AUTO_LOGIN -encryptTablespaces all'''.format(dbfiledest) + + + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() + self.ocommon.log_info_message("disk" + version, self.file_name) + + # Conditionally set the export and additional dbca options if version is 19 + export_line = "export CV_ASSUME_DISTID=OL8;" if int(version) == 19 else "" + dbca_validate_option = "-J-Doracle.assistants.dbca.validate.ConfigurationParams=false" if int(version) == 19 else "" + + rspdata = '''su - {0} -c "{17}{1}/bin/dbca -silent {15} -createDatabase \ + -templateName General_Purpose.dbc \ + -gdbname {2} \ + -createAsContainerDatabase {3} \ + -sysPassword HIDDEN_STRING \ + -systemPassword HIDDEN_STRING \ + -datafileDestination {4} \ + -storageType {5} \ + -characterSet {6} \ + -redoLogFileSize {7} \ + -databaseType {8} \ + -databaseConfigType {9} \ + -nodelist {10} \ + -useOMF true \ + {12} \ + {13} \ + {18} \ + {16} \ + -enableArchive {14}"'''.format( + dbuser, dbhome, dbname, cdbflag, dbfiledest, stype, charset, redosize, + dbtype, dbctype, crs_nodes, dbname, pdbsettings, initparams, arcmode, + prereq, tdewallet, export_line, dbca_validate_option) + + cmd = '\n'.join(line.lstrip() for line in rspdata.splitlines()) return cmd def get_pdb_params(self): @@ -539,4 +619,4 @@ def get_init_params(self): initparams=""" -initparams '{0}'""".format(initprm) - return initparams + return initparams \ No newline at end of file diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracstdby.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracstdby.py index ad91f25d3b..af24e021f5 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracstdby.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/oraracstdby.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################# """ This file contains to the code call different classes objects based on setup type diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasetupenv.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasetupenv.py index cdf3c2a407..e069857b7e 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasetupenv.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasetupenv.py @@ -4,7 +4,7 @@ # Copyright 2020-2025, Oracle Corporation and/or affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl # Author: paramdeep.saini@oracle.com -############################ +############################# """ This file contains to the code call different classes objects based on setup type @@ -97,6 +97,9 @@ def setup(self): # self.ocommon.log_info_message("Start crs_sw_install()",self.file_name) # self.crs_sw_install() # self.ocommon.log_info_message("End crs_sw_install()",self.file_name) + self.ocommon.log_info_message("Running comment_out_swap_space()",self.file_name) + self.comment_out_swap_space() + self.ocommon.log_info_message("Ended comment_out_swap_space()",self.file_name) self.setup_ssh_for_k8s() self.set_banner() @@ -792,3 +795,62 @@ def set_banner(self): else: msg="Grid is not installed on this machine" self.ocommon.log_info_message(self.ocommon.print_banner(msg),self.file_name) + + def comment_out_swap_space(self): + """ + This function comments out the SWAP_SPACE=500 parameter in oraparam.ini + file for Oracle version 19 in both GRID_HOME and DB_HOME. + """ + oraversion = self.ocommon.get_rsp_version("INSTALL", None) + version = oraversion.split(".", 1)[0].strip() + + # Get DB and GI homes + dbuser, dbhome, dbase, oinv = self.ocommon.get_db_params() + giuser, gihome, gibase, oinv = self.ocommon.get_gi_params() + + if int(version) != 19: + self.ocommon.log_info_message( + "Skipping commenting out SWAP_SPACE as Oracle version is {}".format(version), + self.file_name + ) + return + + homes_to_check = [gihome, dbhome] + section_name = "[Generic Prereqs]" + param_name = "SWAP_SPACE=500" + + for home in homes_to_check: + file_path = "{}/oui/oraparam.ini".format(home) + + try: + with open(file_path, 'r') as file: + lines = file.readlines() + + in_section = False + modified_lines = [] + + for line in lines: + if line.strip() == section_name: + in_section = True + elif line.startswith('[') and in_section: + in_section = False + + if in_section and line.strip() == param_name: + modified_lines.append("#{}".format(line)) + else: + modified_lines.append(line) + + with open(file_path, 'w') as file: + file.writelines(modified_lines) + + self.ocommon.log_info_message( + "Successfully commented out {} in {}".format(param_name, file_path), + self.file_name + ) + + except Exception as e: + self.ocommon.log_error_message( + "Failed to comment out {} in {}: {}".format(param_name, file_path, str(e)), + self.file_name + ) + diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasshsetup.py b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasshsetup.py index e451730d42..cab2e7897b 100755 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasshsetup.py +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/scripts/orasshsetup.py @@ -179,7 +179,7 @@ def performsshsetup(self,user,gihome,sshscr,cls_nodes,version,password,counter,e sshcmd_output, sshcmd_error, sshcmd_retcode = self.ocommon.execute_cmd(sshcmd, None, None) self.ocommon.check_os_err(sshcmd_output, sshcmd_error, sshcmd_retcode, False) else: - cmd='''su - {0} -c "echo \"{4}\" | {1}/{2} comp admprv -n {3} -o user_equiv -fixup"'''.format(user,gihome,sshscr,new_nodes,'HIDDEN_STRING') + cmd='''su - {0} -c "echo \"{4}\" | {1}/{2} comp admprv -n {3} -o user_equiv -fixup"'''.format(user,gihome,sshscr,cls_nodes,'HIDDEN_STRING') output,error,retcode=self.ocommon.execute_cmd(cmd,None,None) self.ocommon.check_os_err(output,error,retcode,None) From a7ebc3a181dabd8d07376b607c052ceff6720830 Mon Sep 17 00:00:00 2001 From: Saurabh Ahuja Date: Mon, 1 Sep 2025 06:51:01 +0000 Subject: [PATCH 2/2] checksum --- .../containerfiles/19.3.0/Checksum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum index cb4a9752e5..50e21b2552 100644 --- a/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum +++ b/OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Checksum @@ -1,2 +1,2 @@ -b7c4c66f801f92d14faa0d791ccda721 19.3.0/LINUX.X64_193000_db_home.zip -1858bd0d281c60f4ddabd87b1c214a4f 19.3.0/LINUX.X64_193000_grid_home.zip +1858bd0d281c60f4ddabd87b1c214a4f 19.3.0/LINUX.X64_193000_db_home.zip +b7c4c66f801f92d14faa0d791ccda721 19.3.0/LINUX.X64_193000_grid_home.zip