Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapratt patch 1 #83

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps-unlimited/EBSR12.2onOCI/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions apps-unlimited/EBSR12.2onOCI/AppTier/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions apps-unlimited/EBSR12.2onOCI/Database/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

75 changes: 75 additions & 0 deletions apps-unlimited/EBSR12.2onOCI/Database/ChangeHomePath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#############################################################################
# ChangeHomePath.sh
# An include script holding the common routine that changes the oracle
# database home path if needed when switching a standby database to primary.
#
# This is an INCLUDE file. It is code to be included in an outer ksh
# script. It just holds the routine ReConfig, which calls the EBS code.
#
# Note: assumes all the database instances are present in gv_instance when
# the check is done in the main script.
#
# Requires user equivalency across all RAC nodes.
#
# No parameters passed in
#
# Rev:
# 8/23/24 Re-formed as a standard routine to access inside different scripts
# 1/15/24 DPresley Created
#############################################################################
#
ReConfig()
{
LogMsg "Started ReConfig - Database Home Reconfiguration"

LogMsg "DbName: $DbName"

# Calling script has the apps password. Need to get the database password
GetLogon $DB_SECRET_NAME
DB_SECRET=$LOGON

PERLBIN=`dirname $ORACLE_HOME/perl/bin/perl`
LogMsg "PERLBIN = $PERLBIN"

PATH=${PERLBIN}:${PATH}

PERL5LIB=$ORACLE_HOME/perl/lib/5.32.0:$ORACLE_HOME/perl/lib/site_perl/5.32.0:$ORACLE_HOME/appsutil/perl

# Call the EBS script txkSuncDBConfig.pl
LogMsg "Running txkSyncDBConfig.pl"
{ echo "$APPS_SECRET"; } | perl $ORACLE_HOME/appsutil/bin/txkSyncDBConfig.pl \
-dboraclehome=$ORACLE_HOME \
-outdir=$ORACLE_HOME/appsutil/log \
-cdbsid=${ORACLE_SID} \
-pdbname=${PDB_NAME} \
-dbuniquename=${DB_UNIQUE_NAME} \
-israc=YES \
-virtualhostname=${VIRTUAL_HOSTNAME} \
-logicalhostname=${LOGICAL_HOSTNAME} \
-scanhostname=${SCAN_NAME} \
-scanport=${SCAN_LISTENER_PORT} \
-dbport=${DB_LISTENER_PORT} \
-appsuser=${APPS_USERNAME} | tee -a ${LOG_OUT}


LogMsg "Running txkCfgUtlfileDir.pl with mode=setUtlFileDir"

{ echo "$APPS_SECRET"; echo "$DB_SECRET"; } | perl $ORACLE_HOME/appsutil/bin/txkCfgUtlfileDir.pl \
-contextfile=$CONTEXT_FILE \
-oraclehome=$ORACLE_HOME \
-outdir=$ORACLE_HOME/appsutil/log \
-mode=setUtlFileDir \
-servicetype=opc | tee -a ${LOG_OUT}

LogMsg "Running txkCfgUtlfileDir.pl with mode=syncUtlFileDir"

{ echo "$APPS_SECRET"; } | perl $ORACLE_HOME/appsutil/bin/txkCfgUtlfileDir.pl \
-contextfile=$CONTEXT_FILE \
-oraclehome=$ORACLE_HOME \
-outdir=$ORACLE_HOME/appsutil/log \
-mode=syncUtlFileDir \
-servicetype=opc | tee -a ${LOG_OUT}

LogMsg "Completed ReConfig - Database Home Reconfiguration"
}

