This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
generated from gomu-gomu/starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateObserver.sh
40 lines (34 loc) · 1.53 KB
/
createObserver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2022 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2022
# Author: [email protected]
# Description: Creates Data Guard Observer using the following parameters:
# $DG_OBSERVER_NAME: Name of the observer
# $PRIMARY_DB_CONN_STR: Connection string to connect with primary database
# $ORACLE_PWD: The Oracle password for sys user of the primary database
# $DG_OBSERVER_DIR: Directory to store observer data, log files
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
set -e
# Validation: Check if PRIMARY_DB_CONN_STR is provided or not
if [ -z "$PRIMARY_DB_CONN_STR" ]; then
echo "ERROR: Please provide PRIMARY_DB_CONN_STR to connect with primary database. Exiting..."
exit 1
fi
# Validation: Check if ORACLE_PWD (which is password for sys user of the primary database) is provided or not
if [ -z "$ORACLE_PWD" ]; then
echo "ERROR: Please provide sys user password of primary database as ORACLE_PWD. Exiting..."
exit 1
fi
# Creating the directory for Observer configuration and log file
mkdir -p "$DG_OBSERVER_DIR"
# Starting observer in background, passing password using here-doc
nohup dgmgrl -echo sys@${PRIMARY_DB_CONN_STR} "START OBSERVER ${DG_OBSERVER_NAME} FILE IS ${DG_OBSERVER_DIR}/fsfo.dat LOGFILE IS ${DG_OBSERVER_DIR}/observer.log" > "${DG_OBSERVER_DIR}"/nohup.out << EOF &
${ORACLE_PWD}
EOF
# Sleep for dgmgrl to start observer in background otherwise container will exit
sleep 4