Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

1. Introduction  

It is possible to schedule your own pre- or post processing script as part of the Dbvisit Standby execution. A good example of doing this is if you want to execute your own custom code to perform certain tasks before or after Dbvisit Standby sends or apply logs; or it can be used to execute a script after you have opened the standby database read-only to start reporting extracts or any other custom code you would want to execute.
This is the new recommended way where one script is used for both pre- and post-processing. This script when executed by Dbvisit Standby, will be called with two parameters indicating if it should execute pre or post tasks and what the Dbvisit Standby process is that is being called.


In Dbvisit Standby version 8 a Dbvisit Standby Configuration (DDC) parameter is available called: DBV_PRE_POST_PROC


This parameter is set in the Primary database DDC file and should point to the script you want to execute before or after Dbvisit Standby processing.


Example Linux:

DBV_PRE_POST_PROC=/usr/local/bin/dbv_pre_post_processing.sh


Example Windows:

DBV_PRE_POST_PROC=c:\bin\dbv_pre_post_processing.cmd



Dbvisit Standby does come with a sample script to get you started.
This script is located in: DBVISIT_BASE/standby/doc

  • Linux sample script: example_pre_post_processing.sh
  • Windows sample script: example_pre_post_processing.cmd

The samples can be found at the end of this section.


These sample scripts will take two parameters which is passed by Dbvisit Standby to it:

  • Parameter 1 can be one of two possible values: [pre|post]
  • Parameter 2 can be one number from 1 to 6: [1|2|3|4|5|6]


Usage examples:

Usage: ./pre-post-dbvisit.sh [pre|post] [1|2|3|4|5|6]



Example call on Linux to perform pre- or post-process tasks when sending logs (see number explanation below)

# ./pre-post-dbvisit.sh pre 1
# ./pre-post-dbvisit.sh post 5




Example call on Windows to perform pre- or post-process tasks when sending logs (see number explanation below)

# ./pre-post-dbvisit.cmd pre 1
# ./pre-post-dbvisit.cmd post 1


Pre- and Post-processing script input parameters:
When the script is executed the first parameter that will be passed to it will be "pre" or "post" indicating if the script is executed before (pre) or after (post) Dbvisit Processing:


pre = Pre Dbvisit Processing step
post = Post Dbvisit Processing step


The second parameter that is passed is in number format. The possible values are 1 through to the number 6.

The number indicates which step Dbvisit Standby is performing:


1 = Dbvisit is executed on primary and will be sending logs to standby
2 = Dbvisit is executed on standby and will be applying logs
3 = Dbvisit Graceful Switchover is executed on primary
4 = Dbvisit Graceful Switchover is executed on standby
5 = Dbvisit Activation is executed on standby
6 = Standby Database is opened read-only



2.  Linux - Sample Script


This section will provide you with an example script that can be located in DBVISIT_BASE/standby/doc folder.

Important - these are not complete scripts as they do not execute any specific tasks, you will need to modify them to your requirements.

