0% found this document useful (0 votes)
14 views27 pages

Oracle DataGuard Broker - HA AND Disaster Recovery !!

The document provides an overview of configuring and operating the Data Guard Broker using DGMGRL, detailing its components, including configuration files, background processes, and the command line interface. It outlines the steps to set up the Data Guard Broker, including enabling the broker, configuring databases, and managing connections. Additionally, it explains the roles of various processes like DMON, NSV, and RSM in maintaining database configurations and communication between primary and standby databases.

Uploaded by

Abdo Mohamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views27 pages

Oracle DataGuard Broker - HA AND Disaster Recovery !!

The document provides an overview of configuring and operating the Data Guard Broker using DGMGRL, detailing its components, including configuration files, background processes, and the command line interface. It outlines the steps to set up the Data Guard Broker, including enabling the broker, configuring databases, and managing connections. Additionally, it explains the roles of various processes like DMON, NSV, and RSM in maintaining database configurations and communication between primary and standby databases.

Uploaded by

Abdo Mohamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

A DATA GUARD BROKER

In this article I present about Data Guard Broker and also steps to configure Data Guard Broker.
The Data Guard Broker logically groups Primary and all Standby databases in a DATA GUARD setup
into a broker configuration to manage and monitor them. All operations can be performed either
through OEM (GUI) or the broker’s Command line Interface (DGMGRL).

The Broker Consists of Three Major Parts

Broker Configuration files


Background Processes on each node
Command line interface known as DGMGRL

CONFIGURATION FILES

By default, the Data Guard Broker has two copies of configuration files located at $ORACLE_HOME/dbs
with file name of dr1_db_unique_name.dat and dr2_db_unique_name.dat

SYS> SHOW PARAMETERS DG_BROKER_CONFIG;

NAME TYPE VALUE


-------------------------- ---------- -------------------------------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0/db_home1/dbs/dr1crms.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0/db_home1/dbs/dr2crms.dat

When the broker is started for the first time, the configuration files are automatically created
and names using default path name and filename. You must set these parameters on the primary
(production) database as well as on any standby databases.

If you wish to override you can using alter system set command? In My Opinion, It’s a bad practice
to keep both files in same place especially on the Primary database.

SYS> alter system set dg_broker_config_file1='/preferred location/' ...


SYS> alter system set dg_broker_config_file2='/preferred location/' ...

You can only be set or changed when the Data Guard broker is not running (DG_BROKER_START=FALSE).

Its recommend to place these files on different disks so single disk failure does NOT affect your
broker configuration. The Primary has the master copies of the configuration files, because the
broker is Primary-Centric. All changes to these files are done by the primary, even if you are on
the standby server the configuration changes will be passed to the primary via NSV-DRC processes
and the DMON process will make the change which is then propagated back to the standby databases.

If the primary has a problem then each standby database has a copy, when a failover occurs the
Standby that becomes the primary then become the master of those configuration files.

DMON PROCESS

DMON stands for Data Guard Monitor Process specific to Data Guard Broker. If Data Guard Broker is
enabled, Oracle uses Data Guard Broker Monitor (DMON) background process to manage and monitor
the primary and standby databases as a unified configuration.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

This Process runs for every database instance that is managed by broker and gets enabled when you
set DG_BROKER_START=TRUE. By default the value of DG_BROKER_START=FALSE.

DMON is the server side component that interacts with local database and the DMON process of the
other database to perform requested function. This is responsible for monitoring health of the
broker configuration and maintains consistent description of configuration files.

DATABASES WITH BROKER (DMON) PROCESSES

BACKGROUND PROCESSES

DATA GUARD BROKER PROCESSES

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

In Data Guard Broker configuration, DMON Process on the Primary database that is the owner of the
configuration, all Commands to modify any configuration comes only from the Primary (though you
may connect any database using DGMGRL Client), all Standby databases receive all configuration
changes via the Primary.

BROKER RESOURCE MANAGER (RSM)

