#!/bin/ksh
############################################################################
# Script Name..: gg_common.ksh
# Description..: Common GG Hub functions for inclusion to all driver scripts
# Author.......: Michael Culp
# Date.........: 04/23/2010
# Version......: .65
# Modified By..: Michael Culp
# Date Modified: 06/07/2017
# Comments.....: Change this library to make mods to all functions
# Schema owner.: N/A
# Dependent on.: N/A
# Script type..: function library
# Function list:
############################################################################

############################################################################
#
############################################################################

gg_init()
##########################################################
# These variables should be set prior to setup
# Call this function anytime the variables need to be
# set for values that will be utilized in other functioons
# gg_init should be used to determine which environment
# needs to be setup
#########################################################
{

# Take a parameter for the instance
gginst=$1

# Do not change the following 2 variables
#########################################################
ggcomver=".92"
ggcomdt="10/18/2018"

# set -xv
# This will set the ggini file based on the hostname
#########################################################
initflnm=`hostname -a`".ggini"

echo "Display the init file name"
echo $initflnm

# Test to see if the is an init file first
# if so read it, otherwise set these variables

#   future enhancement check for various scripts standard names
echo
echo
echo "Checking for the existance of the ggini initialization file.."
echo

# if [ -f /oracle/admin/scripts/ggcommon/`hostname -a`.ggini ]; then
if [ -f /oracle/admin/scripts/ggcommon/`hostname -a`.gginix ]; then
   echo "....file exists...."
   echo
   echo " The ggini file was read ....Y"
   echo
   echo "....reading variables from the .ggini file....."
   echo
#   . ./`hostname -a`.ggini
   . /oracle/admin/scripts/ggcommon/`hostname -a`.ggini
else
   echo "....file does not exist"
   echo
   echo " The ggini file was not read ...."
   echo
   echo "....reading variables from the gg_init function....."
   echo
   #########################################################
   # Set the Oracle inventory location
   #########################################################
   orainv="/oracle/oraInventory"

   echo
   echo "Running gg_init function()......."
   echo

   #######################################################
   # GoldenGate operational directory
   # This needs to be set during build of additional
   # GoldenGate instances
   #######################################################
   # gg_dir="/oracle/product/gg123"
   # gg_dir="/oracle/product/gg123ms"
   # gg_dir="/oracle/product/gg122"

   # gg_dir="/oracle/product/ggvad001"
   # gg_dir="/oracle/product/ggvad001"
   # gg_dir="/oracle/product/ggvad001"
   # gg_dir="/oracle/product/ggtxd003"
   # gg_dir="/oracle/product/ggtxd002"
   # gg_dir="/oracle/product/ggtxd001"
   # gg_dir="/oracle/product/ggtxd006"
   # gg_dir="/oracle/product/ggtxd007"
   gg_dir="/oracle/product/ggvat004"

   # gg_dir="/oracle/product/gg121"

   export GGS_HOME=$gg_dir

   export OGG_HOME=$GGS_HOME

   #######################################################
   # GoldenGate version
   # We support GG 12.1, 12.2, 12.3 currently
   #######################################################
   ggver="12.3"
   # ggver="12.2"
   # ggver="12.1"

   # export DBFS_MNT=/dbfs

   #######################################################
   # GoldenGate source version
   #######################################################
   ggsrcver="12.1"

   #######################################################
   # ggflnm - is the zip file name of the GG distro
   # This is the name of the goldengate zip files
   #######################################################
   # File below is 12.3.0.1.2
   ggflnm="123014_fbo_ggs_Linux_x64_shiphome.zip"

   # File below is 12.3.0.1.2
   # ggflnm="123012_fbo_ggs_Linux_x64_shiphome.zip"

   # File below is 12.2
   # ggflnm="V100692-01.zip"

   # File below is 12.3 Micro Service Architecture
   # ggflnm="123010_fbo_ggs_Linux_x64_shiphome.zip"
   #######################################################

   #######################################################
   # ggdir_dist - directory of the distro zip file
   # This is the name of the directory where the distribution GoldenGate software is stored
   # Choose one and uncomment it
   #######################################################
   ##### GoldenGate ver. 12.3
   # ggdir_dist="/ora01/Oracle_SW/gg123/"
   ##### GoldenGate ver. 12.3.0.1.4
   ggdir_dist="/ora01/Oracle_SW/gg123/123014/"
   ##### GoldenGate ver. 12.3 MicroService Architecture
   # ggdir_dist="/ora01/Oracle_SW/gg123ms/"
   # ggdir_dist="/ora01/Oracle_SW/gg122/"
   # ggdir_dist="/ora01/Oracle_SW/gg121/"

   #######################################################
   # gginstdir - Location of the installer
   # GoldenGate installer directory
   #######################################################
   gginstdir=$ggdir_dist"fbo_ggs_Linux_x64_shiphome/Disk1"

   #######################################################
   # ggrspfldir - Response file directory
   # Response file directory
   #######################################################
   ggrspfldir=$ggdir_dist"fbo_ggs_Linux_x64_shiphome/Disk1/response"

   #######################################################
   # ggrspfl - response file name
   # Response file name for install of the GG binaries
   #######################################################
   ggrspfl="oggcore_mrc.rsp"

   #######################################################
   # XAG version
   #######################################################
   # xagver="7.1b"
   # xagver="8.1b"
   xagver="9.1"

   #######################################################
   # This is the name of the directory where the XAG software is stored
   #######################################################
   # xagdir_dist="/ora01/Oracle_SW/xag71/"
   # xagdir_dist="/ora01/Oracle_SW/xag81b/"
   xagdir_dist="/ora01/Oracle_SW/xag91/"


   #######################################################
   # XAG Ops directory
   # This is the operational directory for XAG
   #######################################################
   # xagdir="/oracle/product/xag_71"
   # xagdir="/oracle/product/xag_81b"
   xagdir="/oracle/product/xag_91"


   #######################################################
   # XAG home directory
   #######################################################
   XAG_HOME=/oracle/product/xag_91
   XAG_LOG=/oracle/product/xag_91/log/nodename


   #######################################################
   # This is the name of the xag zip file
   #######################################################
   # xagflnm="xagpack81b.zip"
   xagflnm="xagpack91.zip"

   # Read the GG environment files
   # . ./ggoraenv.env

fi

XAG_SD=/oracle/admin/scripts/ggcommon

CRS_SD=/oracle/admin/scripts/crsdbfs
DBFS_SD=/oracle/admin/scripts/clle_dbfscommon
GG_SD=/oracle/admin/scripts/ggcommon
ASM_SD=/oracle/admin/scripts/asmcommon
DG_SD=/oracle/admin/scripts/dgcommon


############################################################################
# Show the variable status dashboard,  comment this line to not display it
############################################################################
gg_init_dbrd

}