69 changes: 69 additions & 0 deletions apps-unlimited/EBSR12.2onOCI/Database/EBSCFG.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# EBSCFG.env
# This environment file is called by scripts on the DB nodes that execute EBS
# TXK commands to configure EBS metadata post switchover or failover.
# The scripts assume logical host names have been implemented for EBS R12.2.
#
# Environment variables in this env file:
# - SCRIPT_DIR: The directory where these scripts reside.
# - THIS_HOSTNAME: The logical host name for THIS host, without the .domain.
# - VIRTUAL_HOSTNAME: The logicalhostname.domain alias for the VIP on THIS node.
# This would be the VIP for the Grid listener or the VIP of a
# dedicated EBS listener. Use the command
# "srvctl config vip -n $HOSTNAME" to get this setting.
# - LOGICAL_HOSTNAME: The logical hostname.domain for THIS server. The EBS
# script txkSyncDBConfig.pl will use this variable to configure EBS
# on THIS node.
# - SCAN_NAME: The SCAN name for THIS cluster. Use the command: "srvctl config
# scan" to obtain the scan name.
# - SCAN_LISTENER_PORT: The listener port number for the SCAN listeners. Use
# the command "srvctl config scan_listener" to get this value.
# - DB_LISTENER_PORT: The listener port number for the database. This can be
# the Grid listener port or the listener port of a dedicated EBS
# listener if one is configured and running.
# - DB_HOSTS: Space-delimited list of network assigned / physical hostnames
# for the EBS RAC database, enclosed in double quotes.
# Do not use logical host names for this list.
# Example: "physicalhost1 physicalhost2 physicalhostN..."
# - CDB_NAME: The name of the database CDB as set by the database parameter
# DB_NAME.
# - DB_UNIQUE_NAME: The database unique name set by the database parameter
# DB_UNIQUE_NAME.
# - PDB_NAME: The name of the PDB that the EBS database resides in.
# - CONTEXT_FILE: $ORACLE_HOME/<PDB_NAME>_<HOST_NAME>.env
# - PDB_TNS_CONNECT_STRING: The TNS connect string for the PDB
# - DB_SECRET_NAME: The name of the secret in the OCI vault holding the
# database EBS_SYSTEM password/credential.
# - APPS_SECRET_NAME: The name of the secret in the OCI vault holding the APPS
# schema password/credential.
# - APPS_USERNAME: The name of the APPS schema, typically "APPS".
# - COMPARTMENT_OCID: The OCID of the OCI compartment that contains the OCI
# vault.
# - LOG_DIR: These scripts will write their execution logs in this directory

SCRIPT_DIR=/home/oracle/ebscdb/coRoutines

THIS_HOSTNAME=ebsdb1
VIRTUAL_HOSTNAME=ebsdb1-vip.ebsdbprivateexa.ebsmaacloud2vcn.oraclevcn.com
LOGICAL_HOSTNAME=ebsdb1.ebsdbprivateexa.ebsmaacloud2vcn.oraclevcn.com
SCAN_NAME=iadexadb-bw5wn-scan.ebsexadbprivate.ebscloudmaavcn.oraclevcn.com

SCAN_LISTENER_PORT=1521
DB_LISTENER_PORT=1521

DB_HOSTS="iadexadb-bw5wn1 iadexadb-bw5wn2"
CDB_NAME=EBSCDB
DB_UNIQUE_NAME=EBSCDB_9cv_iad

PDB_NAME=VISPRD
PDB_TNS_CONNECT_STRING=visprd
CONTEXT_FILE=${ORACLE_HOME}/${PDB_NAME}_${THIS_HOSTNAME}

DB_SECRET_NAME=ebs-db-secret
APPS_SECRET_NAME=ebs-apps-secret
APPS_USERNAME=APPS

COMPARTMENT_OCID="ocid1.compartment.oc1..aaaaaaaadynzghibxxo362cdebbtkqtuixd5ql24njdk3rd4mtil6qr5mgzq"

LOG_DIR=${SCRIPT_DIR}/log
TNS_ALIAS=visprd

107 changes: 107 additions & 0 deletions apps-unlimited/EBSR12.2onOCI/Database/EBS_DB_RoleChange.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/bin/ksh
#############################################################################
# EBS_DB_RoleChange.sh
# Spawn the scripts to reconfigure EBS on the database RAC nodes if required.
#
# Note: This script blocks when running the txk configuration scripts, so
# errors are caught here instead of floating around in the ether.
#
# Note: If the homes need to change: we're assuming all database instances
# are visible in gv$instance when this is executed. If an instance
# is down, that home will not be reconfigured.
#
# Requires user equivalency across all RAC nodes.
#
# Things to ignore or be aware of:
# stty: standard input: Inappropriate ioctl for device
# The random creation of +DATAC1 in your script directory (bug#: ...)
# Creation of logs in your script directory named mmddhhmm.log
#
# No parameters passed in
#
# Rev:
# 8/28/24 MPratt Simplified, added ksh coroutine for efficiency
# 1/15/24 DPresley Created
#############################################################################
#
. /home/oracle/EBSCDB.env
. ./EBSCFG.env
HostName=$(hostname)
MYHOST=$(hostname)

. ${CONTEXT_FILE}.env

# Call the standard functions routine
. $SCRIPT_DIR/stdfuncs.sh

# Include the common code for reconfiguring the path. This will be
# executed both from this script and from the spawned shell scripts on other DB
. $SCRIPT_DIR/ChangeHomePath.sh