#!/bin/bash
#
# Description:
# ===========
# This script is provided by Dbvisit Software Limited as an example
# pre/post processing script. This script can be used to perform 
# custom tasks (pre) before Dbvisit Standby execute, or (post) following
# a successful execution.
#
# NOTE: This script is a basic template and you will need to add custom code
# to this script to perform the required tasks you want to perform as 
# part of pre or post dbvisit processing. 
#
# This script should be added to the Dbvisit Database Configuration (DDC) file
# Example: PRE_POST_PROCESSING=/usr/local/bin/pre-post-dbvisit.sh
#
# Dbvisit STandby will pass two parameters to this script
# Parameter 1 can be one of two possible values: [pre|post]
# Parameter 2 can be one number from 1 to 6: [1|2|3|4|5|6]
# 
# Usage: ./pre-post-dbvisit.sh [pre|post] [1|2|3|4|5|6]
#
# Example: ./pre-post-dbvisit.sh pre 1
#
# Parameter explanation:
# =====================
# pre = Pre Dbvisit Processing step
# post = Post Dbvisit Processing step
# 1 = Dbvisit is executed on primary and will be sending logs to standby
# 2 = Dbvisit is executed on standby and will be applying logs
# 3 = Dbvisit Graceful Switchover is executed on primary 
# 4 = Dbvisit Graceful Switchover is executed on standby
# 5 = Dbvisit Activation is executed on standby
# 6 = Standby Database is opened read-only 
#
# 
# Note: This script is an example only and should be tested first before 
# it is used in a production environment.
#
# To enable debugging, uncomment following line:
# set -x
#
###########################################
# Function to echo usage
###########################################
usage ()
{
program=`basename $0`
cat <<EOF
Usage:
${program} [pre|post] [1|2|3|4|5|6]
[pre|post} - Specify if Pre or Post processing is being performed
[1|2|3|4|5|6] - Indicate Dbvisit operation being performed
-h - display the usage

pre = Pre Dbvisit Processing step
post = Post Dbvisit Processing step
1 = Dbvisit is executed on primary and will be sending logs to standby
2 = Dbvisit is executed on standby and will be applying logs
3 = Dbvisit Graceful Switchover is executed on primary 
4 = Dbvisit Graceful Switchover is executed on standby
5 = Dbvisit Activation is executed on standby
6 = Standby Database is opened read-only 
Example, to perform a task on the standby server following activation:
${program} post 5
EOF
exit 1
}
###########################################
# Function to setup parameter variables
# Description:
# Specify any global settings in this section
###########################################
setup_parameters ()
{
## Below are some example values
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
SERVER=`uname -n`
dbvisit_base=/usr/dbvisit
logfile=${dbvisit_base}/standby/log/pre-post-dbvisit.log
}
###########################################
# Function to change database environments
# Description:
# Use oraenv to set the environment if needed
###########################################
set_env ()
{
export ORAENV_ASK=NO
export ORACLE_SID=$1
. oraenv >> /dev/null
export ORAENV_ASK=YES
}
###########################################
# Function to Add text to logfile
###########################################
addLog()
{
# comment 1st line below to remove echo back to user and to only write to log
echo "`date +%d-%h-%Y:%H:%M:%S` : ${1}" 
echo "`date +%d-%h-%Y:%H:%M:%S` : ${1}" >> ${logfile}
}
### Add your custom functions here
###
##########################
##########################
####
#### MAIN PROGRAM SECTION
####
##########################
##########################
## First call function to set the environment or specific global variables
setup_parameters
## Test input values, must be 2 values, if not exit
if test $# -ne 2
then
echo "Cannot execute, 2 values must be specified as input..."
usage
exit 99
fi
if [ ${1} = "pre" ] || [ ${1} = "post" ] 
then
if ! [[ $2 =~ '^[1-6]+$' ]]
then 
echo "2nd Parameter must be a number between 1 and 6"
usage
exit 97
fi
else
echo "1st Parameter must be \"pre\" or \"post\"";
usage
exit 98
fi
### Now that values are valid, execute required code block
case ${1} in
pre) 
addLog "Start Pre Processing"
case ${2} in
1) 
addLog "Primary Database Send"
## add custom code here or call custom function
;;
2)
addLog "Standby Database Apply"
## add custom code here or call custom function
;;
3)
addLog "Primary Server Graceful Switchover"
## add custom code here or call custom function
;;
4)
addLog "Standby Server Graceful Switchover"
## add custom code here or call custom function
;;
5)
addLog "Standby Database Activate"
## add custom code here or call custom function
;;
6)
addLog "Standby Database Read-Only"
## add custom code here or call custom function
;;
esac 
;;
post)
addLog "Start post Processing"
case ${2} in
1)
addLog "Primary Database Send"
## add custom code here or call custom function
;;
2)
addLog "Standby Database Apply"
## add custom code here or call custom function
;;
3)
addLog "Primary Server Graceful Switchover"
## add custom code here or call custom function
;;
4)
addLog "Standby Server Graceful Switchover"
## add custom code here or call custom function
;;
5)
addLog "Standby Database Activate"
## add custom code here or call custom function
;;
6)
addLog "Standby Database Read-Only"
## add custom code here or call custom function
;;
esac
;;
esac