When DMON needs to execute some SQL statement, (if SQL is for Primary with the help of RFS
process, it will execute it directly. Suppose SQL is for the standby database, the RSM asks the
NSV process to send it to the standby database. The configuration commands executed by the
broker during the database startup or may be required to be run during Data Guard setup.

DATA GUARD NET SERVER – (NSVn)

NSV processes are responsible for making connection with the remote database.
DMON or RSM process may ask NSV process to connect to other node for any work request.
DMON may need to send some communication to the other node and RSM may have to get some data
through SQL from other node.

Each NSV Process will have DRC process on the Standby database, which performs the actual work on
behalf of the NSV process, the DRS process on the standby will return the status back to NSV
Process on the Primary.

The DMON Process of the Primary database tries to communicate with each Standby via NSV-DRC pair
to establish communication and configuration info so that the standby can start and apply services.

DRCn

NSV Processes contact DRC process running on the other node to establish the connection, so DRC
acts like a receiver on the other node.

INTER NODE SERVERS (INSVs)

When using RAC environment, there are some set of processes called the internode servers (INSV).
Which maintain a connection between the nodes in the cluster to ensure that the broker on each
node knows the state of the cluster.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

COMMAND LINE INTERFACE - DGMGRL

The third part of broker setup is the interface through which users will interact with broker.
Let’s start to configure DGMGRL.

DISASTER RECOVERY ENVIRONMENT

OPERATING SYSTEM : RHEL


DATABASE SOFTWARE : 11.2.0.1

PRIMARY DB_NAME : CRMS


STANDBY DB_NAME : CRMS

PRIMARY DATABASE UNIQUE NAME : CRMS


STANDBY DATABASE UNIQUE NAME : STBYCRMS

PRIMARY SERVER  192.168.1.130  SERVER1.ORACLE.COM  SERVER1  PRODUCTION DATABASE


STANDBY SERVER  192.168.1.131  SERVER2.ORACLE.COM  SERVER2  STANDBY DATABASE

CONFIGURING DATA GUARD BROKER

TO SET DG_BROKER_START=TRUE on both databases.


The Primary database to be open.
The Standby database to have been mounted.

VERIFY DG_BROKER_START PARAMETER

# ON PRIMARY DATABASE AND STANDBY DATABASE

SYS> show parameter DG_BROKER_START;

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE

SET DG_BROKER_START TO TRUE

# ON PRIMARY DATABASE

SYS> alter system set DG_BROKER_START=TRUE scope=both;


System altered.

# ON STANDBY DATABASE

SYS> alter system set DG_BROKER_START=TRUE scope=both;


System altered.

# ON PRIMARY DATABASE

SYS> show parameter db_domain;

NAME TYPE VALUE


------------------------------------ ----------- ---------------------
db_domain string

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# ON STANDBY DATABASE

SYS> show parameter db_domain;

NAME TYPE VALUE


------------------------------------ ----------- -----------------------
db_domain string

The value of db_domain is null. GLOBAL_DBNAME should be set db_unique_name_DGMGRL, so the value of
GLOBAL_DBNAME = crms_DGMGRL for Primary database and for Standby GLOBAL_DBNAME = stbycrms_DGMGRL.

# ON PRIMARY SERVER – listener.ora file contents

# listener.ora Network Configuration File:


/u01/app/oracle/product/11.2.0/db_home1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.130)(PORT = 1521))
)
)

ADR_BASE_LISTENER = /u01/app/oracle

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = crms)
(GLOBAL_DBNAME = crms_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_home1)
)
(SID_DESC =
(SID_NAME = crms)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_home1)
)
)

# ON STANDBY SERVER – listener.ora file CONTENTS

# listener.ora Network Configuration File:


/u01/app/oracle/product/11.2.0/db_home1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))
)
)

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

ADR_BASE_LISTENER = /u02/app/oracle

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = stbycrms)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_home1)
)
(SID_DESC =
(SID_NAME = stbycrms)
(GLOBAL_DBNAME = stbycrms_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_home1)
)
)

Now check listener status on both servers.

BROKER CONFIGURATION ON PRIMARY SERVER

$ dgmgrl
DGMGRL for Linux: Version 11.2.0.1.0 - Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/passwd@CRMSDB


Connected.

# ON PRIMARY DATABASE

DGMGRL> create configuration <DG_CONFIG_NAME> as primary database is <DB_UNIQUE_NAME>


connect identifier is <PRIMARY_NET_SERVICE_NAME>;

DGMGRL> create configuration dgcrms as primary database is crms connect identifier is CRMSDB;
Configuration "dgcrms" created with primary database "crms"

DGMGRL> show configuration;

Configuration - dgcrms
Protection Mode : MaxPerformance
Databases : crms - Primary database
Fast-Start Failover : DISABLED
Configuration Status : DISABLED

# ADDING THE PHYSICAL STANDBY DATABASE

DGMGRL> add database <STANDBY_DB_UNIQUE_NAME> as connect identifier is