gg_init_dbrd()
########################################################
# This is a display dashboard that shows the values of
# Environmental variables
# used in various functions
########################################################
{

echo
echo "Change variables in gg_common.ksh gg_init...."
echo "Display with gg_init_dbrd function .........."
echo

echo
echo "..gg_common.ksh ver. $ggcomver Date $ggcomdt"
echo "....Oracle Inventory location................: " $orainv
echo "....GoldenGate Version.......................: " $ggver
echo "....GoldenGate Source Version supported......: " $ggsrcver
echo
echo "================= Installation Parameters ======================="
echo "....GoldenGate Filename......................: " $ggflnm
echo "....GoldenGate software distribution dir.....: " $ggdir_dist
echo "....GoldenGate Response File Dir.............: " $ggrspfldir
echo "....GoldenGate Response File ................: " $ggrspfl
echo "....GoldenGate Installer directory...........: " $gginstdir
echo "....GoldenGate Ops  Directory................: " $gg_dir
echo "....GoldenGate Home..GGS_HOME................: " $GGS_HOME
echo "....GoldenGate Home..OGG_HOME................: " $OGG_HOME
echo
echo "....XAG Version..............................: " $xagver
echo "....XAG Filename.............................: " $xagflnm
echo "....XAG Dist directory.......................: " $xagdir_dist
echo "....XAG Ops directory........................: " $xagdir
echo "....XAG Home directory.......................: " $XAG_HOME
echo ".......XAG scripts directory.................: " $XAG_SD
echo "....XAG Log Directory........................: " $XAG_LOG
echo
echo "================= DBFS Parameters =============================="

echo "================= Scripts Directoriess ========================="
echo ".......CRS.................: " $CRS_SD
echo ".......DBFS................: " $DBFS_SD
echo ".......GoldenGate..........: " $GG_SD
echo ".......XAG.................: " $XAG_SD
echo ".......DataGuard...........: " $DG_SD
echo "================================================================"

echo
echo "....LD_LIBRARY_PATH..........................: " $LD_LIBRARY_PATH
echo
echo "....PATH.....................................: " $PATH
echo

echo "Installation directories......................."
echo
ls -lt /oracle/product/


# echo "Show ldd for libraries........................."
# ldd -d extract
# echo "....end transmission..........................."

}

