Posts

Showing posts from September, 2024

Decommission v3

 #!/bin/bash # Check if ORACLE_SID is provided if [ -z "$1" ]; then     echo "Error: ORACLE_SID not provided."     echo "Usage: $0 <ORACLE_SID> <second_node_instance>"     exit 1 fi # Set environment variables export ORACLE_SID=$1 export ORAENV_ASK=NO . oraenv second_node_instance="$2" LOG_FILE="decommission_$ORACLE_SID.log" ORACLE_HOME="<oracle_home>" # Function to log messages log() {     echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | tee -a $LOG_FILE } # Function to execute SQL commands run_sql() {     echo "$1" | $ORACLE_HOME/bin/sqlplus -S "/ as sysdba" } # Function to execute DGMGRL commands run_dgmgrl() {     dgmgrl -silent <<EOF connect / $1 exit; EOF } # Start decommissioning process log "Decommissioning process started for ORACLE_SID: $ORACLE_SID" # Retrieve the database unique name dynamically db_unique_name=$(sqlplus -s / as sysdba <<EOF set ...