<STANDBY_NET_SERVICE_NAME> maintained as physical;

DGMGRL> add database stbycrms as connect identifier is STBY_CRMSDB maintained as physical;


Database "stbycrms" added

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

DGMGRL> show configuration;

Configuration - dgcrms
Protection Mode: MaxPerformance
Databases: crms - Primary database
stbycrms - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status: DISABLED

# CONFIGURATION NEEDS TO BE ENABLED

DGMGRL> enable configuration;


Enabled.

DGMGRL> show configuration;

Configuration - dgcrms
Protection Mode: MaxPerformance
Databases:
crms - Primary database
stbycrms - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status: SUCCESS

DGMGRL> show database verbose crms;

Database - crms

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
crms

Properties:
DGConnectIdentifier = 'crmsdb'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '...
LogFileNameConvert = '...
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'SERVER1.ORACLE.COM'
SidName = 'crms'
StaticConnectIdentifier =
'(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER1.ORACLE.COM)(PORT=1521))(CONNECT_DATA=
(SERVICE_NAME=crms_DGMGRL)(INSTANCE_NAME=crms)(SERVER=DEDICATED)))'
StandbyArchiveLocation = 'USE_DB_RECOVERY_FILE_DEST'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
TopWaitEvents = '(monitor)'

Database Status: SUCCESS

DGMGRL> show database verbose stbycrms;

Database - stbycrms

Role: PHYSICAL STANDBY


Intended State: APPLY-ON
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: ON
Instance(s):
stbycrms

Properties:
DGConnectIdentifier = 'stby_crmsdb'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '...
LogFileNameConvert = '...
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'SERVER2.ORACLE.COM'
SidName = 'stbycrms'
StaticConnectIdentifier =
'(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER2.ORACLE.COM)(PORT=1521))(CONNECT_DATA=
(SERVICE_NAME=stbycrms_DGMGRL)(INSTANCE_NAME=stbycrms)(SERVER=DEDICATED)))'
StandbyArchiveLocation = 'USE_DB_RECOVERY_FILE_DEST'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
TopWaitEvents = '(monitor)'

Database Status: SUCCESS

DGMGRL> help

add Adds a standby database to the broker configuration


connect Connects to an Oracle database instance
convert Converts a database from one type to another
create Creates a broker configuration
disable Disables a configuration, a database, or fast-start failover
edit Edits a configuration, database, or instance
enable Enables a configuration, a database, or fast-start failover
exit Exits the program
failover Changes a standby database to be the primary database
help Displays description and syntax for a command
quit Exits the program
reinstate Changes a database marked for reinstatement into a viable standby
rem Comment to be ignored by DGMGRL
remove Removes a configuration, database, or instance
show Displays information about a configuration, database, or instance
shutdown Shuts down a currently running Oracle database instance
start Starts the fast-start failover observer
startup Starts an Oracle database instance
stop Stops the fast-start failover observer
switchover Switches roles between a primary and standby database

Use "help <command>" to see syntax for individual commands

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

EQUIVALENT BROKER COMMNADS TO ALTER SYSTEM

DGMGRL> SHOW DATABASE 'crms' 'LogArchiveMaxProcesses';


LogArchiveMaxProcesses = '4'

SYS> alter system set log_archive_max_processes=8 scope=spfile;


DGMGRL> EDIT DATABASE 'crms' SET PROPERTY 'LogArchiveMaxProcesses'=8;
Property "LogArchiveMaxProcesses" updated

DGMGRL> SHOW DATABASE 'crms' 'LogArchiveMaxProcesses';


LogArchiveMaxProcesses = '8'

SYS> alter database recover managed standby database cancel;


DGMGRL> edit database 'stbycrms' set state='LOG-APPLY-OFF';

SYS> alter database recover managed standby database disconnect from session;
DGMGRL> edit database 'stbycrms' set state='ONLINE';

SYS> alter database set log_archive_dest_2='defer' scope=both;


DGMGRL> edit database 'stbycrms' set property 'LogShipping'='OFF';

SYS> alter database set log_archive_dest_2='enable' scope=both;


DGMGRL> edit database 'stbycrms' set property 'LogShipping'='ON';

PERFORM A SWITCHOVER TEST

DGMGRL> show configuration;


Configuration - dgcrms
Protection Mode: MaxPerformance
Databases:
crms - Primary database
stbycrms - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:SUCCESS

DGMGRL> switchover to stbycrms;


Performing switchover NOW, please wait...
New primary database "stbycrms" is opening...
Operation requires shutdown of instance "crms" on database "crms"
Shutting down instance "crms"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "crms" on database "crms"
Starting instance "crms"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "stbycrms"

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
stbycrms - Primary database
crms - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status: SUCCESS

# The FORMER STANDBY DATABASE IS NOW THE NEW PRIMARY DATABASE

SYS> select name, db_unique_name, database_role, open_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE


--------- ------------------------------ ---------------- --------------------
CRMS stbycrms PRIMARY READ WRITE

# The FORMER PRIMARY DATABASE IS NOW THE NEW PHYSICAL STANDBY

SYS> select database_role, db_unique_name, protection_level, open_mode from v$database;

DATABASE_ROLE DB_UNIQUE_NAME PROTECTION_LEVEL OPEN_MODE


----------------- ----------------- --------------------- ----------
PHYSICAL STANDBY crms MAXIMUM PERFORMANCE MOUNTED

SYS> select DEST_ID,DEST_NAME,STATUS,TYPE,SRL,RECOVERY_MODE


from v$archive_dest_status where dest_id=1;

DEST_ID DEST_NAME STATUS TYPE SRL RECOVERY_MODE


--------- ------------------- -------- ------- ----- ------------------------
1 LOG_ARCHIVE_DEST_1 VALID LOCAL NO MANAGED REAL TIME APPLY

POINTS TO NOTE

The broker automatically enables real-time-apply on standby databases. When Redo Apply in real
time, the redo data is recovered directly from the standby redo log files as they are being filled.

The standby database does not have to wait for the log files to be archived before applying redo
data from the archived redo log files. This minimizes the transactional lag between the primary
and the standby. Reference doc here

IS STANDBY IN SYNC WITH PRIMARY ?

# ON THE PRIMARY DATABASE

SYS> select thread#, max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14722

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# ON STANDBY DATABASE

SYS> select thread#, max(sequence#) from v$archived_log where applied='YES' group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14722

QUERYING STANDBY REDO LOG FILES ON STANDBY SITE

# ON STANDBY DATABASE

SYS> select group#, sequence#, bytes, used,status from v$standby_log;

GROUP# SEQUENCE# BYTES USED STATUS


---------- ---------- ---------- ---------- ----------
4 14723 52428800 1263104 ACTIVE
5 0 52428800 512 UNASSIGNED
6 0 52428800 512 UNASSIGNED
7 0 52428800 512 UNASSIGNED

SHOW THE CONFIGURATION

DGMGRL> show database crms;

Database - crms
Role: PHYSICAL STANDBY
Intended State : APPLY-ON
Transport Lag : 0 seconds
Apply Lag : 0 seconds
Real Time Query: OFF
Instance(s) : crms
Database Status : SUCCESS

DGMGRL> show database stbycrms;

Database - stbycrms
Role : PRIMARY
Intended State: TRANSPORT-ON
Instance(s) : stbycrms
Database Status : SUCCESS

SWITCHOVER TO THE FORMER PRIMARY DATABASE :

DGMGRL> switchover to crms;


Performing switchover NOW, please wait...
New primary database "crms" is opening...
Operation requires shutdown of instance "stbycrms" on database "stbycrms"
Shutting down instance "stbycrms"...
ORA-01109: database not open

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

Database dismounted.
ORACLE instance shut down.

Operation requires startup of instance "stbycrms" on database "stbycrms"


Starting instance "stbycrms"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "crms"

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover : DISABLED


Configuration Status: SUCCESS

# ON PRIMARY DATABASE

SYS> select name, db_unique_name, database_role, open_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE


--------- ------------------------------ ---------------- --------------------
CRMS crms PRIMARY READ WRITE

# ON STANDBY DATABASE

SYS> select name, db_unique_name, database_role, open_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE


--------- ------------------------------ ---------------- --------------------
CRMS stbycrms PHYSICAL STANDBY MOUNTED

SYS> select DEST_ID, DEST_NAME, STATUS, TYPE, SRL, RECOVERY_MODE


from v$archive_dest_status where dest_id=1;

DEST_ID DEST_NAME STATUS TYPE SRL RECOVERY_MODE


-------- ------------------ ------- ------- ---- --------------------------
1 LOG_ARCHIVE_DEST_1 VALID LOCAL NO MANAGED REAL TIME APPLY

DGMGRL> show database crms

Database - crms
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s): crms
Database Status: SUCCESS

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

DGMGRL> show database stbycrms;