gg_cr_env()
###############################################################################
# Create the ggoraenv.env file
###############################################################################
{

#
# Environment
#

################################################################
# usedate=`date +%a`
################################################################
usedate=`date +%d-%h-%Y`

echo $usedate

echo
echo "...Creating ggoraenv_"$usedate".env...."
echo

# echo > ggoraenv.env
cat << EOS > ggoraenv_$usedate.env

# export ORACLE_HOME=/oracle/product/
# export ORACLE_SID=
# export LD_LIBRARY_PATH=

# GGS_HOME=/oracle/product/gg12.1
# GGS_HOME=/oracle/product/12.2/gg_2
# export GGS_HOME=/u01/app/oracle/product/12.2/gg_2
# export GGS_HOME=$gg_dir
# GGS_HOME=\$gg_dir
# export GGS_HOME=$gg_dir
export GGS_HOME=/oracle/product/gg122

export GG_SITE=01
# export GG_SITE=02
# export GG_SITE=03
# export GG_SITE=04
# export GG_SITE=05
# export GG_SITE=06
# export GG_SITE=07
export GG_LOC=TX
# export GG_LOC=VA

# if there is only one DB related to this GG home,
# set NEW_ORACLE_SID to avoid constant switch between a DB env and its GG env
# export NEW_ORACLE_SID=DBFSXD011; . ~/.std_profile

# otherwise, set NEW_ORACLE_SID to dummy if there are multiple replicated databases related to same GG home
# export NEW_ORACLE_SID=dummy; . ~/.std_profile

# uncomment next three lines if  ORACLE_SID is dummy
# export ORACLE_HOME=/oracle/product/11.2.0/db_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib/$JAVA_HOME/lib/amd64/server:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

export PATH=$GGS_HOME:$PATH
export LD_LIBRARY_PATH=$GGS_HOME:$LD_LIBRARY_PATH

# for OEM12c GG monitoring
# export JAVA_HOME=/oracle/product/12.1.0/oem_1/agent/core/12.1.0.2.0/jdk/jre
# export PATH=$JAVA_HOME/bin:$PATH
# export LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64/server:$LD_LIBRARY_PATH

TZ=UTC
export TZ

#############################################
## For GI Agent (XAG)
##############################################
# export XAG_HOME=/oracle/product/xag71
# export XAG_HOME=/oracle/product/xag81b
# export XAG_HOME=/oracle/product/xag91
# export PATH=$XAG_HOME/bin:$PATH

##############################################
# Change the prompt
##############################################
PS1="\\
\${PWD} \\
\${SNAME} [\${ORACLE_SID}] [GG_site$GG_SITE"_"$GG_LOC]-> "
export PS1

# alias ggsora12='. $HOME/.ggsora12_env;cd $GGS_HOME'
# alias ggsora12='. /ora_rman/ora013/mrc/gg/ggoraenv.env;cd $GGS_HOME'
# alias xag='. $HOME/.ggsora12_env;cd $XAG_HOME'
# alias ggstatus='$XAG_HOME/bin/agctl status goldengate piperd01_oggapp'

echo "GGS_HOME is : " $GGS_HOME

# export TMPLT=/oracle/product/11.2.0/db_1/assistants/dbca/templates
export TMPLT=/oracle/product/12.1.0/db_1/assistants/dbca/templates
export ADMSCR=/oracle/admin/scripts
export APXSCR=/oracle/admin/scripts/apex
export GGADMSCR=/oracle/admin/scripts/ggcommon
export APXADMSCR=/oracle/admin/scripts/apex

alias admscr='cd $ADMSCR'
alias apxscr='cd $APXADMSCR'
alias tmplt='cd $TMPLT'
alias ggadmscr='cd $GGADMSCR'

alias gi='cd /oracle_crs/product/11.2.0/crs_2/log/$HOST'
alias ocssd='cd /oracle_crs/product/11.2.0/crs_2/log/$HOST/cssd'
alias crsd='cd /oracle_crs/product/11.2.0/crs_2/log/$HOST/crsd'

GGS_HOME=/oracle/product/12.2/gg_2
alias gh='cd $GGS_HOME'
alias gd='cd /ggate'
#############################################
# For GoldenGate
#############################################
export GGS_HOME=/oracle/product/12.2/gg_2
export PATH=$GGS_HOME:$PATH
export LD_LIBRARY_PATH=$GGS_HOME:$LD_LIBRARY_PATH


EOS
}


 

Ready for Action?

LET'S GO!
Copyright 2024 IT Remote dot com
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram