Wednesday, January 9, 2019

Data Guard on OCI PaaS DB

Oracle has introduced the data guard capability for DBs created with VM shape types. There's an earlier post which shows how to setup a data guard configuration with PaaS DB primary and standby created on IaaS resources (compute instances + block storages). This post looks at new capability introduced for VM shapes on PaaS DBs.
The data guard created on PaaS will have both primary and standby on same region but in a different availability domain, unlike in the previous post where standby and primary were on separate regions. Therefore before creating the data guard association for an existing database create a subnet on the availability domain that will be used for standby. AD1Subnet and AD2Subnets are created for this purpose where AD1 will be used for primary and AD2 will be used for standby.
Network traffic must flow freely between the two subnets on port 1521 (or the port used for listener). Add the security rule to the VCN security list.
These two are the only new things to concern about before creating the primary DB. Once the primary DB is created enable data guard on the primary DB.
This will open the DB system information form to be filled with information for standby system. Once details are submitted the standby system will provisioned.
A red shield icon will be displayed next to the DB that has a data guard association.
At the end of the provisioning a data guard configuration will be created which would also include a DG broker setup. The default setup will be maximum performance mode with async redo transport mode.
DGMGRL> show configuration

Configuration - fraDB_fra1h8_fraDB_fra27c

  Protection Mode: MaxPerformance
  Members:
  fraDB_fra1h8 - Primary database
    fraDB_fra27c - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 37 seconds ago)

DGMGRL> show database fraDB_fra1h8

Database - fraDB_fra1h8

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

Database Status:
SUCCESS
The standby will be in mount mode not open for read only.
DGMGRL> show database fraDB_fra27c

Database - fraDB_fra27c

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 6 seconds ago)
  Apply Lag:          0 seconds (computed 6 seconds ago)
  Average Apply Rate: 3.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    fraDB

Database Status:
SUCCESS
Verbose output for database configuration is given at the end.


Automatic backup could be enabled in both primary and standby. However, only the primary DB at the time will execute the backup. Backups will start running on the (old) standby after a role change when it becomes the (new) primary. The DB in standby mode will not execute a backup and as such there will be no backup failures logged on standby unlike previous post.

Switchover could be performed using DGB as before.
DGMGRL> show configuration

Configuration - fraDB_fra1h8_fraDB_fra27c

  Protection Mode: MaxPerformance
  Members:
  fraDB_fra1h8 - Primary database
    fraDB_fra27c - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 27 seconds ago)

DGMGRL> validate database fraDB_fra27c

  Database Role:     Physical standby database
  Primary Database:  fraDB_fra1h8

  Ready for Switchover:  Yes
  Ready for Failover:    Yes (Primary Running)

  Managed by Clusterware:
    fraDB_fra1h8:  YES
    fraDB_fra27c:  YES

  Standby Apply-Related Information:
    Apply State:      Running
    Apply Lag:        1 second (computed 10 seconds ago)
    Apply Delay:      0 minutes

  Log Files Cleared:
    fraDB_fra1h8 Standby Redo Log Files:  Cleared
    fraDB_fra27c Online Redo Log Files:   Not Cleared
    fraDB_fra27c Standby Redo Log Files:  Available


DGMGRL> switchover to fraDB_fra27c;
Performing switchover NOW, please wait...
Operation requires a connection to database "fraDB_fra27c"
Connecting ...
Connected to "fraDB_fra27c"
Connected as SYSDBA.
New primary database "fraDB_fra27c" is opening...
Oracle Clusterware is restarting database "fraDB_fra1h8" ...
Connected to "fraDB_fra1h8"
Connected to "fraDB_fra1h8"
Switchover succeeded, new primary is "fradb_fra27c"
DGMGRL> show configuration

Configuration - fraDB_fra1h8_fraDB_fra27c

  Protection Mode: MaxPerformance
  Members:
  fraDB_fra27c - Primary database
    fraDB_fra1h8 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 15 seconds ago)

DGMGRL> switchover to fraDB_fra1h8
Performing switchover NOW, please wait...
Operation requires a connection to database "fraDB_fra1h8"
Connecting ...
Connected to "fraDB_fra1h8"
Connected as SYSDBA.
New primary database "fraDB_fra1h8" is opening...
Oracle Clusterware is restarting database "fraDB_fra27c" ...
Switchover succeeded, new primary is "fradb_fra1h8"
DGMGRL> show configuration

Configuration - fraDB_fra1h8_fraDB_fra27c

  Protection Mode: MaxPerformance
  Members:
  fraDB_fra1h8 - Primary database
    fraDB_fra27c - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 28 seconds ago)
The switchover and failover could also be done on cloud console. However, at the time of the post, the role reversal is not reflected correclty on the peer role. But the operations listed for the DB are valid for that role. Below it shows switchover and reinstate options for primary DB, even though peer role is listed as standby.
On the other-hand on standby it only gives failover as the option but the peer role is listed as primary.
Even though the default protection mode is maximum performance, this could be changed after setting the redo transport mode compatible with the protection mode begin set.
Update 2021/03/30 As of this update, only maximum performance is supported in OCI DBCS for VMs. Though protection mode could be changed manually as below this won't be supported by Oracle.
DGMGRL> edit database fraDB_fra27c set property LogXptMode='SYNC';
Property "logxptmode" updated
DGMGRL> edit database fraDB_fra1h8 set property LogXptMode='SYNC';
Property "logxptmode" updated

DGMGRL> edit configuration set protection mode as maxavailability;
Succeeded.

DGMGRL> show configuration

Configuration - fraDB_fra1h8_fraDB_fra27c

  Protection Mode: MaxAvailability
  Members:
  fraDB_fra27c - Primary database
    fraDB_fra1h8 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 22 seconds ago)
Finally the patch applying could be done in a standby first manner.

When a DB system is dropped, the associated DG configuration is also removed at the same time.

Related Post
Data Guard With OCI PaaS DB (DBaaS) Primary and Standby on IaaS



DG Broker verbose output for databases.
DGMGRL> show database verbose fraDB_fra1h8

Database - fraDB_fra1h8

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

  Properties:
    DGConnectIdentifier             = 'fraDB_fra1h8'
    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          = '8'
    LogArchiveMinSucceedDest        = '1'
    DataGuardSyncLatency            = '0'
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    FastStartFailoverTarget         = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    PreferredObserverHosts          = ''
    HostName                        = 'fravm'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fravm)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=fraDB_fra1h8_DGMGRL.ad1subnet.fravcn.oraclevcn.com)(INSTANCE_NAME=fraDB)(SERVER=DEDICATED)))'
    OnlineArchiveLocation           = 'LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY REOPEN=0'
    OnlineAlternateLocation         = ''
    StandbyArchiveLocation          = 'LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY REOPEN=0'
    StandbyAlternateLocation        = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'
    SidName                         = '(monitor)'

  Log file locations:
    Alert log               : /u01/app/oracle/diag/rdbms/fradb_fra1h8/fraDB/trace/alert_fraDB.log
    Data Guard Broker log   : /u01/app/oracle/diag/rdbms/fradb_fra1h8/fraDB/trace/drcfraDB.log

Database Status:
SUCCESS

DGMGRL> show database verbose fraDB_fra27c

Database - fraDB_fra27c

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 5 seconds ago)
  Apply Lag:          0 seconds (computed 5 seconds ago)
  Average Apply Rate: 3.00 KByte/s
  Active Apply Rate:  0 Byte/s
  Maximum Apply Rate: 0 Byte/s
  Real Time Query:    OFF
  Instance(s):
    fraDB

  Properties:
    DGConnectIdentifier             = 'fraDB_fra27c'
    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          = '8'
    LogArchiveMinSucceedDest        = '1'
    DataGuardSyncLatency            = '0'
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    FastStartFailoverTarget         = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    PreferredObserverHosts          = ''
    HostName                        = 'fravmst'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fravmst)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=fraDB_fra27c_DGMGRL.ad2subnet.fravcn.oraclevcn.com)(INSTANCE_NAME=fraDB)(SERVER=DEDICATED)))'
    OnlineArchiveLocation           = 'LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY REOPEN=0'
    OnlineAlternateLocation         = ''
    StandbyArchiveLocation          = 'LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY REOPEN=0'
    StandbyAlternateLocation        = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'
    SidName                         = '(monitor)'

  Log file locations:
    Alert log               : /u01/app/oracle/diag/rdbms/fradb_fra27c/fraDB/trace/alert_fraDB.log
    Data Guard Broker log   : /u01/app/oracle/diag/rdbms/fradb_fra27c/fraDB/trace/drcfraDB.log

Database Status:
SUCCESS