Thursday, February 22, 2024

Oracle GoldenGate Script for Troubleshooting

Oracle GoldenGate is a comprehensive software product that enables real-time data integration, replication, and synchronization across heterogeneous systems. It supports continuous data streaming with minimal latency and offers high availability and data integrity. GoldenGate facilitates data replication between different database platforms, including Oracle Database, Microsoft SQL Server, MySQL, and others, allowing organizations to achieve real-time data integration for analytics, reporting, disaster recovery, and distributed data environments. Its capabilities include data transformation, filtering, conflict resolution, and support for complex replication topologies, making it a powerful solution for maintaining synchronized data across diverse IT landscapes.

This script checks if Oracle Golden Gate process is running or not and give the exact starting point to catch up:


#!/bin/bash

. /etc/profile

#. /home/oracle/.bash_profile 


YYMMDD=`date +%Y%m%d`

LOG_DIR=/home/oracle/GGscript/log

WRK_DIR=/home/oracle/GGscript/work

LOG_FL=${LOG_DIR}/${ORACLE_SID}_gg_chk.log

WRK_FL=${WRK_DIR}/gg_chk_${ORACLE_SID}_gg_chk.wrk

BAD_FL=${WRK_DIR}/gg_chk_${ORACLE_SID}_gg_chk.bad


export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_home1

export PATH=$ORACLE_HOME/bin:$PATH/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/local/lib

DBA_MAIL_ADDR='ADD_EMAIL@HERE.com'

HOSTNAME=`uname -n | tr '[a-z]' '[A-Z]'`

{

echo "###########################################"

echo "GG Check Up `basename $0` started t `date`"


#check if maint flag is on

if [ -f /home/oracle/work/${ORACLE_SID}_maintenance.on ] ; then

   echo "Maintenance flag is on .... stop "

   exit 0

fi


### Check GG processes

cd /ggs

echo "info all" | /ggs/ggsci | sed -e '1,/^Program/d' -e '/^GGSCI/,$d' -e '/^ *$/d' | tee $WRK_FL

echo " "

cat $WRK_FL | grep -v 'RUNNING'| grep -iv 'test' | tee $BAD_FL


non_run_cnt=0

if [ -f $BAD_FL ] ; then

   non_run_cnt=`wc -l $BAD_FL |awk '{print $1}'`

fi

echo "GG Process Not Running: $non_run_cnt "


if [[ $non_run_cnt -gt 0 ]] ; then

   echo "\nEmail support team ($DBA_MAIL_ADDR) about failed processes "

   cat $BAD_FL

   mailx -s "$HOSTNAME : ALERT: One or more Goldengate Process in ${ORACLE_SID} are down ($non_run_cnt)!!!" $DBA_MAIL_ADDR < $BAD_FL

fi



rm -f $WRK_FL $BAD_FL  $LAGWRK_FL $LAG_FL $LAG_LST

echo "GG Check Up `basename $0` finished at `date`"

echo "###########################################"


} 2>&1 | tee $LOG_FL 

 


No comments: