Posts

Patching readiness

 #!/bin/bash # Function to check GoldenGate status check_goldengate() {     if agctl status goldengate | grep -q "is running"; then         echo "GoldenGate is running."     else         echo "GoldenGate is not running."     fi } # Function to check ACFS status check_acfs() {     if acfsutil info > /dev/null 2>&1; then         echo "ACFS is up."     else         echo "ACFS is down."     fi } # Function to check EMCTL status check_emctl() {     if emctl status > /dev/null 2>&1; then         echo "EMCTL is running."     else         echo "EMCTL is not running."     fi } # Function to check if create_rp.ksh exists check_create_rp() {     if [ -f create_rp.ksh ]; then         echo "create_rp.ksh exists."     else         echo "create_rp.ksh does not exist."     fi } # Main function main() {     echo "Patching readiness check starting..."     # Task 1: Verify GoldenGate  

Header

CONFIG_FILE=$1 PATCH_LOG=$(grep PATCH_LOG "$CONFIG_FILE" | awk -F ':' '{ print $2}') CHANGE_NUMBER=$(grep CHANGE "$CONFIG_FILE" | awk -F ':' '{ print $2}') SCRIPT_BASE=$(grep SCRIPT_BASE "$CONFIG_FILE" | awk -F ':' '{ print $2}') DBHOME_NUM_19C=$(grep 19C_NEW "$CONFIG_FILE" | awk -F ':' '{ print $2}') DBHOME_NUM_12C=$(grep 12C_NEW "$CONFIG_FILE" | awk -F ':' '{ print $2}') DBHOME_NUM_11G=$(grep 11G_NEW "$CONFIG_FILE" | awk -F ':' '{ print $2}')

Create pfile v2

 #!/bin/bash OUTPUT_DIRECTORY="$1" # Get the current timestamp CURRENT_TIMESTAMP=$(date +"%Y%m%d_%H%M%S") # Define the path for the new folder NEW_FOLDER="$OUTPUT_DIRECTORY/$CURRENT_TIMESTAMP" # Create the new folder mkdir -p "$NEW_FOLDER" # Function to create pfile create_pfile() {     local output_directory="$1"     local oracle_sid="$2"          source oraenv <<< "$oracle_sid" > /dev/null     result=$(sqlplus -S / as sysdba <<EOF create pfile='$output_directory/init_$oracle_sid.ora' from spfile; exit; EOF ) } # Loop through Oracle SIDs and create pfiles in the new folder for SID in $(ps -ef | grep '[o]ra_smon' | awk '{print $NF}' | cut -d '_' -f3); do     create_pfile "$NEW_FOLDER" "$SID" done echo "Pfiles created successfully in $NEW_FOLDER."

Create pfile v1

 #!/bin/bash OUTPUT_DIRECTORY="$1" CURRENT_TIMESTAMP=$(date +"%Y%m%d_%H%M%S") NEW_FOLDER="$OUTPUT_DIRECTORY/$CURRENT_TIMESTAMP" BACKUP_FOLDER="$OUTPUT_DIRECTORY/backup_$CURRENT_TIMESTAMP" mkdir -p "$NEW_FOLDER" create_pfile() {     local output_directory="$1"     local oracle_sid="$2"          source oraenv <<< "$oracle_sid" > /dev/null     result=$(sqlplus -S / as sysdba <<EOF create pfile='$output_directory/init_$oracle_sid.ora' from spfile; exit; EOF ) } # Loop through Oracle SIDs and create pfiles for SID in $(ps -ef | grep '[o]ra_smon' | awk '{print $NF}' | cut -d '_' -f3); do     create_pfile "$NEW_FOLDER" "$SID" done # If backup folder exists, rename it with timestamp if [ -d "$OUTPUT_DIRECTORY/backup" ]; then     mv "$OUTPUT_DIRECTORY/backup" "$BACKUP_FOLDER" fi # Move the new folder to the backup loc

deployment pre patch

 #!/bin/bash # Check if all required arguments are provided if [ "$#" -ne 5 ]; then     echo "Usage: $0 <SCRIPT_BASE> <CHANGE_NUMBER> <FRAME> <DBHOME_NUMBER> <CLUSTER_NAME>"     exit 1 fi SCRIPT_BASE=$1 CHANGE_NUMBER=$2 FRAME=$3 DBHOME_NUMBER=$4 CLUSTER_NAME=$5 # Define paths SCRIPT_LOCATION="/auto/data.misc/oracle/VAT_PATCH/19.22/PRE_INSTALL" PATCH_LOG="$SCRIPT_LOCATION/PATCH_LOG" # Create directories mkdir -p "$SCRIPT_LOCATION" "$PATCH_LOG" # Tar and extract files tar -xf /auto/data.misc/oracle/VAT_PATCH/19.22/PRE_INSTALL.tar.gz -C "$SCRIPT_LOCATION" # Update ssl jan2024.conf with provided parameters sed -i "s/CHANGE_NUMBER/$CHANGE_NUMBER/g" "$SCRIPT_LOCATION/ssl_jan2024.conf" sed -i "s/FRAME/$FRAME/g" "$SCRIPT_LOCATION/ssl_jan2024.conf" sed -i "s/DBHOME_NUMBER/$DBHOME_NUMBER/g" "$SCRIPT_LOCATION/ssl_jan2024.conf" # Update pat

Golden gate stop v1

#!/bin/bash read -p "Enter the log directory: " log_dir if [ -z "$log_dir" ]; then     echo "Log directory not provided. Exiting."     exit 1 fi mkdir -p "$log_dir" for value in $(locate setup_ogg | grep -E '/setup_ogg$'); do     source $value     cp $value $value_prepatch_bkp'$(date +"%Y%m%d%H%M%S")'     GG_HOME=$(dirname "$value")     GG_HOME_FILE=$(echo "$GG_HOME" | tr '/' '_')     log_file="$log_dir/gg_info_$GG_HOME_FILE.log"     cd "$GG_HOME"     echo "==cccccces === ============" > "$log_file"     echo "Executing 'info all' in $GG_HOME" >> "$log_file"     ./ggsci <<EOF >> "$log_file"     STOP ER * detail EOF done # Capture the log without the header export ORACLE_SID=$(ps -ef | grep '[a]sm_smon.*+ASM' | awk '{print $NF}' | cut -d '_' -f3) source oraenv <&l

Oratab Entries validate and add

#!/bin/bash # Ask user for log directory read -p "Enter the log directory: " log_directory log_directory=$(realpath "$log_directory") # Ask user for file2 (sop.conf) name read -p "Enter the name of sop.conf file: " file2_name file2_path="$log_directory/$file2_name" # Phase 1: Generate db_unique_name_version.log for SID in $(ps -ef | grep '[o]ra_smon' | awk '{print $NF}' | cut -d '_' -f3); do     export ORACLE_SID=$SID     source oraenv <<< "$SID"     # Get DB unique name and version using the first query     DB_UNIQUE_NAME_INFO=$(sqlplus -s / as sysdba <<EOF set feedback off set heading off SELECT d.DB_UNIQUE_NAME || ':' || SUBSTR(i.VERSION, 1, 2) FROM v\$database d, v\$instance i; EOF     )     # Get instance name and version using the second query     INSTANCE_NAME_INFO=$(sqlplus -s / as sysdba <<EOF set feedback off set heading off SELECT i.INSTANCE_NAME || ':' || SUBSTR(i.