Database - stbycrms

Role: PHYSICAL STANDBY


Intended State : APPLY-ON
Transport Lag : 0 seconds
Apply Lag : 0
Real Time Query : ON
Instance(s) : stbycrms
Database Status: SUCCESS

CHANGE DATAGUARD PROTECTION MODE

We can change Data Guard Protection mode using Data Guard command line interface (DGMGRL).
Already Physical Standby database is configured as MAXIMUM PERFORMANCE.
This scenario sets Protection mode of the configuration would be MAXIMUM AVALIABILITY.

Configure Standby Redolog files.


Set database property LogXptMode to SYNC

Maximum Availability Protection mode requires standby redolog files on the standby database. In
order to change from MAXIMUM PERFORMANCE to MAXIMUM AVAILABILITY the Log Transport Mode LogXptMode
must be set to SYNC.

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status:
SUCCESS

DGMGRL> EDIT DATABASE 'stbycrms' SET PROPERTY 'LOGXPTMODE'='SYNC';


Property "LogXptMode" updated

The broker will not allow this command to succeed unless the standby database is configured with
standby redo log files in the configuration.

Now you can change the protection mode to MAXIMUM AVAILABILITY. The protection mode is changed
using the EDIT CONFIGURATION SET PROTECTION MODE AS command.

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;


Succeeded.

Suppose configuration is disabled when you enter above command, protection mode is not applied
until you enable the configuration using ENABLE CONFIGURATION command.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# VERIFY PROTECTION MODE USING SHOW CONFIGURATION COMMAND

DGMGRL> show configuration;

Configuration - dgcrms
Protection Mode: MaxAvailability
Databases:
crms - Primary database
stbycrms - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status: SUCCESS

CHANGE FROM MAXIMUM AVAILABILITY TO MAX PROTECTION

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPROTECTION;


Succeeded.

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxProtection


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

CHANGE FROM MAXIMUM PROTECTION TO MAX PERFORMANCE

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;


Succeeded.

DGMGRL> EDIT DATABASE STBYCRMS SET PROPERTY LOGXPTMODE='ASYNC';


Property "logxptmode" updated

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

As we know changing the protection mode is very simple using DGMGRL. But anyhow a point to note that when
you change protection mode from MAX PERFORMANCE to MAX PROTECTION, ensure first process would be change to
max availability and then to max protection. Otherwise Primary will be taken down. Let’s see

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

CHANGE FROM MAXIMUM PERFORMANCE TO MAXIMUM PROTECTION

Now you can set the protection mode to Maximum Protection from Maximum Performance. Changing
directly to Maximum Protection mode requires the restart of the primary database.

DGMGRL> EDIT DATABASE stbycrms SET PROPERTY LOGXPTMODE=SYNC;


Property "logxptmode" updated

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPROTECTION;

Operation requires shutdown of instance "crms" on database "crms"


Shutting down instance "crms"...
Database closed.
Database dismounted.
ORACLE instance shut down.

Operation requires startup of instance "crms" on database "crms"


Starting instance "crms"...
ORACLE instance started.
Database mounted.
Database opened.

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxProtection


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

# ON PRIMARY DATABASE

SYS> show parameter log_archive_dest_2;

NAME TYPE VALUE


-------------------------- ----------- ------------------------------------------------------
log_archive_dest_2 string service="stby_crmsdb", LGWR SYNC AFFIRM DELAY=0
optional compression=disable max_failure=0
max_connections=1 reopen=300 db_unique_name="stbycrms"
net_timeout=30, valid_for=(all_logfiles, primary_role)
# ON STANDBY DATABASE

SYS> show parameter log_archive_dest_2;

NAME TYPE VALUE


-------------------------- ----------- ------------------------------------------------------
log_archive_dest_2 string service="stby_crmsdb", LGWR ASYNC AFFIRM
valid_for=(all_logfiles, primary_role)
db_unique_name="stbycrms"

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

LOGXPTMODE =SYNC/ASYNC

ASYNC should be used when LGWR is used to transfer logs in MAX PERFORMANCE mode. This is default.
SYNC is for MAX AVAILABILITY or MAX PROTECTION mode.

Before you perform switchover process, you need to change database property LogXptMode of the
Primary database also it is taken care during a transition.

Already we have changed LogXptMode=SYNC in primary database to send redo data for standby database.
But still we maintain LogXptMode=ASYNC in standby database. Before switch over process we need to
set LogXptMode=SYNC at both side, If Protection mode is MAX AVAILABILITY or MAX PROTECTION.

