Monitoring For Stability

Adding Heartbeat To GoldenGate

This pertains to the version of GoldenGate 12.2 => 18.1

ADD HEARTBEATTABLE [, FREQUENCY number in seconds] [, RETENTION_TIME number in days] | [, PURGE_FREQUENCY number in days]

FREQUENCY = Specifies how often the heartbeat seed table and heartbeat table are updated. For example, how frequently heartbeat records are generated. The default is 60 seconds.

RETENTION_TIME = Specifies when heartbeat entries older than the retention time in the history table are purged. The default is 30 days.

PURGE_FREQUENCY = Specifies how often the purge scheduler is run to delete table entries that are older than the retention time from the heartbeat history . The default is 1 day.

What is written to trail file 12.2 / 12.3

What is written to trail file 12.1


CREATE USER

create tablespace gg_data datafile '/u01/app/oracle/oradata/srcxxt01/gg_data.dbf' size 1024M;

create user ogguser identified by ogg
default tablespace gg_data temporary tablespace temp
quota unlimited on gg_data;
grant select any table to ogguser ;
grant select any transaction to ogguser ;
grant select any dictionary to ogguser ;
grant flashback  any table to ogguser ;
grant execute on dbms_flashback to ogguser ;
grant create session, alter session to ogguser ;
grant connect,resource to ogguser ;
grant alter any table to ogguser ;
grant alter system to ogguser ;
grant execute on sys.dbms_internal_clkm to ogguser ;
exec dbms_goldengate_auth.grant_admin_privilege('ogguser');






create user testrep identified by testrep
default tablespace users temporary tablespace temp;

grant connect to testrep;
alter user testrep default role connect;
grant create session to testrep;
grant resource to testrep;
alter user testrep quota unlimited on users;



truncate table stress1;
truncate table stress2;
truncate table stress3;
truncate table stress4;
truncate table stress5;
truncate table stress6;
truncate table stress7;




make_testrep_objects.sql

DROP TABLE STRESS1 CASCADE CONSTRAINTS ;

