Db running on nodes
#!/bin/bash
# Check if ASM SID is passed as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <ASM_SID>"
exit 1
fi
# Set the Oracle SID (ASM) and source environment using oraenv
export ORACLE_SID=$1
export ORAENV_ASK=NO
source oraenv > /dev/null
# Define log file
LOG_FILE="exadata_db_config.log"
> "$LOG_FILE" # Clear previous log content
# Print header
echo -e "Database Unique Name | Database Instances | Configured Nodes" | tee -a "$LOG_FILE"
echo "--------------------------------------------------------------" | tee -a "$LOG_FILE"
# Get list of all databases managed by Grid Infrastructure
DB_LIST=$(srvctl config database | sort -u)
# Loop through each database and fetch required details
for DB in $DB_LIST; do
DB_NAME=$(srvctl config database -d "$DB" | grep -i "Database unique name" | awk -F": " '{print $2}')
INSTANCES=$(srvctl config database -d "$DB" | grep -i "Database instances" | awk -F": " '{print $2}')
NODES=$(srvctl config database -d "$DB" | grep -i "Configured nodes" | awk -F": " '{print $2}')
# Print in single-row format
echo -e "$DB_NAME | $INSTANCES | $NODES" | tee -a "$LOG_FILE"
done
echo "--------------------------------------------------------------" | tee -a "$LOG_FILE"
echo "Database configuration check completed. Log saved in $LOG_FILE."
Comments
Post a Comment