If you ignore you would get following ORA ERROR.

Error: ORA-16627:
operation disallowed since no standby databases would remain to support protection mode Failed.

DGMGRL> switchover to stbycrms;


..
...

Switchover succeeded, new primary is "stbycrms"

# EXECUTE FOLLOWING SQL STATEMENT AT BOTH SIDE

SYS> select name, db_unique_name, database_role, protection_mode from v$database;


...

I reset Protection Mode as MAXIMUM PERFORMANCE and LogXptMode=ASYNC at both side.

CONVERY PHYSICAL STANDBY TO SNAPSHOT STANDBY

Steps to convert a Physical Standby database to Snapshot Standby database using Data Guard broker
command line interface DGMGRL. Redo data will continue to be received by the database while it is
operating as a snapshot standby database but redo will not be applied until the Snapshot Standby
is converted back into Physical Standby database.

The flashback feature is required to create a snapshot standby database. If flashback database is
disabled, it is enabled automatically during conversion to a snapshot standby database.

# VERIFY DATABASE DETAILS

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerfromance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# CONVERT A PHYSICAL STANDBY TO A SNAPSHOT DATABASE

DGMGRL> convert database stbycrms to snapshot standby;


Converting database "crms" to a Snapshot Standby database, please wait...
Database "stbycrms" converted successfully

$ tail –f alert_stbycrms.log
..
...

alter database convert to snapshot standby


Starting background process RVWR
Tue Nov 16 04:22:15 2015
RVWR started with pid=20, OS id=25510
Allocated 15937428 bytes in shared pool for flashback generation buffer
Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_11/16/2015 04:22:15

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Snapshot standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

# CHECH STANDBY DATABASE

SYS> select name, db_unique_name, database_role, protection_mode from v$database;

NAME DB_UNIQU DATABASE_ROLE PROTECTION_MODE


--------- ----------- -------------------- --------------------
CRMS stbycrms SNAPSHOT STANDBY MAXIMUM PERFORMANCE

SYS> select open_mode, flashback_on from v$database;

OPEN_MODE FLASHBACK_ON
-------------------- ------------------
READ WRITE RESTORE POINT ONLY

# CHECK ARCHIVE LOG DETALS ON PRIMARY DATBASE

SYS> archive log list;


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 14943
Next log sequence to archive 14945
Current log sequence 14945

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

SYS> select thread#, max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14944

# CHECK ARCHIVE LOG DETAILS ON STANDBY DATABASE [SNAPSHOT]

SYS> archive log list;


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 2
Current log sequence 2

SYS> select thread#, max(sequence#) from v$archived_log where applied='YES' group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14943

# MAKE LOG SWITCH ON PRIMARY DATABASE

SYS> alter system switch logfile;


System altered.

SYS> alter system switch logfile;


System altered.

SYS> alter system switch logfile;


System altered.

SYS> alter system switch logfile;


System altered.

SYS> select thread#, max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14948

# VERIFY WHETHER MRP HAS APPLIED OR NOT ON STANDBY DATABASE

SYS> select thread#, max(sequence#) from v$archived_log where applied='YES' group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14943

$ ps -ef | grep mrp


oracle 25591 21378 0 04:46 pts/4 00:00:00 grep mrp # MRP is NOT running

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

As I said above, redo is being received from the primary database, but is not applied. The snapshot
standby database should be revert back to a physical Standby then only it would be resynchronized
with primary by applying redo data which was earlier shipped from the primary yet not applied.

REVERT THE STANDBY DATABASE BACK TO PHYSICAL STANDBY

Any updates made to the database while it was operating as a snapshot standby will be rejected. The
conversion process does perform shutdown of the standby database. The shutdown is required for the FLASHBACK
DATABASE operation.

DGMGRL> CONVERT DATABASE 'stbycrms' to PHYSICAL STANDBY;

Operation requires shutdown of instance "stbycrms" on database "stbycrms"


Shutting down instance "stbycrms"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "stbycrms" on database "stbycrms"
Starting instance "stbycrms"...
ORACLE instance started.
Database mounted.
Continuing to convert database "stbycrms" ...
Operation requires shutdown of instance "stbycrms" on database "stbycrms"
Shutting down instance "stbycrms"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "stbycrms" on database "stbycrms"
Starting instance "stbycrms"...
ORACLE instance started.
Database "stbycrms" converted successfully

