I setup up a Oracle 12c Dataguard configuration. To build the standby database I used the RMAN DUPLICATE command, which requires a static listener configuration.
tnsname.ora on HOSTNAMEA and HOSTNAMEB are the same:
BR = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEA)(PORT = 1521))
)
(CONNECT_DATA =
(SID = BR)
) )
BR_STBY = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEB)(PORT = 1521))
)
(CONNECT_DATA =
(SID = BR)
) )
listener.ora HOSTNAMEA:
SID_LIST_LISTENER =
(SID_DESC =
(GLOBAL_DBNAME = BR_DGMGRL)
(ORACLE_HOME = /opt/oracle/product/12200/dbhome_1)
(SID_NAME = BR)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEA)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
listener.ora HOSTNAMEB:
SID_LIST_LISTENER =
(SID_DESC =
(GLOBAL_DBNAME = BR_STDBY_DGMGRL)
(ORACLE_HOME = /opt/oracle/product/12200/dbhome_1)
(SID_NAME = BR)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEB)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
This configuration is using a static listener configuration. How does the application know the database has for example switched from HOSTNAMEA to HOSTNAMEB? Should I use dynamic listener registration? how should the configuration look like?
Best Answer
You should have a TNS entry, in the client machine, similar to following to connect to the data guard environment.
You also should have database service configured according to their role-primary or standby as shown below(if you are using Grid Infrastructure).
If you are not using Grid Infrastructure then(AS SYSDBA on Primary)-
Modify the attributes used in the above examples according to your need and refer to the Oracle documentation for details.