3.  Windows - Sample Script


This section will provide you with an example script that can be located in DBVISIT_BASE\standby\doc folder.

Important - these are not complete scripts as they do not execute any specific tasks, you will need to modify them to your requirements.

#!/bin/bash
#
# Description:
# ===========
# This script is provided by Dbvisit Software Limited as an example
# pre/post processing script. This script can be used to perform 
# custom tasks (pre) before Dbvisit Standby execute, or (post) following
# a successful execution.
#
# NOTE: This script is a basic template and you will need to add custom code
# to this script to perform the required tasks you want to perform as 
# part of pre or post dbvisit processing. 
#
# This script should be added to the Dbvisit Database Configuration (DDC) file
# Example: PRE_POST_PROCESSING=/usr/local/bin/pre-post-dbvisit.sh
#
# Dbvisit STandby will pass two parameters to this script
# Parameter 1 can be one of two possible values: [pre|post]
# Parameter 2 can be one number from 1 to 6: [1|2|3|4|5|6]
# 
# Usage: ./pre-post-dbvisit.sh [pre|post] [1|2|3|4|5|6]
#
# Example: ./pre-post-dbvisit.sh pre 1
#
# Parameter explanation:
# =====================
# pre = Pre Dbvisit Processing step
# post = Post Dbvisit Processing step
# 1 = Dbvisit is executed on primary and will be sending logs to standby
# 2 = Dbvisit is executed on standby and will be applying logs
# 3 = Dbvisit Graceful Switchover is executed on primary 
# 4 = Dbvisit Graceful Switchover is executed on standby
# 5 = Dbvisit Activiation is excecuted on standby
# 6 = Standby Database is opened read-only 
#
# 
# Note: This script is an example only and should be tested first before 
# it is used in a production environment.
#
# To enable debugging, uncomment following line:
# set -x
#
###########################################
# Function to echo usage
###########################################
usage ()
{
program=`basename $0`
cat <<EOF
Usage:
${program} [pre|post] [1|2|3|4|5|6]
[pre|post} - Specify if Pre or Post processing is being performed
[1|2|3|4|5|6] - Indicate Dbvisit operation being performed
-h - display the usage

pre = Pre Dbvisit Processing step
post = Post Dbvisit Processing step
1 = Dbvisit is executed on primary and will be sending logs to standby
2 = Dbvisit is executed on standby and will be applying logs
3 = Dbvisit Graceful Switchover is executed on primary 
4 = Dbvisit Graceful Switchover is executed on standby
5 = Dbvisit Activiation is excecuted on standby
6 = Standby Database is opened read-only 
Example, to perform a task on the standby server following activation:
${program} post 5
EOF
exit 1
}
###########################################
# Function to setup parameter variables
# Description:
# Specify any global settings in this section
###########################################
setup_parameters ()
{
## Below are some example values
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
SERVER=`uname -n`
dbvisit_base=/usr/dbvisit
logfile=${dbvisit_base}/standby/log/pre-post-dbvisit.log
}
###########################################
# Function to change database environments
# Description:
# Use oraenv to set the environment if needed
###########################################
set_env ()
{
export ORAENV_ASK=NO
export ORACLE_SID=$1
. oraenv >> /dev/null
export ORAENV_ASK=YES
}
###########################################
# Function to Add text to logfile
###########################################
addLog()
{
# comment 1st line below to remove echo back to user and to only write to log
echo "`date +%d-%h-%Y:%H:%M:%S` : ${1}" 
echo "`date +%d-%h-%Y:%H:%M:%S` : ${1}" >> ${logfile}
}
### Add your custom functions here
###
##########################
##########################
####
#### MAIN PROGRAM SECTION
####
##########################
##########################
## First call function to set the environment or specific global variables
setup_parameters
## Test input values, must be 2 values, if not exit
if test $# -ne 2
then
echo "Cannot execute, 2 values must be specified as input..."
usage
exit 99
fi
if [ ${1} = "pre" ] || [ ${1} = "post" ] 
then
if ! [[ $2 =~ '^[1-6]+$' ]]
then 
echo "2nd Parameter must be a number between 1 and 6"
usage
exit 97
fi
else
echo "1st Parameter must be \"pre\" or \"post\"";
usage
exit 98
fi
### Now that values are valid, execute required code block
case ${1} in
pre) 
addLog "Start Pre Processing"
case ${2} in
1) 
addLog "Primary Database Send"
## add custom code here or call custom function
;;
2)
addLog "Standby Database Apply"
## add custom code here or call custom function
;;
3)
addLog "Primary Server Graceful Switchover"
## add custom code here or call custom function
;;
4)
addLog "Standby Server Graceful Switchover"
## add custom code here or call custom function
;;
5)
addLog "Standby Database Activate"
## add custom code here or call custom function
;;
6)
addLog "Standby Database Read-Only"
## add custom code here or call custom function
;;
esac 
;;
post)
addLog "Start post Processing"
case ${2} in
1)
addLog "Primary Database Send"
## add custom code here or call custom function
;;
2)
addLog "Standby Database Apply"
## add custom code here or call custom function
;;
3)
addLog "Primary Server Graceful Switchover"
## add custom code here or call custom function
;;
4)
addLog "Standby Server Graceful Switchover"
## add custom code here or call custom function
;;
5)
addLog "Standby Database Activate"
## add custom code here or call custom function
;;
6)
addLog "Standby Database Read-Only"
## add custom code here or call custom function
;;
esac
;;
esac