# VERIFY STANDBY DATABASE

SYS> select name, db_unique_name, database_role, protection_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


--------- ------------------------------ ---------------- --------------------
CRMS stbycrms PHYSICAL STANDBY MAXIMUM PERFORMANCE

SYS> select open_mode, flashback_on from v$database;

OPEN_MODE FLASHBACK_ON
-------------------- ------------------
MOUNTED NO

$ ps -ef | grep mrp

oracle 27524 1 4 23:25 ? 00:00:06 ora_mrp0_stbycrms


oracle 27544 21378 0 23:28 pts/4 00:00:00 grep mrp

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

# ON PRIMARY DATABSE

SYS> select thread#, max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14964

# ON STANDBY DATABASE

SYS> select thread#, max(sequence#) from v$archived_log where applied='YES' group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 14964

Now MRP process is running. All shipped redo data has been applied on the standby side. Now the
Primary database and Standby database is in SYNC.

PERFORM A MANUAL FAILOVER

Suppose Primary Database crash and cannot be recovered in a short period, then we need to perform
failover operation. After failover operation, we would remove Primary database from Data guard
configuration and have to recreate it.

If Flashback enabled on the Primary database before the failover operation, you can bring the old
Primary back into the configuration as a Standby database. It’s possible to move the old Primary
database back in time to point just before where the failure occurred.

The only consideration is you must have enabled Flashback Database on the Primary database before
the failover. It’s always good idea and recommended to enable flashback in Standby database also.

ENVIRONMENT DETAILS

Database name : crms


Primary db_unique_name : crms
Standby db_unique_name : stbycrms
Primary Site : SERVER1 – 198.168.1.130
Standby Site : SERVER2 – 198.168.1.131
Standby Database Type : Physical Standby

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# PRIMARY DATABASE SERVER

SQL> select name, db_unique_name, database_role, protection_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


--------- ----------------- ---------------- ------------------
CRMS crms PRIMARY MAXIMUM PERFORMANCE

SQL> select switchover_status, flashback_on from v$database;

SWITCHOVER_STATUS FLASHBACK_ON
-------------------- ------------------
TO STANDBY YES

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.

# STANDBY DATABASE SERVER

SQL> select name, db_unique_name, database_role, protection_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


--------- ----------------- ---------------- --------------------
CRMS stbycrms PHYSICAL STANDBY MAXIMUM PERFORMANCE

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

# CONNECTING DGMGRL COMMAND LINE INTERFACE

DGMGRL> connect sys/crms@STBY_CRMSDB


Connected.

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
crms - Primary database
stbycrms - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
ORA-01034: ORACLE not available
ORA-16625: cannot reach database "crms"

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# EXECUTE THE FAILOVER

DGMGRL> failover to stbycrms;


Performing failover NOW, please wait...
Failover succeeded, new primary is "stbycrms"

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
stbycrms - Primary database
crms - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

DGMGRL> reinstate database crms;


Reinstating database "crms", please wait...

Failed.
Reinstatement of database "crms" failed

# CONNECT THE NEW PRIMARY DATABASE

SYS> select name, db_unique_name, database_role, protection_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


--------- ------------------------------ ---------------- --------------------
CRMS stbycrms PRIMARY MAXIMUM PERFORMANCE

SYS> select standby_became_primary_scn from v$database;

STANDBY_BECAME_PRIMARY_SCN
--------------------------
221022633

After a failover (when the Physical Standby becomes the Primary), Oracle writes the failover SCN
to the control file. We can query STANDBY_BECAME_PRIMARY_SCN column of the V$DATABASE fixed view
so that it’s easy to determine at which the old standby database became the new primary database.

# ON OLD PRIMARY DATABASE

SYS> startup mount;


..
...
Database Mounted.

SYS> flashback database to scn 221022633;


Flashback complete.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# TRACE ALERT_LOG INFORMATION

$ tail –f alert_crms.log

flashback database to scn 221022633


Flashback Restore Start
Flashback Restore Complete
Flashback Media Recovery Start
Serial Media Recovery started
..
...

Incomplete Recovery applied until change 221022634 time 11/23/2015 02:05:40


Flashback Media Recovery Complete
Completed: flashback database to scn 221022633

# CONVERT THE DATABASE TO A PHYSICAL STANDBY DATABASE

SQL> alter database convert to physical standby;


Database altered.

Above SQL statement will dismount the database after successfully converting the control file to
a standby control file.

# SHUT DOWN AND RESTART THE OLD PRIMARY

