Oracle DOC: https://docs.oracle.com/database/121/DGBKR/cli.htm#DGBKR570
========================================================DG Configuration begins=========================================================
$PC_PROD>dgmgrl
DGMGRL>connect C##JWONG
Connected as sysdg
DGMGRL>Connect C##JWONG@SC_PROD
Connect as sysdg
DGMGRL>quit
$PC_PROD>sqlplus / as sysdba
SQL>alter system set log_archive_dest_2='' scope=both;
SQL>alter system set dg_broker_start=true scope=both;
SQL>
$Atlanata>sqlplus / as sysdba
SQL>alter database recover managed standby database cancel;
SQL>alter system set log_archive_dest_2='' scope=both;
SQL>alter system set dg_broker_start=true scope=both;
$PC_PROD>dgmgrl
DGMGRL>connect C##JWONG@PC_PROD
Connected as sysdg
DGMGRL>create configuration 'DGConf' as primary database is 'PC_PROD' connect identifier is PC_PROD;
DGMGRL>show configuration;
DGMGRL>add database 'SC_PROD' as connect identifier is SC_PROD;
DGMGRL>EDIT database 'PC_PROD' SET PROPERTY 'RedoRoutes' = '(PC_PROD:SC_PROD ASYNC)';
DGMGRL> SHOW CONFIGURATION WHEN PRIMARY IS 'PC_PROD';
DGMGRL>EDIT database 'SC_PROD' SET PROPERTY 'RedoRoutes' = '(SC_PROD:PC_PROD ASYNC)';
DGMGRL> SHOW CONFIGURATION WHEN PRIMARY IS 'SC_PROD';
DGMGRL>enable configuration;
Enabled
DGMGRL>show configuration;
DGMGRL>show database PC_PROD;
DGMGRL>show database SC_PROD;
========================================================DG Configuration ready=========================================================
========================================================Switchover begins=========================================================
DGMGRL>validate database verbose 'PC_PROD';
--ready for switchover 
DGMGRL>validate database verbose 'SC_PROD';
--ready for switchover
--ready for failover

$SC_PROD>
SQL>show pdbs;
pdbs are readonly
SQL> select open_mode from v$database;
read only with apply
SQL>
$PC_PROD>
DGMGRL>switchover to SC_PROD
##failover
DGMGRL>failover to SC_PROD
DGMGRL>
--successful, SC_PROD is now new primary
$SC_PROD>
SQL>quit ----because of the restart
$SC_PROD>
SQL>sqlplus / as sysdba
SQL>select open_mode from v$database;
read write

SQL>show pdbs
pdbs are read write
SQL>
$PC_PROD>
SQL>quit ---- because of restart
$PC_PROD>
SQL>sqlplus / as sysdba
SQL>select open_mode from v$database;
read only with apply ----(mounted)
----only for CDB
SQL>show pdbs
pdbs are mounted
SQL>alter pluggable database all open;
SQL>show pdbs
----pdbs are read only
SQL>exit
=====================================================switch back begins=======================================================
$PC_PROD>dgmgrl
DGMGRL>connect C##JWONG@PC_PROD
DGMGRL>validate database verbose PC_PROD
--ready for switchover
--ready for failover
DGMGRL>validate database verbose SC_PROD
--ready for switchover

DGMGRL>switchover to PC_PROD
##failover
DGMGRL>failover to PC_PROD
----successful PC_PROD now is new primary
DGMGRL>exit
$SC_PROD>
SQL>connect / as sysdba
SQL>show pdbs
mounted
SQL>alter pluggable database all open;
----open
----test active data guard by selecting records---------------------------------------
SQL>alter session set container=pdb1;
SQL>select count(* from hr.employees;
..107
SQL>
$PC_PROD>sqlplus / as sysdba
SQL>show pdbs
read write
SQL>!clear
SQL>