EnvSetup
LOG_OUT=${LOG_DIR}/${HostName}_EBS_DB_RoleChange_${TS}.log

LogMsg "EBS_DB_RoleChange.sh: Started"

GetLogon $APPS_SECRET_NAME
APPS_SECRET=$LOGON

# Start sqlplus in coroutine, logged in as apps user
LaunchCoroutine APPS $APPS_SECRET $PDB_TNS_CONNECT_STRING

GetDbName

sql="select XMLTYPE(t.text).EXTRACT('//ORACLE_HOME/text()').getStringVal() \
from apps.fnd_oam_context_files t \
where name = '` echo ${PDB_NAME}`_`echo ${THIS_HOSTNAME}`' \
and node_name = '`echo ${THIS_HOSTNAME}`' \
order by last_update_date desc \
fetch first row only;"
EBS_DB_OH=`ExecSql "${sql}"`

LogMsg "ORACLE_HOME: $ORACLE_HOME"
LogMsg "EBS_DB_OH: $EBS_DB_OH"

# Only spawn the jobs if the oracle home path is different
if [ "${ORACLE_HOME}" != "${EBS_DB_OH}" ]
# TESTING: DO IT IF IT'S THE SAME
# if [ "${ORACLE_HOME}" = "${EBS_DB_OH}" ]
then
LogMsg "Oracle home paths are different. Reconfigure hosts"

# Insert a row for each RAC node, then select those rows to drive the fix scripts.
# Need the rows in the table so the middle tiers can see configuration is not
# done yet across all instances.

# Are we assuming all instances are up when this executes? Why, yes, we are...

sql="INSERT INTO apps.xxx_EBS_role_change (host_name,rolechange_date) \
SELECT host_name, sysdate \
FROM gv\$instance;
commit;"
ExecSql "${sql}"

LogMsg "DB_HOSTS: $DB_HOSTS"
LogMsg "MYHOST: $MYHOST"

# DB_HOSTS is a configuration in your .env file
for i in ${DB_HOSTS}
do
if [ "${i}" == "${MYHOST}" ];
then
LogMsg "Configuring database homes for EBS on local host ${i}"
ReConfig
else
LogMsg "Configuring database homes for EBS on remote host: ${i}"
LogMsg "ssh -t oracle@${i} cd ${SCRIPT_DIR}; ${SCRIPT_DIR}/callReConfig.sh"
ssh -t oracle@${i} "cd ${SCRIPT_DIR}; ${SCRIPT_DIR}/callReConfig.sh"
fi

sql="DELETE FROM apps.xxx_EBS_role_change where host_name='${i}';
commit;"
ExecSql "${sql}"
done
fi

LogMsg "Completed: EBS_DB_RoleChange.sh."

58 changes: 58 additions & 0 deletions apps-unlimited/EBSR12.2onOCI/Database/callReConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/ksh
#############################################################################
# callReConfig.sh
# Call the scripts to reconfigure EBS on the database RAC nodes on remote
# hosts.
#
# Requires user equivalency across all RAC nodes.
#
# This script establishes the environment, gets the apps password.
# then executes ReConfig on remote hosts. It's called remotely by
# EBS_DB_RoleChange.sh
#
# Rev:
# 8/29/24 MPratt Created
#############################################################################
#

# echo "callReConfig.sh: You got in"
# echo "HOSTNAME: $HOSTNAME"
mypath=`pwd`
echo "mypath: $mypath"

. /home/oracle/EBSCDB.env
. ${mypath}/EBSCFG.env
HostName=$(hostname)

. ${CONTEXT_FILE}.env

# Include the standard functions routines
. $SCRIPT_DIR/stdfuncs.sh

# Include the common code for reconfiguring the path. This holds the
# code that is executed in this script for the DB nodes remote to the main
# driving script.
. $SCRIPT_DIR/ChangeHomePath.sh

EnvSetup
LOG_OUT=${LOG_DIR}/${HostName}_callReConfig_${TS}.log

LogMsg "callReConfig.sh: Started"

# Get the apps password - needs to be set before executing ReConfig
GetLogon $APPS_SECRET_NAME
APPS_SECRET=$LOGON

# Don't need to do this - not executing sqlplus for anything here
# Start sqlplus in coroutine, logged in as apps user
# LaunchCoroutine APPS $APPS_SECRET $PDB_TNS_CONNECT_STRING

# for this script, ok to substitute HostName for DbName, which is used
# in LogMsg (else would need to launch the coroutine)
# GetDbName
DbName=$HostName

ReConfig

LogMsg "callReConfig.sh: Completed."

Loading