SQL> select status from v$instance;

STATUS
------------
STARTED

SYS> shut immediate;

ORA-01507: database not mounted

ORACLE instance shut down

SQL> startup mount;


ORACLE instance stared.
..
...
Database Mounted.

You can start Redo Apply or real-time apply on the new Physical Standby database.

# TO START REDO APPLY

SYS> alter database recover managed standby database disconnect;


Database altered.

# TO START REAL-TIME-APPLY

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

Note that the sequence was reset to be #1

# ON THE NEW PRIMARY

SQL> archive log list;


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1

SYS> select name, db_unique_name, database_role, protection_level open_mode from v$database;

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_LEVEL OPEN_MODE


------ -------------- -------------- ------------------- ----------
CRMS stbycrms PRIMARY MAXIMUM PERFORMANCE READ WRITE

# EXECUTE THE FOLLOWING QUERY ON THE NEW STANDBY

SQL> select process, status, client_process, sequence# from v$managed_standby;

PROCESS STATUS CLIENT_P SEQUENCE#


--------- ------------ -------- ----------
ARCH CONNECTED ARCH 0
ARCH CONNECTED ARCH 0
ARCH CONNECTED ARCH 0
ARCH CONNECTED ARCH 0
RFS IDLE UNKNOWN 0
RFS IDLE UNKNOWN 0

6 rows selected.

# ON THE NEW PRIMARY DATABASE

SYS> show parameter log_archive_dest_2;


...

Here, redo transport services do not transmit redo data to the new standby database because
destination is not available. So configure valid destination to ship redo data to the standby site.

SQL> alter system set log_archive_dest_2='service=crmsdb LGWR ASYNC


VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=crms' scope=both;
System altered.

# IF LOG_ARCHIVE_DEST_STAE_2 IS DEFER, EXECUTE FOLLOWING QUERY

SYS> alter system set log_archive_dest_stae_2=ENABLE scope=both;


System altered.

SYS> alter system switch logfile;


System altered.

SYS> alter system switch logfile;


System altered.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

# NOW EXECUTE THE FOLLOWING QUERY ON THE NEW STANDBY

SQL> select process, status, client_process, sequence# from v$managed_standby;


...

# CONNECT DGMGRL COMMAND LINE INTERFACE

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
stbycrms - Primary database
crms - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

The next step is to reinstate the failed Primary database

DGMGRL> reinstate database crms;


...

DGMGRL> show configuration;


...

Or, you can use following method also.

DGMGRL> remove database crms;


Removed database "crms" from the configuration

DGMGRL> add database crms as connect identifier is CRMSDB maintained as physical;


Database "crms" added

DGMGRL> enable database crms;


Enabled.

DGMGRL> show configuration;

Configuration - dgcrms

Protection Mode: MaxPerformance


Databases:
stbycrms - Primary database
crms - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status: SUCCESS

Data Guard Broker command line interface (DGMGRL) utility that automates and centralizes Data
Guard management. Using DGMGRL we can run consecutive operations such as (switchover/failover)
with just one command unlike SQL*Plus interface.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu


DATA GUARD BROKER CONFIGURATION & OPERATIONS | DGMGRL

REMOVE SAFELY DATA GUARD BROKER

DGMGRL> connect sys@CRMSDB


Password:

DGMGRL> remove configuration;


Removed configuration

# ON THE PRIMARY DATBASE

SYS> show parameter dg_broker;

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr1crms.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr2crms.dat
dg_broker_start boolean TRUE

SYS> alter system set dg_broker_start=FALSE scope=both;


System altered.

$ cd $ORACLE_HOME/dbs
$ mv dr1crms.dat dr1crms.dat.bkp
$ mv dr2crms.dat dr2crms.dat.bkp

# ON THE STANDBY DATABASE

SYS> show parameter dg_broker;

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr1stbycrms.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr2stbycrms.dat
dg_broker_start boolean TRUE

SYS> alter system set dg_broker_start=FALSE scope=both;


System altered.

$ cd $ORACLE_HOME/dbs
$ mv dr1stbycrms.dat dr1stbycrms.dat.bkp
$ mv dr2stbycrms.dat dr2stbycrms.dat.bkp

DGMGRL> show configuration;


Error:
ORA-16525: the Data Guard broker is not yet available
Configuration details cannot be determined by DGMGRL

We have safely removed Data Guard broker configuration. Help this doc helps to you.
Nice link for DGMGRL commands given here.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

You might also like