Data Guard Broker

###################################################
##      How to configure DATA GUARD BROKER    ##
###################################################

# Create the data guard broker files

--Primary
alter system set dg_broker_config_file1 = '+DATA1/TEFOXTR/DATAGUARDCONFIG/brokerconfig01.dat';
alter system set dg_broker_config_file2 = '+FRA1/TEFOXTR/DATAGUARDCONFIG/brokerconfig02.dat';

--Standby
alter system set dg_broker_config_file1 = '+DATA1/TEFOXZH/DATAGUARDCONFIG/brokerconfig01.dat';
alter system set dg_broker_config_file2 = '+FRA1/TEFOXZH/DATAGUARDCONFIG/brokerconfig02.dat';


--Start the broker on both databases
alter system set dg_broker_start=true;


--From the primary database connect to the broker and create the configuration
#dgmgrl

DGMGRL>
connect sys/xxxxxxx@TEFOXTR.emilianofusaglia.net

--Create the configuration for primary database
create configuration 'BRKTEFOX' as primary database is 'TEFOXTR' connect identifier is TEFOXTR_DGBHA.emilianofusaglia.net;

--Add standby database
add database 'TEFOXZH' as connect identifier is TEFOXZH_DGBHA.emilianofusaglia.net;

--Setup the properties
edit database 'TEFOXTR' set property 'LogXptMode' = 'SYNC';
edit database 'TEFOXZH' set property 'LogXptMode' = 'SYNC';
--or
edit database 'TEFOXTR' set property 'LogXptMode' = 'ASYNC';
edit database 'TEFOXZH' set property 'LogXptMode' = 'ASYNC';

edit configuration set protection mode as maxprotection;
--or
edit configuration set protection mode as maxavailability;
--or
edit configuration set protection mode as maxperformance;

edit database 'TEFOXTR' set property 'NetTimeout' = '20';
edit database 'TEFOXZH' set property 'NetTimeout' = '20';

edit database 'TEFOXTR' set property 'Binding' = 'MANDATORY';
edit database 'TEFOXZH' set property 'Binding' = 'MANDATORY';

enable configuration;

-- Switchover command:
DGMGRL> SWITCHOVER to "TEFOXZH";

--Stop Recovery
edit database 'TEFOXZH' set state = 'APPLY-OFF';
--Start Recovery
edit database 'TEFOXZH' set state = 'APPLY-ON';
edit database 'TEFOXZH' set state = 'APPLY-ON' WITH APPLY INSTANCE ='TEFOXZH1';

--Enable ArchiveLog Tracing on Primary and Standby for Troubleshooting
edit instance 'TEFOXTR1' on database 'TEFOXTR' set property 'LogArchiveTrace' = '1';    
edit instance 'TEFOXZH1' on database 'TEFOXZH' set property 'LogArchiveTrace' = '6345';