> For the complete documentation index, see [llms.txt](https://dbi-services.gitbook.io/dmk-oracle-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dbi-services.gitbook.io/dmk-oracle-manual/scripts/dgobserver.-ksh-or-ps1.md).

# dgobserver.ksh

In an Oracle Dataguard environment with Fast-Start Failover activated, you should be able to automate the restart of an “Observer”. This exactly what the script performs.

First of all you need to prepare the environment.

* Add the ORACLE\_SID into the ORATAB
* Create under ${DMK\_ORA\_ADMIN\_SID} a “etc” directory
* Source DMK to load the new configuration
* Copy into “${DMK\_ORA\_ADMIN\_SID}/etc” the dgobserver.cfg template

```
cat ${DMK_HOME}/templates/etc/dgobserver.cfg
# template dgcheck.cfg  - defines variables for  the observer monitoring script

#****************************************************************************************
# Connection string to the ConfigurationWideServiceName
# create an entry in tnsnames.ora with
# <DB_NAME>_CFG.<DB_DOMAIN>=
#  (DESCRIPTION =(ADDRESS=(PROTOCOL=TCP)(HOST=<host1>)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=<host2>)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=<db_name>_CFG.<DB_DOMAIN>)))

ConnectStringConfigWide="/@<DB_UNIQUE_NAME>.<DB_DOMAIN>"

# To use 'in background' start-option, a wallet-connect (/@alias) is required

#****************************************************************************************
# Connection string to the primary - only to specify if not using ConnectStringConfigWide
#ConnectStringPrim="sys/xxxx@<DB_UNIQUE_NAME>.<DB_DOMAIN>"

#****************************************************************************************
# Connection string to the Standby - only to specify if not using ConnectStringConfigWide
#ConnectStringStdb="sys/xxxx@<DB_UNIQUE_NAME>.<DB_DOMAIN>"

#****************************************************************************************
# Kill the Observer process once timeout has been reached (seconds)
ObserverStopHardlyTimeOut=30

#****************************************************************************************
# This parameter specify how long the script retries to reach
# the databases in order to start the observer (seconds)
ObserverRebootRetryTime=600
```

It is recommended to connect to the configuration wide service name

```
DGMGRL> show configuration ConfigurationWideServiceName
```

This service is registered by all running database sites with the local listener. It is recommended to create a tnsnames alias \<DB\_UNIQUE\_NAME>.\<DB\_DOMAIN> using this service (per default \<db\_name>\_CFG.\<db\_domain>).

As highlighted by the above configuration the script tries to reach at least one database instance (regardless of the database role) in order to start/stop the observer and enter in a loop which retries to connect to the database for about 10minutes.

This is especially useful in case of a reboot; mostly the database servers needs more time to complete the boot sequence. Therefore the script loops for 10min before it gives-up.

Syntax

```
dgobserver.ksh [start|stop|status] [SID]
```

Do not forget to add the script into the “${DMK\_HOME}/etc/service\_start\_stop.cfg” configuration file in order to start/ the observer in case of a reboot.
