How to build Oracle 19c R2 standby database using Data Guard?
Version-1.2 | Last updated Date: 07/24/2020
Table of Contents
Part-1: Technical Steps On Primary Database Server: 2
Part-2: Technical Steps On Standby Database Server: 12
Part-3: Open up PRIMARY and STANDBY database ALERT LOG 20
Part-5: Changing Data Guard Protection Modes 29
Part-6: Data Broker Troubleshooting Commands 34
Part-7: Errors and troubleshooting 34
Task:
The task is to create a database called MOIDDGDB in the primary data center (in FLcago) and then build a standby database in the Disaster Recovery Data Center (in New York). Below you can find more details:
Primary | Standby | |
Data Center Location | FLcago | New York |
Hostname | Server-243 | Server-233 |
Short Hostname | FL | ny |
IP Address | 192.168.0.223 | 192.168.0.233 |
Listener Name | LISTENER | LISTENER |
Listener Port | 1521 | 1521 |
Database Name | MOIDDGDB | MOIDDGDB |
DB Unique Name | MOIDDGDB_FL | MOIDDGDB_NY |
Part-1: Technical Steps On Primary Database Server:
No. | Description | Command / Details / Screenshots | |
1.1 | Connect to Primary Database Server |
| |
1.2 | Create a new database called MOIDDGDB |
| |
1.3 | Create a script called db role to check the role of the database | vi /tmp/dbrole.sql i → to go insert mode
ESC :wq! | |
1.4 | Verify Primary database is OPEN |
| |
1.5 | Verify Primary Server and to be Standby Server are in-network and reachable from PRIMARY Server. |
| |
1.6 | Verify Database is in Archivelog mode. |
| |
1.7 | Enable Force Logging. This is to ensure changes are logged into redo logs. |
| |
1.8 | Verify force logging is enabled. |
| |
1.9 | Set the standby file management to auto. This will ensure all datafiles get to create on standby when they are created on primary. |
| |
1.10 | Change db unique name. |
| |
1.11 | Add standby redo logs
| ||
1.12 | Verify all redo and log files are created. | set linesize 200; set pagesize 200; col member format a40; break on type skip 1; Select group#, type, member from v$logfile order by 2,1; | |
1.13 | Shutdown database and exit out of SQL. |
| |
1.14 | Add DB_UNIQUE_NAME entry in oratab | cat >> /etc/oratab << EOF MOIDDGDB_FL:/u01/app/oracle/product/19.3.0/dbhome_1:N EOF | |
1.15 | Copy spfile to new instance spfile. |
| |
1.16 | Startup instance using db_unique_name |
| |
1.17 | Create password file |
| |
1.18 | Create a directory for database backup. |
| |
1.19 | Configure RMAN for backups |
| |
1.20 | Add connection entries for Primary and Standby database in tnsnames.ora file. | cd $ORACLE_HOME/network/admin cat >> tnsnames.ora << EOF MOIDDGDB_FL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = FL)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = MOIDDGDB_FL) ) ) MOIDDGDB_NY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = NY)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = MOIDDGDB_NY) ) ) EOF | |
1.21 | Verify both connection strings are pingable |
| |
1.22 | Backup listener.ora file |
| |
1.23 | Add the SID_DESC for primary database. Add another SID_DESC for data broker. Note: Add only the RED and GREEN part in listener.ora file from → | vi listener.ora
| |
1.24 | Reload Listener |
| |
1.25 | Verify if the static services are registered in the listener |
|
Part-2: Technical Steps On Standby Database Server:
No. | Description | Command / Details / Screenshots | |
2.1 | Connect to Standby Database Server |
| |
2.2 | Verify Primary and Standby are in network and reachable from STANDBY Database Server. |
| |
2.3 | Add db_name and db_unique_name entries in oratab file. | cat >> /etc/oratab << EOF MOIDDGDB:/u01/app/oracle/product/19c/dbhome_1:N MOIDDGDB_NY:/u01/app/oracle/product/19c/dbhome_1:N EOF | |
2.4 | Create directories for database related files. |
| |
2.5 | Set oracle environment for standby database |
| |
2.6 | Add connection entries for Primary and Standby database in tnsnames.ora file. | cd $ORACLE_HOME/network/admin cat >> tnsnames.ora << EOF MOIDDGDB_FL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = FL)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = MOIDDGDB_FL) ) ) MOIDDGDB_NY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = NY)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = MOIDDGDB_NY) ) ) EOF | |
2.7 | Verify both connection strings are pingable |
| |
2.8 | Backup listener.ora file |
| |
2.9 | Add the SID_DESC for primary database. Add another SID_DESC for data broker. Note: Add only the RED and GREEN part in listener.ora file from → |
| |
2.10 | Reload Listener |
| |
2.11 | Verify if the static services are registered in listener |
| |
2.12 | Copy password file from PRIMARY to STANDBY |
| |
2.13 | Copy dbrole.sql from PRIMARY |
| |
2.14 | Create a temporary init.ora file to start STANDBY database |
| |
2.15 | Verify temporary init.ora is created | ls -ltrh /tmp/init$ORACLE_SID.ora | |
2.16 | Startup the standby instance |
| |
2.17 | Using RMAN, connect to target (Primary) and auxiliary (standby) database. ~This is done in Target Database~ |
| |
2.18 | Start duplicating database from RMAN. | DUPLICATE TARGET DATABASE exit; | |
2.19 | Verify STANDBY database is created and in mount mode while database role is set to “Physical Standby” |
|
Part-3: Open up PRIMARY and STANDBY database ALERT LOG
3.1 | Now open up two putty sessions to keep an eye on both alert logs. Once this is done, we will be switFLng the database role where standby will become primary and primary will become standby | On FLcago Server:
On NY Server:
|
3.2 | Check the status of database_role on primary and standby databases. | On FLcago Server:
On NY Server:
|
Part-4: Setup Data Broker
No. | Description | Command / Details / Screenshots |
4.1 | Start Data Broker on Primary |
|
4.2 | Start Data Broker on Standby |
|
4.3 | Connect to data broker. |
|
4.4 | Create configuration to add primary. | CREATE CONFIGURATION MOIDDGDB_configuration AS PRIMARY DATABASE IS MOIDDGDB_FL CONNECT IDENTIFIER IS MOIDDGDB_FL; |
4.5 | Add standby to broker configuration | ADD DATABASE MOIDDGDB_NY AS CONNECT IDENTIFIER IS MOIDDGDB_NY MAINTAINED AS PHYSICAL; |
4.6 | Enable configuration | enable configuration; |
4.7 | Exit out of broker to perform few log switches. |
|
4.8 | Perform a log switch |
|
4.9 | Login to broker and check the configuration |
|
4.10 | Let us check the properties of PRIMARY Database |
|
4.11 | Let us check the properties of STANDBY Database |
|
4.12 | Check detailed database properties of PRIMARY DATABASE | DGMGRL> show database verbose MOIDDGDB_FL Database - MOIDDGDB_FL Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): MOIDDGDB_FL Properties: DGConnectIdentifier = 'MOIDDGDB_FL' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' RedoRoutes = '' DelayMins = '0' Binding = 'optional' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyLagThreshold = '30' TransportLagThreshold = '30' TransportDisconnectedThreshold = '30' ApplyParallel = 'AUTO' ApplyInstances = '0' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DataGuardSyncLatency = '0' DbFileNameConvert = '' LogFileNameConvert = '' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' PreferredObserverHosts = '' StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Server-243)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MOIDDGDB_FL_DGMGRL)(INSTANCE_NAME=MOIDDGDB_FL)(SERVER=DEDICATED)))' StandbyArchiveLocation = '/u99/MOIDDGDB/Archive' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'arch_%t_%s_%r.arc' TopWaitEvents = '(monitor)' Log file locations: Alert log : /u01/app/oracle/diag/rdbms/MOIDDGDB_FL/MOIDDGDB_FL/trace/alert_MOIDDGDB_FL.log Data Guard Broker log : /u01/app/oracle/diag/rdbms/MOIDDGDB_FL/MOIDDGDB_FL/trace/drcMOIDDGDB_FL.log Database Status: SUCCESS DGMGRL> |
4.13 | Check detailed database properties of STANDBY DATABASE | DGMGRL> show database verbose MOIDDGDB_NY Database - MOIDDGDB_NY Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Average Apply Rate: 6.00 KByte/s Active Apply Rate: 351.00 KByte/s Maximum Apply Rate: 371.00 KByte/s Real Time Query: OFF Instance(s): MOIDDGDB_NY Properties: DGConnectIdentifier = 'MOIDDGDB_NY' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' RedoRoutes = '' DelayMins = '0' Binding = 'optional' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyLagThreshold = '30' TransportLagThreshold = '30' TransportDisconnectedThreshold = '30' ApplyParallel = 'AUTO' ApplyInstances = '0' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DataGuardSyncLatency = '0' DbFileNameConvert = '' LogFileNameConvert = '' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' PreferredObserverHosts = '' StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=server-233)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MOIDDGDB_NY_DGMGRL)(INSTANCE_NAME=MOIDDGDB_NY)(SERVER=DEDICATED)))' StandbyArchiveLocation = '/u99/MOIDDGDB/Archive' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'arch_%t_%s_%r.arc' TopWaitEvents = '(monitor)' Log file locations: Alert log : /u01/app/oracle/diag/rdbms/MOIDDGDB_NY/MOIDDGDB_NY/trace/alert_MOIDDGDB_NY.log Data Guard Broker log : /u01/app/oracle/diag/rdbms/MOIDDGDB_NY/MOIDDGDB_NY/trace/drcMOIDDGDB_NY.log Database Status: SUCCESS DGMGRL> |
4.14 | Keep an eye on both database alert log files and lets perform a switchover. |
|
4.15 | Have you been watFLng alert log? Anything changed in there while database were switFLng its role? What is the output of the following SQL on both databases? SQL> @/tmp/dbrole.sql Did MOIDDGDB_FL became standby and did MOIDDGDB_NY became primary? |
Part-5: Changing Data Guard Protection Modes
While keeping an eye on alert log, lets change Data Guard protection modes.
5.1 | Connect to Data Broker |
|
5.2 | For: Maximum Performance Mode | DGMGRL>
PRIMARY SQL> @/tmp/dbrole.sql STANDBY SQL> @/tmp/dbrole.sql |
5.3 | For: Maximum Availability Mode | DGMGRL>
PRIMARY SQL> @/tmp/dbrole.sql STANDBY SQL> @/tmp/dbrole.sql |
5.4 | For: Maximum Protection Mode | DGMGRL>
PRIMARY SQL> @/tmp/dbrole.sql STANDBY SQL> @/tmp/dbrole.sql |
Part-6: Data Broker Troubleshooting Commands
ALTER SYSTEM SET dg_broker_start=true; show parameter dg_broker_start | ||
dgmgrl sys/abc123@MOIDDGDB_FL | ||
CREATE CONFIGURATION MOIDDGDB_configuration AS PRIMARY DATABASE IS MOIDDGDB_FL CONNECT IDENTIFIER IS MOIDDGDB_FL; | ||
ADD DATABASE MOIDDGDB_NY AS CONNECT IDENTIFIER IS MOIDDGDB_NY MAINTAINED AS PHYSICAL; | ||
show configuration | ||
show database MOIDDGDB_FL | ||
show database verbose MOIDDGDB_FL | ||
edit configuration set protection mode as Maxperformance; edit configuration set protection mode as MaxAvailability; edit configuration set protection mode as MaxProtection; | ||
switchover to MOIDDGDB_FL | ||
show database 'MOIDDGDB_FL' InconsistentProperties | ||
Part-7: Errors and troubleshooting
No. | Problem | Resolution |
7.1 | DGMGRL> show configuration Configuration - MOIDDGDB_configuration Protection Mode: MaxPerformance Members: MOIDDGDB_NY - Primary database MOIDDGDB_FL - Physical standby database Warning: ORA-16809: multiple warnings detected for the member | DGMGRL> show database MOIDDGDB_FL |
7.2 | ORA-16854: apply lag could not be determined | Check if standby is up Check if redo apply is running “ ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;” |
Hope this helps.
Moid Muhammad