Friday, April 25, 2025

#!/bin/bash # Script: recreate_redologs.sh # Usage: ./recreate_redologs.sh # Initialize variables INPUT_FILE=$1 LOG_FILE="redo_recreation_$(date +%Y%m%d%H%M%S).log" TMP_DIR="/tmp/redo_workdir" mkdir -p $TMP_DIR # Load input parameters source $INPUT_FILE || { echo "Error loading input file"; exit 1; } # Database connection strings PRIMARY_CONN="${SYS_USER}/${SYS_PASSWORD}@${DB_NAME}" # Get standby DB name using dgmgrl get_standby_db() { dgmgrl -silent ${PRIMARY_CONN} < $TMP_DIR/primary_groups.lst log "Capturing existing groups on standby" capture_groups $STANDBY_CONN STANDBY > $TMP_DIR/standby_groups.lst # Create new groups on primary log "Creating new primary redo logs" awk -F, '/PRIMARY/{print $2}' $TMP_DIR/primary_groups.lst | sort -u | while read thread; do count=$(grep ",$thread,PRIMARY" $TMP_DIR/primary_groups.lst | wc -l) create_new_groups $PRIMARY_CONN PRIMARY $NEW_REDO_SIZE $thread $count done # Create new standby logs on standby log "Creating new standby redo logs" awk -F, '/STANDBY/{print $2}' $TMP_DIR/standby_groups.lst | sort -u | while read thread; do count=$(grep ",$thread,STANDBY" $TMP_DIR/standby_groups.lst | wc -l) create_new_groups $STANDBY_CONN STANDBY $NEW_STANDBY_REDO_SIZE $thread $count done # Switch logs and wait for old groups to become inactive log "Forcing log switches on primary" for i in {1..10}; do sqlplus -S $PRIMARY_CONN <