ASM Aliases


One of the changes included since the 8.0.16 release is that during CSD (at the end of it) a text file is created in the standby dbvisit LOGDIR.

This file contains a list of datafile details from the primary, which would include example the ASM alias names if they were used.

The file naming is DBVISIT_BASE/standby/log/dbv_<DDC>_csd_db_file_info.txt


The file text have the following format:

DATAFIILE_TYPE (DATA/TEMP), FILE_ID, FILE_NAME, TABLESPACE_NAME,CON_ID


Example:

DATA,1,+DATA2/DBVFOUR/DATAFILE/system.263.948382091,SYSTEM,0
DATA,2,+DATA2/DBVFOUR/DATAFILE/sysaux.264.948382097,SYSAUX,0
DATA,3,+DATA2/DBVFOUR/DATAFILE/undotbs1.265.948382101,UNDOTBS1,0
DATA,4,+DATA2/DBVFOUR/DATAFILE/undotbs2.267.948382111,UNDOTBS2,0
DATA,5,+DATA2/DBVFOUR/DATAFILE/users.268.948382115,USERS,0
DATA,6,+DATA2/DBVFOUR/DATAFILE/test02.dbf,TEST1,0
DATA,8,+DATA2/dbvfour/test401.dbf,TEST4,0
TEMP,1,+DATA2/DBVFOUR/TEMPFILE/temp.2097.950291191,TEMP,0


This file can be used as part of a post-processing script (sample is located in the DBVISIT_BASE/standby/doc) folder - at the end of CSD to run a small script to take this as input and create ASM aliases if you require that on the standby server.   

We do not recommend the use of ASM aliases but to rather use true OMF naming.  But if you do want to continue with ASM aliases, we now provide the above to help you create your own post processing script to create them as required to your needs



  • No labels