CREATE TABLE STRESS1 (
  FIELD1   VARCHAR2 (10)  NOT NULL,
  FIELD2   VARCHAR2 (10)  NOT NULL,
  FIELD3   VARCHAR2 (10)  NOT NULL,
  NUM1     NUMBER        NOT NULL,
  NUM2     NUMBER,
  DATE1    DATE,
  FIELD4   VARCHAR2 (20),
  FIELD5   VARCHAR2 (20),
  FIELD6   VARCHAR2 (20),
  NUM3     NUMBER,
  NUM4     NUMBER,
  FIELD7   VARCHAR2 (20),
  FIELD14  VARCHAR2 (20),
  FIELD8   VARCHAR2 (20),
  FIELD9   VARCHAR2 (20),
  FIELD10  VARCHAR2 (20),
  FIELD11  VARCHAR2 (20),
  FIELD12  VARCHAR2 (20),
  FIELD13  VARCHAR2 (20),
  DATE2    DATE,
  DATE3    DATE,
  NUM5     NUMBER,
  NUM6     NUMBER,
  NUM7     NUMBER,
  NUM8     NUMBER,
  NUM9     NUMBER,
  NUM10    NUMBER,
  NUM11    NUMBER,
  FIELD15  VARCHAR2 (20),
  CONSTRAINT STRESS1_PK
  PRIMARY KEY ( NUM1, FIELD1, FIELD2, FIELD3 )
    USING INDEX
     TABLESPACE USERS PCTFREE 10
     STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
 TABLESPACE USERS
   PCTFREE 10   PCTUSED 40
   INITRANS 1   MAXTRANS 255
 STORAGE (
   INITIAL 2M NEXT 2M PCTINCREASE 0
   MINEXTENTS 1 MAXEXTENTS 4096 )
   NOCACHE;


drop sequence stress1_seq;


create sequence stress1_seq start with 1
increment by 1;


DROP TABLE STRESS2 CASCADE CONSTRAINTS ;


CREATE TABLE STRESS2 (
  FIELD1   VARCHAR2 (10)  NOT NULL,
  FIELD2   VARCHAR2 (10)  NOT NULL,
  FIELD3   VARCHAR2 (10)  NOT NULL,
  NUM1     NUMBER        NOT NULL,
  NUM2     NUMBER,
  DATE1    DATE,
  FIELD4   VARCHAR2 (20),
  FIELD5   VARCHAR2 (20),
  FIELD6   VARCHAR2 (20),
  NUM3     NUMBER,
  NUM4     NUMBER,
  FIELD7   VARCHAR2 (20),
  FIELD14  VARCHAR2 (20),
  FIELD8   VARCHAR2 (20),
  FIELD9   VARCHAR2 (20),
  FIELD10  VARCHAR2 (20),
  FIELD11  VARCHAR2 (20),
  FIELD12  VARCHAR2 (20),
  FIELD13  VARCHAR2 (20),
  DATE2    DATE,
  DATE3    DATE,
  NUM5     NUMBER,
  NUM6     NUMBER,
  NUM7     NUMBER,
  NUM8     NUMBER,
  NUM9     NUMBER,
  NUM10    NUMBER,
  NUM11    NUMBER,
  FIELD15  VARCHAR2 (20),
  CONSTRAINT STRESS2_PK
  PRIMARY KEY ( NUM1, FIELD1, FIELD2, FIELD3 )
    USING INDEX
     TABLESPACE USERS PCTFREE 10
     STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
 TABLESPACE USERS
   PCTFREE 10   PCTUSED 40
   INITRANS 1   MAXTRANS 255
 STORAGE (
   INITIAL 2M NEXT 2M PCTINCREASE 0
   MINEXTENTS 1 MAXEXTENTS 4096 )
   NOCACHE;

drop sequence stress2_seq;



create sequence stress2_seq start with 1
increment by 1;


DROP TABLE STRESS3 CASCADE CONSTRAINTS ;

CREATE TABLE STRESS3 (
  FIELD1   VARCHAR2 (10)  NOT NULL,
  FIELD2   VARCHAR2 (10)  NOT NULL,
  FIELD3   VARCHAR2 (10)  NOT NULL,
  NUM1     NUMBER        NOT NULL,
  NUM2     NUMBER,
  DATE1    DATE,
  FIELD4   VARCHAR2 (20),
  FIELD5   VARCHAR2 (20),
  FIELD6   VARCHAR2 (20),
  NUM3     NUMBER,
  NUM4     NUMBER,
  FIELD7   VARCHAR2 (20),
  FIELD14  VARCHAR2 (20),
  FIELD8   VARCHAR2 (20),
  FIELD9   VARCHAR2 (20),
  FIELD10  VARCHAR2 (20),
  FIELD11  VARCHAR2 (20),
  FIELD12  VARCHAR2 (20),
  FIELD13  VARCHAR2 (20),
  DATE2    DATE,
  DATE3    DATE,
  NUM5     NUMBER,
  NUM6     NUMBER,
  NUM7     NUMBER,
  NUM8     NUMBER,
  NUM9     NUMBER,
  NUM10    NUMBER,
  NUM11    NUMBER,
  FIELD15  VARCHAR2 (20),
  CONSTRAINT STRESS3_PK
  PRIMARY KEY ( NUM1, FIELD1, FIELD2, FIELD3 )
    USING INDEX
     TABLESPACE USERS PCTFREE 10
     STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
 TABLESPACE USERS
   PCTFREE 10   PCTUSED 40
   INITRANS 1   MAXTRANS 255
 STORAGE (
   INITIAL 2M NEXT 2M PCTINCREASE 0
   MINEXTENTS 1 MAXEXTENTS 4096 )
   NOCACHE;

drop sequence stress3_seq;

create sequence stress3_seq start with 1
increment by 1;


DROP TABLE STRESS4 CASCADE CONSTRAINTS ;

CREATE TABLE STRESS4 (
  FIELD1   VARCHAR2 (10)  NOT NULL,
  FIELD2   VARCHAR2 (10)  NOT NULL,
  FIELD3   VARCHAR2 (10)  NOT NULL,
  NUM1     NUMBER        NOT NULL,
  NUM2     NUMBER,
  DATE1    DATE,
  FIELD4   VARCHAR2 (20),
  FIELD5   VARCHAR2 (20),
  FIELD6   VARCHAR2 (20),
  NUM3     NUMBER,
  NUM4     NUMBER,
  FIELD7   VARCHAR2 (20),
  FIELD14  VARCHAR2 (20),
  FIELD8   VARCHAR2 (20),
  FIELD9   VARCHAR2 (20),
  FIELD10  VARCHAR2 (20),
  FIELD11  VARCHAR2 (20),
  FIELD12  VARCHAR2 (20),
  FIELD13  VARCHAR2 (20),
  DATE2    DATE,
  DATE3    DATE,
  NUM5     NUMBER,
  NUM6     NUMBER,
  NUM7     NUMBER,
  NUM8     NUMBER,
  NUM9     NUMBER,
  NUM10    NUMBER,
  NUM11    NUMBER,
  FIELD15  VARCHAR2 (20),
  CONSTRAINT STRESS4_PK
  PRIMARY KEY ( NUM1, FIELD1, FIELD2, FIELD3 )
    USING INDEX
     TABLESPACE USERS PCTFREE 10
     STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
 TABLESPACE USERS
   PCTFREE 10   PCTUSED 40
   INITRANS 1   MAXTRANS 255
 STORAGE (
   INITIAL 2M NEXT 2M PCTINCREASE 0
   MINEXTENTS 1 MAXEXTENTS 4096 )
   NOCACHE;


drop sequence stress4_seq;

create sequence stress4_seq start with 1
increment by 1;



DROP TABLE STRESS5 CASCADE CONSTRAINTS ;

CREATE TABLE STRESS5 (
  FIELD1   VARCHAR2 (10)  NOT NULL,
  FIELD2   VARCHAR2 (10)  NOT NULL,
  FIELD3   VARCHAR2 (10)  NOT NULL,
  NUM1     NUMBER        NOT NULL,
  NUM2     NUMBER,
  DATE1    DATE,
  FIELD4   VARCHAR2 (20),
  FIELD5   VARCHAR2 (20),
  FIELD6   VARCHAR2 (20),
  NUM3     NUMBER,
  NUM4     NUMBER,
  FIELD7   VARCHAR2 (20),
  FIELD14  VARCHAR2 (20),
  FIELD8   VARCHAR2 (20),
  FIELD9   VARCHAR2 (20),
  FIELD10  VARCHAR2 (20),
  FIELD11  VARCHAR2 (20),
  FIELD12  VARCHAR2 (20),
  FIELD13  VARCHAR2 (20),
  DATE2    DATE,
  DATE3    DATE,
  NUM5     NUMBER,
  NUM6     NUMBER,
  NUM7     NUMBER,
  NUM8     NUMBER,
  NUM9     NUMBER,
  NUM10    NUMBER,
  NUM11    NUMBER,
  FIELD15  VARCHAR2 (20),
  CONSTRAINT STRESS5_PK
  PRIMARY KEY ( NUM1, FIELD1, FIELD2, FIELD3 )
    USING INDEX
     TABLESPACE USERS PCTFREE 10
     STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
 TABLESPACE USERS
   PCTFREE 10   PCTUSED 40
   INITRANS 1   MAXTRANS 255
 STORAGE (
   INITIAL 2M NEXT 2M PCTINCREASE 0
   MINEXTENTS 1 MAXEXTENTS 4096 )
   NOCACHE;

drop sequence stress5_seq;


create sequence stress5_seq start with 1
increment by 1;


DROP TABLE STRESS6 CASCADE CONSTRAINTS ;
                                                                               265,1         42%
begin
  for loop_var in 1..overall loop
     for loop_ins in 1..ins loop
       insert into stress7 values(
       'thisisa','temporary','tablevalue',stress7_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
   end loop;
   commit;
   end loop;
end;
/

create or replace procedure rock_and_roll
(ins in number default 10, overall in number default 10)
as
 loop_var number(38);
 loop_ins number(38);
 tmpvar varchar2(50);
begin
  for loop_var in 1..overall loop
     for loop_ins in 1..ins loop
       insert into stress1 values(
       'thisisa','temporary','tablevalue',stress1_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress2 values(
       'thisisa','temporary','tablevalue',stress2_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress3 values(
       'thisisa','temporary','tablevalue',stress3_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress4 values(
       'thisisa','temporary','tablevalue',stress4_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress5 values(
       'thisisa','temporary','tablevalue',stress5_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress6 values(
       'thisisa','temporary','tablevalue',stress6_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
       insert into stress7 values(
       'thisisa','temporary','tablevalue',stress7_seq.nextval,12345,sysdate,
       'newwewil','determine','helloworld',12345,987654,
       '10charvld','11charfld','another1','biggest','smallest',
       'ashortone','dkdksjj',NULL,sysdate-1,sysdate-2,
       12345,23456,34567,45678,56789,98766,56783,
       'thelastone');
   end loop;
   commit;
   end loop;
end;
/


GG New Features 19c

GoldenGate DB Ready

Complete Database Profile OGG readiness check for Classic Extract

MOS Note:1298562.1:
Oracle 
GoldenGate database Complete Database Profile check script for Oracle DB (All Schemas) Classic Extract 

This script is intended to query all of the non default database users to identify current configuration and identify any unsupported data types or types that may need special considerations for Oracle GoldenGate in an Oracle environment.

GoldenGate Integrated Capture and Integrated Replicat Healthcheck Script (Doc ID 1448324.1)

Oracle 12 Setup

GoldenGate Setup for the Hub

Steps to setup a new environment on a node.

Assumptions.

 

These are all the manual steps required to implement resiliency for the GoldenGate hub.   Mike Culp has written scripts to do this process. In general, using scripting for a process that covers many different servers is a best practice approach, as it insures the installs are done in an identical fashion.  This reduces complexity of all maintenance.

 

Setup Overview

Each cluster on the Hub has its’ own database.  This database is used to supply a file system(s) for the trail files and other OGG files required for recovery.   The DBFS filesystem for the OGG files can only be mounted on one node at a time as a best practice. Otherwise duplicate processes could be started, which could cause corruption in the replication hub.  The data disk can be mounted on all systems if desired. If there is only one data group in a replication instance, it is possible to put all files on that one mount, and mount it to only one node at a time. But it is very difficult to undo that decision.

 

  1. Create a directories off the root filesystem system.
  2. Grant the oracle user full control of the dir.
  3. Create the tablespace for DBFS – standard create tablespace command.  The following example uses a bigfile tablespace but that is NOT required.
    1. create bigfile tablespace dbfs_tblsp datafile '+DBFS_DG' size 32g autoextend on next 8g maxsize 300g NOLOGGING EXTENT MANAGEMENT LOCAL AUTOALLOCATE  SEGMENT SPACE MANAGEMENT AUTO ;
  4. Create a user for that tablespace.
    1. At minimum, database users must have the following privileges to create a file system: GRANT CONNECT, CREATE SESSION, RESOURCE, CREATE TABLE, and CREATE PROCEDURE, and DBFS_ROLE
      1. create user dbfs_user identified by dbfs_passwd default tablespace dbfs_tblsp quota unlimited on dbfs_tblsp;
      2. grant create session, create table, create view, create procedure, dbfs_role to dbfs_user;
  5. Create the file system, logging in as the user created above.
    1. start dbfs_create_filesystem dbfs_tblsp dbfs_mnt
      1. This script takes two arguments:
        1. dbfs_tblsp: tablespace for the DBFS database objects
        2. dbfs_mnt : filesystem name, this can be any string and will appear as a directory under the mount point
    2. Validate the system is configured with nocache, logging
      1. SQL>  SELECT logging, cache FROM dba_lobs WHERE tablespace_name='DBFS_TBLSP';

LOGGING CACHE

------- ----------

YES     NO

  1. Modify/rename the mount-dbfs.conf and mount-dbfs.sh scripts for this instantiation.  Each OGG instance will have its own “name” used to identify it within crs. As such a different set of conf and sh script will be needed for each OGG instance.
  2. Test the mount-dbfs.sh script.  (start, stop , status). This validates the setup.
    1. Start should mount the file system.
    2. Stop should unmount.
    3. Status should return the status.
  3. Create a service for the instantation.
    1. srvctl add service -database db_name -service ggname_svc -preferred node1 -available node2
  4. Create the clusterware setup for the dbfs file system.  Use cluster resource to only allow it to be mounted one one node.  The data dbfs system can use local_resource.
    1. $GRID_HOME/bin/crsctl add resource dbfs_mnt \

-type cluster_resource \

-attr "ACTION_SCRIPT=/ora01/scripts/ggcommon/mount-dbfs.sh CHECK_INTERVAL=30 RESTART_ATTEMPTS=10 , \  START_DEPENDENCIES='hard(ora.raca_domain.db)pullup(ora.raca_domain.db)',STOP_DEPENDENCIES='hard(ora.raca_domain.db)',SCRIPT_TIMEOUT=300"

 

  1. Test crsctl to start,stop and relocate to validate it works.

$GRID_HOME/bin/start resource dbfs_mnt

  1. Create the goldengate soft links to the dbfs mounts.
    1. cd $GG_HOME
    2. mv dirprm dirprm.old
    3. mv dirchk dirchk.old
    4. mv dircrd dircrd.old
    5. mv dirrpt dirrpt.old
    6. ln –s /mnt/dbfs_mnt/dirprm dirprm
    7. ln –s /mnt/dbfs_mnt/dirchk dirchk
    8. ln –s /mnt/dbfs_mnt/dircrd dircrd
    9. ln –s /mnt/dbfs_mnt/dirrpt dirrpt
  2. Create the crs definition for goldengate using the XAG interface
    1. $XAG_HOME/bin/agctl add goldengate GG_SOURCE \ --gg_home /u01/oracle/goldengate \ --oracle_home /u01/app/oracle/product/12.2.0/dbhome_1 \  --db_services ggname_svc --use_local_services --filesystems dbfs_mnt
  3. Create the manager parameter file
  4. Start and stop the goldengate instance using agctl.   Validate the mgr process started.
  5. Create the required data dbfs file systems for the data.
  6. Create the crsctl definitions, if desired.  The only difference is -cluster_resource is not used, as the data can be mounted on all systems with no issues.  The only reason for the crsctl definitions is to startup the mount system automatically, there is no failover required.

The system is ready for replication, however the same setup, with the exception of the XAG and CRS configuration is required for all nodes/clusters that may run this instantiation of GoldenGate.  The XAG and the crs setup is only done once per cluster.

 


#!/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_inst_init()
{

echo
echo "Create Install INIT file....."
echo
cat << EOS > gg_inst_init_$gginst.env

export GGS_HOME=/oracle/product/gg122

EOS

}

gg_unzip()
##############################################
# Unzip the GG distribution file
# See gg_init function for the variables:
#     ggdir_dist
#     ggflnm
##############################################
{

ggdir_dist=$1
ggflnm=$2

echo
echo "Unzip function...."
echo

cd $ggdir_dist
unzip $ggflnm

}




 1="lrdne67mp" 2="[DBFSXD011"]-> cat crs_common.ksh

##############################################################################
# CRS Common functions
#
##############################################################################

crs_inst_order()
{

echo
echo "Function name.: crs_inst_order................."
echo "Library file..: crs_common.ksh................."
echo "Directory ....: /oracle/admin/scripts/crsdbfs.."
echo
echo "Shows the installation order for the CRS services..."
echo

echo "Create a service first for GoldenGate"
echo " function - srvctl_add_svc"
echo " add a resource in CRS for DBFS (crs_add_res_dbfs)......"
echo "   naming is dbfs_ gg instance name.."
echo " start the DBFS resource............."
echo " stop the DBFS resource.............."
echo " status of the resource.............."
echo " relocate the resource..............."
echo " "

}

crs_res_add_dbfs()
##############################################################################
# Add resource to CRS for DBFS
##############################################################################
{

# GoldenGate XAG Instance
gg_inst=$1

# Database for dependencies
dbnm=$2

# Project Directory
projdir=$3

echo $gg_inst
echo $dbnm
echo $projscr
echo $projdir/mount_dbfs_$gg_inst.bsh

echo
echo "Function name.: crs_res_add_dbfs..............."
echo "Library file..: crs_common.ksh................."
echo "Directory ....: /oracle/admin/scripts/crsdbfs.."
echo
echo "Creating a CRS resource for DBFS..............."
echo

######################################################################
# Check to see if the .bsh script has been created ...."
######################################################################
if [ ! -f "$projscr/mount_dbfs_$gg_inst.bsh" ]; then
   echo
   echo "The mount script does not exist please create and re-run";
   echo
   exit
else
   echo
   echo "The mount script exists and proceeding with CRS resource create"
   echo
fi

######################################################################
# Check to see if the .conf file has been created ...."
######################################################################
if [ ! -f "$projscr/mount-dbfs_$gg_inst.conf" ]; then
   echo
   echo "The mount conf file does not exist please create and re-run";
   echo
   exit
else
   echo "The mount conf file exists and proceeding with CRS resource create"
fi

echo
echo "Adding CRS resource for DBFS dbfs_"$gg_inst
echo "MAKE SURE THE mount_dbfs script is in place before executing this!!!!"
echo

$CRS_HOME/bin/crsctl add resource dbfs_${gg_inst} -type cluster_resource -attr "ACTION_S                                  CRIPT=$projscr/mount_dbfs_${gg_inst}.bsh, CHECK_INTERVAL=30, RESTART_ATTEMPTS=10, START_                                  DEPENDENCIES='hard(ora.$dbnm.db)pullup(ora.$dbnm.db)',STOP_DEPENDENCIES='hard(ora.$dbnm.                                  db)',SCRIPT_TIMEOUT=300"

# /oracle_crs/product/12.1.0.2/crs_1/bin/crsctl add resource dbfs_${gg_inst} -type clust                                  er_resource -attr "ACTION_SCRIPT=/oracle/admin/scripts/crsdbfs/wrap_mount_dbfs_${gg_inst                                  }.bsh, CHECK_INTERVAL=30, RESTART_ATTEMPTS=10, START_DEPENDENCIES='hard(ora.$dbnm.db)pul                                  lup(ora.$dbnm.db)',STOP_DEPENDENCIES='hard(ora.$dbnm.db)',SCRIPT_TIMEOUT=300"

}



crs_res_start()
##################################################################
# for the $1 parm only the name after dbfs_ needs to be specified
# Start the dbfs resource
##################################################################
{

dbfsmnt=$1
nodename=$2

clear
echo
echo "Function name.: crs_res_start.................."
echo "Library file..: crs_common.ksh................."
echo "Directory ....: /oracle/admin/scripts/crsdbfs.."
echo
echo "Starting CRS resource for DBFS mount "$dbfsmnt
echo
echo "Start DBFS resource...."
echo

# /oracle_crs/product/12.1.0.2/crs_1/bin/crsctl start resource dbfs_$dbfsmnt -n server67mp
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl start resource dbfs_$dbfsmnt -n $nodename

# /oracle_crs/product/12.1.0.2/crs_1/bin/crsctl status resource dbfs_ggtxd001

echo
echo "Status of DBFS resource...."
echo

crs_res_stat $dbfsmnt

echo
echo "df -hs or /dbfs_ mountpoints ...."
echo

df -ha |grep dbfs_

}


crs_res_stop()
{

dbfsmnt=$1

clear
echo
echo "Function name.: crs_add_stop..................."
echo "Library file..: crs_common.ksh................."
echo "Directory ....: /oracle/admin/scripts/crsdbfs.."
echo
echo "Stopping CRS resource for DBFS................."
echo
echo "Stop DBFS resource...."
echo
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stop resource dbfs_$dbfsmnt

echo
echo "Status of DBFS resource...."
echo
crs_res_stat $dbfsmnt

echo
echo "df -hs or /dbfs_ mountpoints ...."
echo
df -ha |grep dbfs_

}


crs_res_stat()
#########################################
# Resource status
#########################################
{

gg_inst=$1

### RVK Change Jan 14th 2019 >>>
### Replaced CRS_HOME hardcode path with $CRS_HOME (Note: CRS_HOME in Dev VA is differen                                  t
### RVK End <<<

$CRS_HOME/bin/crsctl status resource dbfs_$gg_inst

}

crs_res_relo()
#########################################
# Resource relocate
#########################################
{

gg_inst=$1
to_node=$2

/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl relocate resource dbfs_$gg_inst -node $to_                                  node

}


crs_res_del()
#########################################
# Delete DBFS resource
#########################################
{

gg_inst=$1

/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl delete resource dbfs_$gg_inst

}


crs_stat()
{

########################################################################################                                  ###
# The difference on the crs_stat is the directory mismatch on the TX vs VA cluster pair
# Directory needed for TX cluster is 12.1.0.2
########################################################################################                                  ###

########################################################################################                                  ###
# This should be in the ggini file in order to drive the correct directory for all stand                                  ard
# scripts
########################################################################################                                  ###

bindir="12.1.0.2"

echo
echo "crsctl stat res -t...."
echo
/oracle_crs/product/$bindir/crs_1/bin/crsctl status resource -t

echo
echo "Show services from the resource list...."
echo
/oracle_crs/product/$bindir/crs_1/bin/crsctl status resource -t|grep -a1 .svc

echo
echo "If nothing shows here, there are no dbfs mounts ......"
echo
df -ha|grep dbfs

}


crs_stat_xag()
{

gg_inst=$1
dbnm=$2

echo
echo "If XAG resource is not yet setup then this will not work....."
echo
echo "XAG Instance name is $gg_inst / crsctl stat res xag.$gg_inst.goldengate -p all par                                  ameters ...."
echo

# /oracle_crs/product/$bindir/crs_1/bin/crsctl stat res xag.ggtxd001.goldengate -p
/oracle_crs/product/$bindir/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p

echo
echo "Cluster resource cluster resource  (dbfs) action script values...."
echo

/oracle_crs/product/$bindir/crs_1/bin/crsctl stat res -w "TYPE = cluster_resource" -p |                                   grep ACTION_SCRIPT

echo
echo "Cluster resource (dbfs) ..."
echo
# /oracle_crs/product/$bindir/crs_1/bin/crsctl stat res ora.dbfsxd01.dbfs_ggtxd001.svc -                                  p
/oracle_crs/product/$bindir/crs_1/bin/crsctl stat res ora.$dbnm.dbfs_$gg_inst.svc -p

}


crs_stat_xag_det()
{

########################################################################################                                  
# Were setting bindir because there is a difference between location of the binaries
# on TX cluster vs VA cluster
########################################################################################                                  

bindir="12.1.0.2"

gg_inst=$1

echo
echo "XAG Instance name is $gg_inst / crsctl stat res xag.$gg_inst.goldengate -p specifi                                  c parameters ...."
echo

/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   DATAGUARD_AUTOSTART
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   DB_SERVICES
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   START_DEP
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   STOP_DEP
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   HOSTING
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   FILESYST
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   GG_HOME
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   PLACEMENT
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   USE_LOCAL_SERVICES
/oracle_crs/product/12.1.0.2/crs_1/bin/crsctl stat res xag.$gg_inst.goldengate -p |grep                                   RELOCATE

}


srvctl_add_svc()
#######################################################
# This is critical for the overall operation
#######################################################
{

gg_inst=$1
dbnm=$2
pfd=$3
avl=$4

echo
echo "Create a service for GoldenGate in the format of svc_$gg_inst.....................                                  ..."
echo "This service is then used for setup through XAG for keying when GoldenGate fails o                                  ver"
echo "SRVCTL add service for svc_$gg_inst when role is primary..........................                                  ..."
echo "This adds a GoldenGate resource thru SRVCTL ......................................                                  ..."
echo "-preferred takes an instance name as parameter as does -available.................                                  ..."
echo
echo "Showing before services database "$dbnm
echo
srvctl config service -db $dbnm|grep "Service "

echo
echo "Attempting to add service svc_"$gg_inst
echo

# Example on next line
# srvctl add service -db $dbnm -service svc_$gg_inst -role PRIMARY -preferred DBFSXD011                                   -available DBFSXD012
srvctl add service -db $dbnm -service svc_$gg_inst -role PRIMARY -preferred $pfd -availa                                  ble $avl

echo
echo "Showing after services database "$dbnm
echo
srvctl config service -db $dbnm|grep "Service "

}


srvctl_svc_mod()
{

dbnm=$1
svcnm=$2
pfd=$3
avl=$4

echo
echo "This modifies the GG service created for XAG triggering "
echo "the service name automatically has svc_ prepended to avoid misconfig for different                                   service"
echo

srvctl modify service -db $dbnm -service svc_$svcnm -modifyconfig -preferred $pfd -avail                                  able $avl -force

}


srvctl_sho_svc()
{

dbnm=$1

clear
echo
echo "Showing services database "$dbnm
echo
srvctl config service -db $dbnm|grep "Service "

}


crs_cr_mount_scrpt()
{

vsn="1.00"
gginst=ggmrct001
flnm="mount_dbfs_mculp_test.bsh"


echo
echo "Create a mount script...."
echo " Version "$vsn
echo

# cat here for create of file
echo "....creating $flnm file......."

cat << EOS > $flnm

### This script is from Note 1054431.1, ensure you have the latest version
### Note 1054431.1 provides information about the setup required to use this script
### MCulp modified 08/01/2018
### The start section has been modified to work with BOA environment

###############################################
# mount-dbfs.bsh start / stop / check / status
###############################################

###############################################################
### All configuration parameters are now in an external file
###############################################################

###########################################
### Ensure that when multiple mounts are used, there are separate copies
###   of mount-dbfs.sh that reference separate CONFIG file pathnames
# CONFIG=/etc/oracle/mount-dbfs.conf

# MCulp change location #1
# This should have a conf file unique for each mount
# The location is /oracle/admin/scripts for both the script
# and the config file
##############################################################

# CONFIG=/oracle/admin/scripts/crsdbfs/mount-dbfs_ggtxp002.conf
CONFIG=/oracle/admin/scripts/crsdbfs/mount-dbfs_ggtxp003.conf


###########################################
### No editing is required below this point
###########################################
### date-based versioning YYYYMMDD
VERSION=20160215

### source configuration file
if [ -r $CONFIG ]; then
   . $CONFIG
else
   echo "$0 ERROR: cannot read config file $CONFIG, aborting"
   exit 1
fi

### the DBNAME should be set to the CDB name (from config file)
CDB=$DBNAME

### determine platform
UNAME_S=`uname -s`
if   [ $UNAME_S = 'Linux' ]; then LINUX=1; SOLARIS=0;
elif [ $UNAME_S = 'SunOS' ]; then LINUX=0; SOLARIS=1;
fi

GREP=/bin/grep
AWK=/bin/awk
SED=/bin/sed
ECHO=/bin/echo
LOGGER="/bin/logger -t DBFS_${MOUNT_POINT}"
RMF='/bin/rm -f'
TOUCH=/bin/touch
CHMOD=/bin/chmod
PS=/bin/ps
SLEEP=/bin/sleep
KILL=/bin/kill
BASENAME=/bin/basename
STAT=/usr/bin/stat
ID=/usr/bin/id
WC=/usr/bin/wc
SRVCTL=$ORACLE_HOME/bin/srvctl
DBFS_CLIENT=$ORACLE_HOME/bin/dbfs_client
HN=/bin/hostname
PERL=/usr/bin/perl
MOUNT=/bin/mount
### ensure messages are displayed in English for pattern matching
LANG=en_US.UTF-8
NLS_LANG=American_America.AL32UTF8
NUMACTL=/usr/bin/numactl
RPMCTL=/bin/rpm


if [ -z "$STATUS_TIMEOUT" ]; then STATUS_TIMEOUT=0; fi

if [ $LINUX -eq 1 ]; then
  MOUNT=/bin/mount
  XARGS='/usr/bin/xargs -r'
  FUSERMOUNT=/bin/fusermount
  LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64
elif [ $SOLARIS -eq 1 ]; then
  MOUNT=/sbin/mount
  XARGS=/usr/bin/xargs
  UMOUNT=/usr/sbin/umount
  LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:/usr/lib:/lib
fi

DBFS_PWDFILE=$DBFS_PWDFILE_BASE.$$

export ORACLE_HOME LD_LIBRARY_PATH TNS_ADMIN
export STAT MOUNT_POINT PERL_ALARM_TIMEOUT SOLARIS LINUX
export PATH=$ORACLE_HOME/bin:$PATH
export STATUS_TIMEOUT
export LANG NLS_LANG

logit () {
  ### type: info, error, debug
  type=$1
  msg=$2
  if [ "$type" = "info" ]; then
    $ECHO $msg
    $LOGGER -p ${LOGGER_FACILITY}.info "$msg"
  elif [ "$type" = "error" ]; then
    $ECHO $msg
    $LOGGER -p ${LOGGER_FACILITY}.error "$msg"
  elif [ "$type" = "debug" ]; then
    $ECHO $msg
    $LOGGER -p ${LOGGER_FACILITY}.debug "$msg"
  fi
}

### must not be root
if [ `$ID -u` -eq 0 ]; then
  logit error "Run this as the Oracle software owner, not root"
  exit 1
fi

### determine how we were called, derive location
SCRIPTPATH=$0
SCRIPTNAME=`$BASENAME $SCRIPTPATH`

$ECHO $SCRIPTPATH | $GREP ^/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
  MYDIR=`pwd`
  SCRIPTPATH=${MYDIR}/${SCRIPTPATH}
fi

### must cd to a directory where the oracle owner can get CWD
cd /tmp

case "$1" in

##########################################
# Start begins here
##########################################
'start')
  echo "Start...."
  echo
  logit info "$SCRIPTNAME mounting DBFS at $MOUNT_POINT from database $DBNAME"

  ### check to see if it is already mounted
  $SCRIPTPATH status > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    logit error "$MOUNT_POINT already mounted, use $SCRIPTNAME stop before attempting to                                   start"
    $SCRIPTPATH status
    exit 1
  fi

  ### set the ORACLE_SID dynamically based on OCR info, if it is running
  # if RAC, set SID with following command
  export ORACLE_SID=$($SRVCTL status instance -d $DBNAME -n `$HN` | \
         $GREP 'is running' | $AWK '{print $2}' )

  # if single instance, set ORACLE_SID based on below command instead
  if [ -z "$ORACLE_SID" ]; then
    export ORACLE_SID=$($SRVCTL config db -d $DBNAME | $GREP 'instance' | $AWK '{print $                                  3}')
  fi

  logit info "ORACLE_SID is $ORACLE_SID"

  ### further checks required if we are using a PDB
  ### if the local instance isn't running (because ORACLE_SID is null) don't bother
  if [ -n "$ORACLE_SID" -a "$IS_PDB" = 'true' ]; then
    logit info "IS_PDB = true"
    HOSTNAME=`$HN -s`
    ### by checking to see if the service is running on the local instance,
    ###   we can deterine whether we should continue or not
    PDB_SERVICE_STATE=$($SRVCTL status service -d $CDB -s $PDB_SERVICE | \
        $GREP "$ORACLE_SID" )
    ### if the output from the last command is > 0, service is running locally
    if [ -n "$PDB_SERVICE_STATE" ]; then
      logit info "PDB service is online"
    else
      logit error "PDB service is offline.  Exiting"
      exit 2
    fi
  fi

  ### if there's no SID defined locally or it isn't running, stop
  if [ -z "$ORACLE_SID" -a "$WALLET" = 'false' ]; then
    logit error "No running ORACLE_SID available on this host, exiting"
    exit 2
  fi

  ### version comparison function, used in numa section
  # Compare string versions
  # Returns in stdout and in the err code
  # 0        - a equal b
  # 1        - a greater than b
  # 255(-1)  - a less than b
  # version should be in format 1.2.3.4.5
  # It might be a short version like 1.2.3 or 1.2.3.

  version_cmp ()
  {
    local -a al=(`$ECHO $1 | $SED -e 's/\./ /g'`)
    local -a bl=(`$ECHO $2 | $SED -e 's/\./ /g'`)

    local -i i=0
    for ((i=0; i < ${#al[@]}; i++)); do
      # ap is always non-empty. Gap is not possible in both arrays
      local ap=${al[$i]}
      local bp=${bl[$i]}
      # Only $ap defined. $a longer (bigger) then $b
      if [ -z "$bp" ] || [ $ap -gt $bp ]; then
        $ECHO "1"
        return 1
      elif [ $ap -lt $bp ]; then
        $ECHO "-1"
        return -1
      fi
    done
    # Check for the next part from @bl. It means $a shorter (smaller) then $b
    if [ -n "${bl[$i]}" ]; then
      $ECHO "-1"
      return -1
    fi
    # Both arrays ended at the same time. They are equal
    $ECHO "0"
    return 0
  }

# MCulp commenting out the whole section as we do not need this currently
########################################################################################                                  ###
#  ### if numa system on Linux, update mount_options for bug 10004611
#  if [ $LINUX -eq 1 ]; then
#    RPMEXA=`$RPMCTL -q --queryformat '%{VERSION}' exadata-base`
#    NUMASYS=`$NUMACTL --hardware | $GREP available: | cut -c1-18`
#
#    ###Check if an X8 system and image greater than or equal to 11.2.3.3.0 to support n                                  uma mount option
#    if [ "$NUMASYS" = 'available: 8 nodes' ]; then
#      if [ `version_cmp $RPMEXA 11.2.3.3.0` -eq 0 ] || [ `version_cmp $RPMEXA 11.2.3.3.                                  0` -eq 1 ]; then
#        # MOUNT_OPTIONS=$MOUNT_OPTIONS,numa
#        MOUNT_OPTIONS=$MOUNT_OPTIONS
#      else
#        MOUNT_OPTIONS=$MOUNT_OPTIONS
#      fi
#
#    ###Check if an X5-2 system to support numa mount option
#    elif [ "$NUMASYS" = 'available: 2 nodes' ]; then
#      # MOUNT_OPTIONS=$MOUNT_OPTIONS,numa
#      MOUNT_OPTIONS=$MOUNT_OPTIONS
#    ###Check for all other X2 systems, do not use numa option
#    elif [ "$NUMASYS" = 'available: 1 nodes' ]; then
#      MOUNT_OPTIONS=$MOUNT_OPTIONS
#    ###Exit for errors or unexpected values, post in messages file
#    else
#      logit error "Unexpected numa value.  Exiting."
#      logit error "Numa hardware value is: $NUMASYS"
#      logit error "RPM version of Exadata base is: $RPMEXA"
#      exit 1
#    fi
#  else
#    logit info "skipped numa check for Solaris...not applicable"
#  fi
########################################################################################                                  ###

  ### if using password-based startup, use this
  if [ "$WALLET" = 'false' -a -n "$DBFS_PASSWD" ]; then
    $RMF $DBFS_PWDFILE
    if [ -f $DBFS_PWDFILE ]; then
      logit error "please remove $DBFS_PWDFILE and try again"
      exit 1
    fi

    $TOUCH $DBFS_PWDFILE
    $CHMOD 600 $DBFS_PWDFILE
    $ECHO $DBFS_PASSWD > $DBFS_PWDFILE

    logit info "spawning dbfs_client command using SID $ORACLE_SID"
    ### if PDB, mount with this command
    if [ "$IS_PDB" = 'true' ]; then
      (nohup $DBFS_CLIENT ${DBFS_USER}@${PDB} -o $MOUNT_OPTIONS \
          $MOUNT_POINT < $DBFS_PWDFILE | $LOGGER -p ${LOGGER_FACILITY}.info 2>&1 & ) &
    ### if not PDB, mount with this command instead
    else
      echo "Correct command...."

      ### MCulp changed

#     nohup $ORACLE_HOME/bin/dbfs_client ggtxp003/not4good@dbfs_ggtxp003 -o rw,direct_io                                   /dbfs_ggtxp003 < /oracle/admin/scripts/clle_dbfscommon/.gg_password &>/oracle/admin/scr                                  ipts/crsdbfs/nohup.out

#     nohup $ORACLE_HOME/bin/dbfs_client ggtxp003/not4good@dbfs_ggtxp003 -o rw,direct_io                                   /dbfs_ggtxp003 < /oracle/admin/scripts/clle_dbfscommon/.gg_password &
      nohup $ORACLE_HOME/bin/dbfs_client ggtxp002/not4good@dbfs_ggtxp003 -o $MOUNT_OPTIO                                  NS /dbfs_ggtxp003 < /oracle/admin/scripts/clle_dbfscommon/.gg_password &

#     MOUNT_OPTIONS=rw,direct_io

# This is the original mount command unmodified
# MAKE SURE TO MODIFY THE entry after the @ symbol

# The next line is the original line
#        (nohup $DBFS_CLIENT ${DBFS_USER}@ -o $MOUNT_OPTIONS \
#          $MOUNT_POINT < $DBFS_PWDFILE | $LOGGER -p ${LOGGER_FACILITY}.info 2>&1 & ) &


# MOUNT_TNS as added to the conf file that is read in
########################################################################################
echo
echo $DBFS_USER
echo
echo $MOUNT_TNS
echo
echo $MOUNT_OPTIONS
echo
echo


#       (nohup $DBFS_CLIENT ${DBFS_USER}@$MOUNT_TNS -o $MOUNT_OPTIONS \
#          $MOUNT_POINT < $DBFS_PWDFILE | $LOGGER -p ${LOGGER_FACILITY}.info 2>&1 & ) &

    fi
  ### if wallet is true, mount with this command
  elif [ "$WALLET" = true ]; then
    logit info "doing mount $MOUNT_POINT using SID $ORACLE_SID with wallet now"
    (nohup $DBFS_CLIENT /@${DBFS_LOCAL_TNSALIAS} -o $MOUNT_OPTIONS,wallet \
          $MOUNT_POINT | $LOGGER -p ${LOGGER_FACILITY}.info 2>&1 & ) &
  fi

  ### allow time for the mount table update before checking it
  $SLEEP 1
  $RMF $DBFS_PWDFILE
  ### set return code based on success of mounting
  $SCRIPTPATH status > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    logit info "Start -- ONLINE"
    exit 0
  else
    logit info "Start -- OFFLINE"
    exit 1
  fi

  ;;


############################################################
# MCulp Changed
# Added z to the fusermount options as the u by itself
# was not working correctly
############################################################

'stop')
  $SCRIPTPATH status > /dev/null
  if [ $? -eq 0 ]; then
     logit info "unmounting DBFS from $MOUNT_POINT"
     if [ $LINUX -eq 1 ]; then
        logit info "umounting the filesystem using '$FUSERMOUNT -uz $MOUNT_POINT'"
#       $FUSERMOUNT -u $MOUNT_POINT
        $FUSERMOUNT -uz $MOUNT_POINT

     elif [ $SOLARIS -eq 1 ]; then
        logit info "umounting the filesystem using '$UMOUNT $MOUNT_POINT'"
        $UMOUNT $MOUNT_POINT > /dev/null 2>&1
     fi
     $SCRIPTPATH status > /dev/null
     if [ $? -eq 0 ]; then
        logit error "Stop - stopped, but still mounted, error"
        exit 1
     else
        logit info "Stop - stopped, now not mounted"
        exit 0
     fi
  else
    logit error "filesystem $MOUNT_POINT not currently mounted, no need to stop"
  fi
  ;;


'check'|'status')
### check to see if it is mounted
### fire off a short process in perl to do the check (need the alarm builtin)
logit debug "Checking status now"
$PERL <<'TOT'
   $timeout = $ENV{'PERL_ALARM_TIMEOUT'};
   $SIG{ALRM} = sub {
      ### we have a problem and need to cleanup
      exit 3;
      die "timeout" ;
   };
   alarm $timeout;
   eval {
      $STATUSOUT=`$ENV{'STAT'} -f -c "%T" $ENV{'MOUNT_POINT'} 2>&1 `;
      chomp($STATUSOUT);
      ### added fuseblk check for Linux 6 output
      if ( ( $ENV{'SOLARIS'} == 1 && $STATUSOUT eq 'uvfs' ) ||
           ( $ENV{'LINUX'} == 1   && $STATUSOUT eq 'UNKNOWN (0x65735546)' ) ||
           ( $ENV{'LINUX'} == 1   && $STATUSOUT eq 'fuseblk' ) ) {
         ### status is okay
         exit 0;
      } elsif ( $STATUSOUT =~ /Transport endpoint is not connected/ ) {
        ### we have a problem, need to clean up
        exit 2;
      } else {
        ### filesystem is offline
        exit 1;
      }
    };
TOT

RC=$?
### process return codes from the perl block
if [ $RC -eq 3 ]; then
   STATUS_TIMEOUT=$(( $STATUS_TIMEOUT + 1 ))
   logit error "Found timeout while checking status, cleaning mount automatically"
   $SCRIPTPATH clean
   logit debug "Check -- OFFLINE"
   exit 1
elif [ $RC -eq 2 ]; then
   STATUS_TIMEOUT=$(( $STATUS_TIMEOUT + 1 ))
   logit error "Found error while checking status, cleaning mount automatically"
   $SCRIPTPATH clean
   logit debug "Check -- OFFLINE"
   exit 1
elif [ $RC -eq 1 ]; then
    logit debug "Check -- OFFLINE"
    exit 1
elif [ $RC -eq 0 ]; then
    logit debug "Check -- ONLINE"
    exit 0
fi
;;

'restart')
  logit info "restarting DBFS"
  $SCRIPTPATH stop
  $SLEEP 2
  $SCRIPTPATH start
  ;;

##########################################################################
# clean abort
# MCulp 08/01/2018
# Added z to the fusermount option below
##########################################################################

'clean'|'abort')
   logit info "cleaning up DBFS nicely using (fusermount -u|umount)"

   if [ $LINUX -eq 1 ]; then
      $FUSERMOUNT -u $MOUNT_POINT
   elif [ $SOLARIS -eq 1 ]; then
      $UMOUNT $MOUNT_POINT > /dev/null 2>&1
   fi

   $SLEEP 1
   FORCE_CLEANUP=0

   if [ $STATUS_TIMEOUT -gt 1 ]; then
      FORCE_CLEANUP=1
   else
      $SCRIPTPATH status > /dev/null
      if [ $? -eq 0 ]; then FORCE_CLEANUP=1; fi
   fi


   if [ $FORCE_CLEANUP -eq 1 ]; then
      logit error "tried (fusermount -u|umount), still mounted, now cleaning with (fuser                                  mount -uz -z|umount -f) and kill"

      if [ $LINUX -eq 1 ]; then
         $FUSERMOUNT -u -z $MOUNT_POINT
      elif [ $SOLARIS -eq 1 ]; then
         $ECHO "running umount -f now"
         $UMOUNT -f $MOUNT_POINT > /dev/null 2>&1
      fi

      if [ $LINUX -eq 1 ]; then
         PIDS=`$PS -ef | $GREP -w "$MOUNT_POINT" | $GREP dbfs_client| $GREP -v grep | \
         $AWK '{print $2}'`
         if [ -n "$PIDS" ]; then $KILL -9 $PIDS; fi
         PIDS=`$PS -ef | $GREP -w "$MOUNT_POINT" | $GREP mount.dbfs | $GREP -v grep | \
         $AWK '{print $2}'`
         if [ -n "$PIDS" ]; then $KILL -9 $PIDS; fi
      elif [ $SOLARIS -eq 1 ]; then
         PIDS=`$PS -ef | $GREP dbfs_client| $GREP -v grep | $AWK '{print $2}'`
         REALPIDS=' '
         for pid in $PIDS
         do
            ARGS=`pargs $pid`
            $ECHO $ARGS | $GREP  "$MOUNT_POINT$"  > /dev/null
            RET=$?

            if [ $RET -eq 0 ]; then REALPIDS="$REALPIDS $pid"; fi
         done
        if [ -n "$REALPIDS" ]; then $KILL -9 $REALPIDS; fi
        ### do it a 2nd time to clean up others
        if [ -n "$REALPIDS" ]; then $KILL -9 $REALPIDS; fi
        PIDS=`$PS -ef | $GREP dbfs_client| $GREP -v grep | $AWK '{print $2}'`
        REALPIDS=' '
        for pid in $PIDS
        do
           ARGS=`pargs $pid`
           $ECHO $ARGS | $GREP  "$MOUNT_POINT$"  > /dev/null
           RET=$?
           if [ $RET -eq 0 ]; then REALPIDS="$REALPIDS $pid"; fi
        done
        if [ -n "$REALPIDS" ]; then $KILL -9 $REALPIDS; fi

      fi
      exit 1
   fi
  ;;

'version')
  ### simply show the version
  echo "$VERSION"
  ;;

*)
  $ECHO "Usage: $SCRIPTNAME { start | stop | check | status | restart | clean | abort |                                   version }"
  ;;

esac
EOS

echo "$flnm has been created please review file and modify file....."

###### end of the file






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