Common Data Guard Broker (DGMGRL) Errors - ORA-16664, ORA-16809, ORA-16714, ORA-16826

Here I am going to discuss some of the common Data guard broker (DGMGRL) errors.

Following are the details of my example
Database Name/Primary/Standby: ORCLPROD
Primary DB Unique Name: ORCLPROD
Standby DB Unique Name: ORCLPRODSTY
Operating System (OS): HP UX Itanium 11.31

Database Version :11.2.0.3 

1. ORA-16664: unable to receive the result from a database

Solution:
This is a very generic error. We should see the respective (standby) database DRC log. The DRC log are location in background_dump_dest (in 10g) or diagnostic_dest (in 11g). Common symptoms are password file issue , local_listener is not set properly or is NULL.

The error can be further debugged by setting an event

event = "16664 trace name errorstack forever, level 3"

When I setup the data guard broker using DGMGRL, the 'ORA-16664'  error turned to"Warning: ORA-16809: multiple warnings detected for the database".

Extract from DRC log (drcORCLPROD.log) :

Site ORCLPRODSTY returned ORA-16664.
Data Guard Broker Status Summary:
  Type                        Name                             Severity  Status
  Configuration               ORCLPROD_primary                   Warning  ORA-16607
  Primary Database            ORCLPROD                           Success  ORA-00000
  Physical Standby Database   ORCLPRODSTY                          Error  ORA-16664
08/01/2013 12:06:38
Data Guard Broker Status Summary:
  Type                        Name                             Severity  Status
  Configuration               ORCLPROD_primary                   Warning  ORA-16608
  Primary Database            ORCLPROD                           Success  ORA-00000
  Physical Standby Database   ORCLPRODSTY                        Warning  ORA-16809
08/01/2013 12:07:39

I have verified the ORA error using DGMGRL CLI as well.

DGMGRL> show configuration;

Configuration - ORCLPROD_primary

  Protection Mode: MaxPerformance
  Databases:
    ORCLPROD    - Primary database
    ORCLPRODSTY - Physical standby database
      Warning: ORA-16809: multiple warnings detected for the database

Fast-Start Failover: DISABLED

Configuration Status:
WARNING

DGMGRL>

2. ORA-16714: the value of property XYZ is inconsistent with the database setting

Solution:
This is also a generic warning and XYZ refers to the different property settings for the database and Data Guard broker You can get additional details within DGMGRL CLI (as shown below) or by DRC logfile.

DGMGRL CLI:

DGMGRL>  SHOW DATABASE 'ORCLPRODSTY';

Database - ORCLPRODSTY

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   0 seconds
  Apply Lag:       15 minutes 17 seconds
  Real Time Query: OFF
  Instance(s):
    ORCLPROD
      Warning: ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting
      Warning: ORA-16714: the value of property LogArchiveMaxProcesses is inconsistent with the database setting
      Warning: ORA-16714: the value of property LogArchiveMinSucceedDest is inconsistent with the database setting
      Warning: ORA-16714: the value of property LogArchiveTrace is inconsistent with the database setting
      Warning: ORA-16714: the value of property LogArchiveFormat is inconsistent with the database setting

  Database Warning(s):
    ORA-16826: apply service state is inconsistent with the DelayMins property

Database Status:
WARNING

DGMGRL> show database 'ORCLPRODSTY' InconsistentProperties
INCONSISTENT PROPERTIES
   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE
         ORCLPROD     ArchiveLagTarget                    0                                         0
         ORCLPROD LogArchiveMaxProcesses                    4                                         4
         ORCLPROD LogArchiveMinSucceedDest                    1                                         1
         ORCLPROD      LogArchiveTrace                    0            (missing)                    0
         ORCLPROD     LogArchiveFormat ORCLPROD_%s_%t_%r.log            (missing) ORCLPROD_%s_%t_%r.log



DRC Logfile:

08/01/2013 12:07:38
Redo Apply is running without USING CURRENT LOGFILE option while DelayMins=0
Warning: Property 'ArchiveLagTarget' has inconsistent values:METADATA='0', SPFILE='', DATABASE='0'
Warning: Property 'LogArchiveMaxProcesses' has inconsistent values:METADATA='4', SPFILE='', DATABASE='4'
Warning: Property 'LogArchiveMinSucceedDest' has inconsistent values:METADATA='1', SPFILE='', DATABASE='1'
SPFILE is missing value for property 'LogArchiveTrace' with sid='ORCLPROD'
Warning: Property 'LogArchiveTrace' has inconsistent values:METADATA='0', SPFILE='(missing)', DATABASE='0'
SPFILE is missing value for property 'LogArchiveFormat' with sid='ORCLPROD'
Warning: Property 'LogArchiveFormat' has inconsistent values:METADATA='ORCLPROD_%s_%t_%r.log', SPFILE='(missing)', DATABASE='ORCLPROD_%s_%t_%r.log'
08/01/2013 12:08:38


You can fix each warning as shown below:

sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Aug 1 12:21:32 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> ALTER SYSTEM SET ARCHIVE_LAG_TARGET=0 SCOPE=BOTH;

System altered.

SQL> show parameter log_archive_max

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_max_processes            integer     4
SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4 SCOPE=BOTH;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_MIN_SUCCEED_DEST=1 SCOPE=BOTH;

System altered.


As you fix parameter values one by one, it gets reflected in DGMGRL CLI. For example I fixed, 3 settings and DGMGRL output is updated.

DGMGRL> show database 'ORCLPRODSTY' InconsistentProperties
INCONSISTENT PROPERTIES
   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE
         ORCLPROD      LogArchiveTrace                    0            (missing)                    0
         ORCLPROD     LogArchiveFormat ORCLPROD_%s_%t_%r.log            (missing) ORCLPROD_%s_%t_%r.log

DGMGRL>



SQL> ALTER SYSTEM SET LOG_ARCHIVE_TRACE=0 scope=both;

To fix LOG_ARCHIVE_FORMAT warning, we need toc reate pfile, make the corresponding changes and bounce the database.


Once all warning/error are fixed DGMGL status becomes SUCCESS

DGMGRL> show configuration;

Configuration - ORCLPROD_primary

  Protection Mode: MaxPerformance
  Databases:
    ORCLPROD    - Primary database
    ORCLPRODSTY - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS


Data Guard Broker Command-Line Interface (DGMGRL) Setup - Oracle 10g and 11g

In this post, I am going to share the details regarding Data Guard Broker. The article is valid for 10g and 11g. There is no difference with 11g DGMGRL configuration, but there are differences to the broker parameters/properties.

For instance, in 10g DGMGRL the parameter  is LocalListenerAddress while in 11g it is replaced with StaticConnectIdentifier.

What is Data Guard Broker?
It is a framework that centralize managing and monitoring of primary and standby database as a single unit. We can switchover and failover with a single commands there by resulting in database role changes. Broker configuration can be managed by Oracle Enterprise Manager (OEM/Grid) or using Command-Line Interface (DGMGRL).

Note:
  • Below is an example of 10g DGMGRL configuration.
  • This example assumes that you have the primary and standby setup complete and logs are being applied. Both Primary and Standby database use SPFILE.

DB_NAME/Primary/Standby Database: APL
Primary DB Unique Name: APL
Primary Hostname: apldb.vaidiyan.com (or vaid2)
Standby DB Unique Name: APLSTY
Standby Hostname: aplsbdb.vaidiyan.com (or vaid1)
OS: HP Unix (UX) Itanium
 Database Flavor: Enterprise Edition

Primary Database(APL):
File System: /p

1. Update the listener.ora file changes on Primary Database ($ORACLE_HOME/network/admin) with static entry for DGMGRL. The GLOBAL_DBNAME parameter must be defined as db_unique_name_DGMGRL.db_domain. This avoids the ORA-12154 error when switchover happens.



APL =
     (DESCRIPTION_LIST =
     (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = apldb.vaidiyan.com)(PORT = 1532))))

SID_LIST_APL =
  (SID_LIST =
     (SID_DESC =
     (GLOBAL_DBNAME= APL_DGMGRL.vaidiyan.com)
     (ORACLE_HOME= /p01/app/oracle/aplora/10.2.0)
     (SID_NAME = APL)
     (SERVICE_NAME=APL)
     )
     (SID_DESC =
     (SID_NAME = PLSExtProc)
     (ORACLE_HOME = /p01/app/oracle/aplora/10.2.0)
     (PROGRAM = extproc)
     )
     )


2. Make sure the tnsnames for Primary and Standby are added to tnsnames.ora ($ORACLE_HOME/network/admin). Test it with tnsping.

vaid2> tnsping APL

TNS Ping Utility for HPUX: Version 10.2.0.3.0 - Production on 06-AUG-2013 17:37:00

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP) (HOST = apldb.vaidiyan.com)(PORT = 1532))) (CONNECT_DATA = (SID = APL)))
OK (0 msec)
vaid2> tnsping APLSTY

TNS Ping Utility for HPUX: Version 10.2.0.3.0 - Production on 06-AUG-2013 17:37:04

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP) (HOST = aplsbdb.vaidiyan.com)(PORT = 1532))) (CONNECT_DATA = (SID = APL)))
OK (0 msec)



3. Enable LOCAL_LISTENER parameter in the database.

Note: This is required if your listener.ora service name is using a non-default port ie. other than 1521. In this example, the database listener port in 1532, it is mandatory to set this parameter.

ALTER SYSTEM SET LOCAL_LISTENER='APL' SCOPE=BOTH;


4. Edit the SPFILE for Dataguard Broker Parameters - DG_BROKER_START and DB_BROKER_CONFIG_FILEn

SQL>show parameter dg

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /p01/app/oracle/aplora/1
                                                 0.2.0/dbs/dr1APL.dat
dg_broker_config_file2               string      /p01/app/oracle/aplora/1
                                                 0.2.0/dbs/dr2APL.dat
dg_broker_start                      boolean     FALSE
SQL>



ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;

You can verify the Data Guard process at OS level by:
vaid2> ps -ef|grep dmon|grep -v grep
         oracle   892     1  0 10:55:09 ?         0:02 ora_dmon_APL
vaid2>


You can also change the DB_BROKER_CONFIG_FILEn parameter from default location -

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1='/p02/app/oracle/aplora/dr1APL.dat' SID='*';

Standby Database (APLSTY)
File System: /s

a. Similar to how we updated the listener.ora on primary database, edit the listener.ora file changes on Standby Database ($ORACLE_HOME/network/admin) with static entry for DGMGRL. The GLOBAL_DBNAME parameter must be defined as _DGMGRL.db_domain.

In the example, both listener names on Primary and Standby are the same as 'APL' but hostname and GLOBAL_DBNAME are different.


APL =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aplsbdb.vaidiyan.com)(PORT = 1532)))
    )

SID_LIST_APL =
  (SID_LIST =
     (SID_DESC =
     (GLOBAL_DBNAME= APLSTY_DGMGRL.vaidiyan.com)
     (ORACLE_HOME= /s01/app/oracle/aplora/10.2.0)
     (SID_NAME = APL)
     (SERVICE_NAME = APLSTY)
     )
     (SID_DESC =
     (SID_NAME = PLSExtProc)
     (ORACLE_HOME = /s01/app/oracle/aplora/10.2.0)
     (PROGRAM = extproc)
    )
    )



b. Add the tnsnames for Primary and Standby are added to tnsnames.ora ($ORACLE_HOME/network/admin). Test it with tnsping.

vaid1> tnsping APL

TNS Ping Utility for HPUX: Version 10.2.0.3.0 - Production on 06-AUG-2013 17:57:44

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP) (HOST = apldb.vaidiyan.com)(PORT = 1532))) (CONNECT_DATA = (SID = APL)))
OK (0 msec)
vaid1> tnsping APLSTY

TNS Ping Utility for HPUX: Version 10.2.0.3.0 - Production on 06-AUG-2013 17:57:47

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP) (HOST = aplsbdb.vaidiyan.com)(PORT = 1532))) (CONNECT_DATA = (SID = APL)))
OK (10 msec)


 c. Enable LOCAL_LISTENER parameter in the database.  I am repeating the reason for this parameter again here. If your listener.ora service name is using a non-default port ie. other than 1521, this is required.

ALTER SYSTEM SET LOCAL_LISTENER='APLSTY' SCOPE=BOTH;

SQL>show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      APLSTY



 d. Add the Dataguard Broker Parameters - DG_BROKER_START and DB_BROKER_CONFIG_FILEn to the SPFILE.

SQL>show parameter dg

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /s01/app/oracle/aplora/1
                                                 0.2.0/dbs/dr1APLSTY.dat
dg_broker_config_file2               string      /s01/app/oracle/aplora/1
                                                 0.2.0/dbs/dr2APLSTY.dat
dg_broker_start                      boolean     FALSE
SQL>


ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;

You can verify the Data Guard process at OS level by:

vaid1> ps -ef|grep dmon|grep -v grep
          oracle 11303     1  0 10:55:06 ?         0:00 ora_dmon_APL
vaid1>



I am using the default location for DB_BROKER_CONFIG_FILEn parameter.

Data Guard Broker Configuration: 

1. Initiate the CLI -  DGMGRL from operating system and connect using the 'SYS' user


> dgmgrl
DGMGRL for HPUX: Version 10.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2005, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/xxxx!yyyy
Connected.
DGMGRL> show configuration
Error: ORA-16532: Data Guard broker configuration does not exist

Configuration details cannot be determined by DGMGRL





2. Create Configuration with Primary Database (APL)


DGMGRL> create configuration 'APL_primary'
> as primary database is 'APL'
> connect identifier is 'APL';

Configuration "APL_primary" created with primary database "APL"
DGMGRL>

DGMGRL> show configuration;

Configuration
  Name:                APL_primary
  Enabled:             NO
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    APL - Primary database

Current status for "APL_primary":
DISABLED

DGMGRL>


Where,
APL_primary: is the name of the configuration.
Primary database is 'APL':  'APL'  is primary database db_unique_name value
Connect identifier is 'APL': 'APL'  is alias name defined in tnsnames.ora to connect to primary database.

3. Add the Standby Database (APLSTY) to the configuration

DGMGRL> ADD DATABASE 'APLSTY' AS CONNECT IDENTIFIER IS 'APLSTY' MAINTAINED AS PHYSICAL;
Database "APLSTY" added
DGMGRL>


DGMGRL> show configuration

Configuration
  Name:                APL_primary
  Enabled:             NO
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    APL    - Primary database
    APLSTY - Physical standby database

Current status for "APL_primary":
DISABLED

DGMGRL>


4. Validate the Database Configuration

Standby Database:

DGMGRL> show database verbose 'APLSTY';

Database
  Name:            APLSTY
  Role:            PHYSICAL STANDBY
  Enabled:         NO
  Intended State:  OFFLINE
  Instance(s):
    APL

  Properties:
    InitialConnectIdentifier        = 'APLSTY'
    LogXptMode                      = 'ASYNC'
    Dependency                      = ''
    DelayMins                       = '0'
    Binding                         = 'OPTIONAL'
    MaxFailure                      = '10'
    MaxConnections                  = '1'
    ReopenSecs                      = '15'
    NetTimeout                      = '30'
    LogShipping                     = 'ON'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyParallel                   = 'AUTO'
    StandbyFileManagement           = 'AUTO'
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '2'
    LogArchiveMinSucceedDest        = '1'
    DbFileNameConvert               = '/p, /s'
    LogFileNameConvert              = '/p, /s'
    FastStartFailoverTarget         = ''
    StatusReport                    = '(monitor)'
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    HostName                        = 'vaid1'
    SidName                         = 'APL'
    LocalListenerAddress            = '(ADDRESS=(PROTOCOL=TCP)(HOST=aplsbdb.vaidiyan.com)(PORT=1532))'
    StandbyArchiveLocation          = '/s02/arch'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = 'APL_%s_%t_%r.log'
    LatestLog                       = '(monitor)'
    TopWaitEvents                   = '(monitor)'

Current status for "APLSTY":
DISABLED

DGMGRL>



Primary Database:

DGMGRL> show database verbose 'APL';

Database
  Name:            APL
  Role:            PRIMARY
  Enabled:         NO
  Intended State:  ONLINE
  Instance(s):
    APL

  Properties:
    InitialConnectIdentifier        = 'APL'
    LogXptMode                      = 'ASYNC'
    Dependency                      = ''
    DelayMins                       = '0'
    Binding                         = 'OPTIONAL'
    MaxFailure                      = '0'
    MaxConnections                  = '1'
    ReopenSecs                      = '300'
    NetTimeout                      = '180'
    LogShipping                     = 'ON'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyParallel                   = 'AUTO'
    StandbyFileManagement           = 'AUTO'
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '2'
    LogArchiveMinSucceedDest        = '1'
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    FastStartFailoverTarget         = ''
    StatusReport                    = '(monitor)'
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    HostName                        = 'vaid2'
    SidName                         = 'APL'
    LocalListenerAddress            = '(ADDRESS=(PROTOCOL=TCP)(HOST=apldb.vaidiyan.com)(PORT=1532))'
    StandbyArchiveLocation          = 'dgsby_APL'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = 'APL_%s_%t_%r.log'
    LatestLog                       = '(monitor)'
    TopWaitEvents                   = '(monitor)'

Current status for "APL":
DISABLED

DGMGRL>


5.  Enable the configuration


DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;

Configuration
  Name:                APL_primary
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    APL    - Primary database
    APLSTY - Physical standby database

Current status for "APL_primary":
Warning: ORA-16610: command 'EDIT DATABASE APLSTY SET PROPERTY' in progress


If you receive  "Warning: ORA-16610" error, Please give Data Guard broker few minutes to complete the setup and try again.

DGMGRL> show configuration;

Configuration
  Name:                APL_primary
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    APL    - Primary database
    APLSTY - Physical standby database

Current status for "APL_primary":
SUCCESS

DGMGRL>



Now confirm that logs are being transported between primary and standby databases by querying 'V$ARCHIVED_LOG'. Also check for errors in Primary and Standby alert.log located at the background_dump_dest (or $BDUMP). In 11g, the alert log is in diagnostic_dest.

There is Data Guard Broker log file (drcSID.log)which is also located where alert_SID.log is.

Reference:
DGMGRL takes default port if configuration is not set properly (Doc ID 735758.1) 
ORA-16664 ORA-16792 Data guard Broker (Doc ID 1228797.1)
11.2 Data Guard Physical Standby Switchover Best Practices using the Broker (Doc ID 1305019.1)

Oracle 11g: Data Guard Physical Standby Database Setup Guide using RMAN Duplicate

What is DataGuard:
Data Guard is term associated with Oracle standby database (DB) thereby ensuring high availability, data protection and disaster recovery. This technology is used for many OLTP systems and other databases based on the significance and how it affects the business. 

I will go through few terms first before going forward with an example setup.

Terminology
Primary Database: Also called production database.
Standby Database: It is a consistent copy of the primary DB. You can have upto 9 standby DBs for a primary. A standby database can be either a physical standby database or a logical standby database.
Physical Standby: It is a physically identical copy to primary DB (in short block-on-block) on disk. Changes from primary are synched with standby using Redo-Apply method.
Logical Standby: This standby DB have the same data(logical information) as in primary but the physical structure can be different. The DB is kept current using SQL Apply method.
Switchover: During a switchover, the primary database transitions to a standby role, and the standby database transitions to the primary role (in short roles are reversed). This is typically part of planned maintenance of the primary system.
Failover: Failover happens only in the event of a disaster or failure of the primary database, and the failover results in a transition of a standby database to the primary role.It can happen if the primary database server crashes or geographic disasters.

Dataguard Protection Mode/Level:
Maximum Protection: Zero loss of data. The redo of the primary have to be written to local online redo log and standby redo log before the transaction are saved. To ensure no data loss, primary DB shuts down if a fault prevents access to standby redo log.
Maximum Performance: Default mode. This allows transaction on primary to be saved if redo information are written to local online redo log.The primary redo data stream also writes to standby redo log but asynchronously to the local redo log.
Maximum Availability: This mode behaves as Maximum Protection mode. The redo transaction have to be written to both local online redo log and standby redo log but it doesn't shutdown primary database in case of any fault. During the at fault scenarios, it is changed to Maximum Performance mode until the fault is corrected and all the redo gaps are fixed. Once fixed, it automatically changes to Maximum Availability.

Below I am sharing step by step details to build a Maximum Performance DataGuard.

Note: 
  • It is easier if the primary DB uses SPFILE instead of PFILE.
  • Please do understand that DB_NAME of Primary and Standby are same, but the DB_UNIQUE_NAME will be different 
Database Name/Primary/Standby: ORCL
Primary DB Unique Name: ORCL
Standby DB Unique Name: ORCLSTY
Size of the DB: 300 GB
Operating System (OS): HP UX Itanium 11.31

Primary Database(ORCL):
File System: /p

1. Make sure the DB is in archive log mode.

SELECT LOG_MODE FROM V$DATABASE;

or ARCHIVE LOG LIST

If the DB is in "NOARCHIVELOG" mode, please perform the following:

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;

2. Primary DB must have forced logging

SELECT FORCE_LOGGING FROM V$DATABASE;

If DB is not, run the below command:

ALTER DATABASE FORCE LOGGING;

3. Make sure the DB Name and DB Unique Name are set.

SYS@ORCL SQL> SHOW PARAMETER DB_NAME

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      ORCL
SYS@ORCL SQL>SHOW PARAMETER DB_UNIQUE_NAME

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      ORCL

4. Use DB_UNIQUE_NAME to configure LOG_ARCHIVE_CONFIG

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL,ORCLSTY)' scope=both;


5. Set the Log information on the primary


ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/p04/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCL' scope=both;

If you receive the following error:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16019: cannot use LOG_ARCHIVE_DEST_1 with LOG_ARCHIVE_DEST or
LOG_ARCHIVE_DUPLEX_DEST

Solution:
SYS@ORCL SQL>show parameter LOG_ARCHIVE_DEST

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest                     string      /p04/arch
log_archive_dest_1                   string
log_archive_dest_10                  string
..
..

Run the following -
SYS@ORCLSQL>ALTER SYSTEM set log_archive_dest='' scope=both;

System altered.

SYS@ORCLSQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/p04/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCL' scope=both;

System altered.

ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;

Make a note of SERVICE Name and DB_UNIQUE_NAME.


ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=ORCLSTY LGWR ASYNC=20480 OPTIONAL REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLSTY' scope=both;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;

6. Set the *CONVERT parameters if primary and standby are on different file system. My standby is on /s file system while primary is on /p. Also set the FAL_SERVER and FAL_CLIENT parameter. This parameter is to make primary ready to switch roles.

ALTER SYSTEM SET FAL_SERVER=ORCLSTY scope=both;
ALTER SYSTEM SET FAL_CLIENT=ORCL scope=both;

Please note that for changing *CONVERT parameter 'scope=both' doesnt work. It has to be 'scope=spfile'.

ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/s','/p' scope=spfile;
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/s','/p' scope=spfile;

I also added DB_ULTRA_SAFE=DATA_AND_INDEX . The parameter control protection levels. This is not mandatory. This parameter can be changed only using PFILE.

ALTER SYSTEM SET DB_ULTRA_SAFE=DATA_AND_INDEX scope=both;
ALTER SYSTEM SET DB_ULTRA_SAFE=DATA_AND_INDEX scope=both
                 *
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM


ALTER SYSTEM SET DB_ULTRA_SAFE=DATA_AND_INDEX scope=spfile;
ALTER SYSTEM SET DB_ULTRA_SAFE=DATA_AND_INDEX scope=spfile
                 *
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM

 


7. Add Standby redo log
It's a good ideology to match the online redo log configuration of the primary server.

My primary database have 3 groups with 1 log member each of 100M, so I started with GROUP 5. It is important that you have an extra standby redo log member than the online redo log. Here I added two groups more than the online redo log.

ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/p02/redo/styredo_05a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/p03/redo/styredo_06a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/p02/redo/styredo_07a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 8 ('/p03/redo/styredo_08a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 9 ('/p02/redo/styredo_09a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;

ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO scope=both;

8.  Make sure the autehntication is exclusive and password file is created.

ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;

orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password='xxxx!yyyy' entries=10 force=y

I used quotes for password as I have a special character in the password.

9. Create Standby Control file and pfile- This is not mandatory step.

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/orclsty.ctl';

It is easier to modify the pfile created from primary spfile for the standby

CREATE PFILE='/p01/app/oracle/orcldb/11.2.0/dbs/initORCLSTY.ora' from spfile;

10. Add tns details for primary and secondary $ORACLE_HOME/network/admin/tnsnames.ora.
Please note the difference in hostnames.

ORCL=
      (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)
    (HOST = orcldb.vaidiyan.com)
        (PORT = 1521)))
    (CONNECT_DATA =
    (SID = ORCL)))

ORCLSTY=
      (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)
      (HOST = orclstydb.vaidiyan.com)
        (PORT = 1521)))
      (CONNECT_DATA =
      (SID = ORCL)))

Perform tnsping test.

Standby Database(ORCLSTY):
File system : /s

a. Copy the pfile (created on step  9) , password file (from step 8) to $ORACLE_HOME/dbs on the standby server.

You can use scp or rcp to move files across hosts.

b. Add the tns entries for primary and standby to $ORACLE_HOME/network/admin/tnsnames.ora on the standby server

ORCL =
        (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
    (HOST = orcldb.vaidiyan.com)
    (PORT = 1521)))
        (CONNECT_DATA =
        (SID = ORCL)
        ))

ORCLSTY =
        (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)
        (HOST = orclstydb.vaidiyan.com)
    (PORT = 1521)))
        (CONNECT_DATA =
        (SID = ORCL)
        ))

c. Open the pfile copied from primary and change the path of adump, diagnostic_dest, control_file from /p to /s. Make sure no reference to the primary file system (/p) exist in the pfile, replace everything with '/s)

The archive location on standby server is /s04, Also note the change in db_unique_name from that of primary.

*.log_archive_dest_1='LOCATION=/s04/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCLSTY'

*.log_archive_dest_2='SERVICE=ORCL LGWR ASYNC NOAFFIRM OPTIONAL MAX_CONNECTIONS=1 REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL'

*.fal_client='ORCLSTY'
*.fal_server='ORCL'

d. This is KEY that db_unique_name initialization parameter is changed to 'orclsty' and FAL_SERVER I also made sure DB_ULTRA_SAFE is set to the pfile.

db_unique_name=ORCLSTY
DB_ULTRA_SAFE=DATA_AND_INDEX

e. Start the listener on the standby server. My listener name is ORCL on primary and standby

lsnrctl start ORCL

Perform tnsping test.

f. Start the standby DB in nomount state using the pfile

SQL> startup nomount pfile=/s01/app/oracle/orcldb/11.2.0/dbs/initORCL.ora

Verify the db_unique_name and make sure you do NOT use spfile. If you use SPFILE or create SPFILE from pfile on the standby database, the following RMAN DUPLICATE step would throw error.

SQL> show parameter db_unique

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      ORCLSTY

g. If you already have a standby DB (from EMC snapshot technology) copy, then you do not need to perform RMAN DUPLICATE steps. But you need to add the standby redo log files on the Standby Database.

Note that I used the same script as Primary but changed the file system from /p to /s. The redologs must be added when the standby database is in mount state.

ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/s02/redo/styredo_05a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/s03/redo/styredo_06a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/s02/redo/styredo_07a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 8 ('/s03/redo/styredo_08a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 9 ('/s02/redo/styredo_09a.dbf') SIZE 100M BLOCKSIZE 1024 REUSE; 



RMAN DUPLICATE (Building Standby Database):
I have used RMAN duplicate from active database instead of full backup as the connection between the two host is 10G LAN and the size of the database is small (NOT in Terabyte). You can also build standby using full primary database backup to disk/tape.

During this step auxiliary database is the standby database.

1. Verify RMAN connectivity

rman

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 31 16:53:36 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target sys@ORCL

target database Password:
connected to target database: ORCL (DBID=1080107045)

RMAN> connect auxiliary sys@ORCLSTY

auxiliary database Password:
connected to auxiliary database: ORCL (not mounted)

RMAN>

2. I created a RMAN DUPLICATE script (orcl_standby.rman)  with the following commands and executed from command line.

connect AUXILIARY sys/xxxx!yyyy@ORCLSTY
connect TARGET sys/xxxx!yyyy@ORCL
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='ORCLSTY' COMMENT "Is a duplicate standby"
SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL LGWR ASYNC NOAFFIRM OPTIONAL MAX_CONNECTIONS=1 REOPEN=15 MAX_FAILURE=10 NET_TIMEOUT=30 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL'
SET diagnostic_dest='/s01/app/oracle/orcldb'
SET control_files='/s05/orcldata/cntrl01.dbf','/s05/orcldata/cntrl02.dbf','/s06/orcldata/cntrl03.dbf'
SET FAL_CLIENT='ORCLSTY' COMMENT "Is standby"
SET FAL_SERVER='ORCL' COMMENT "Is primary"
SET LOG_FILE_NAME_CONVERT='/p','/s'
SET DB_FILE_NAME_CONVERT='/p','/s'
NOFILENAMECHECK;

How to run the rman script from command line:

rman cmdfile=orcl_standby.rman log=orcl_standby_0731.log

3. Once the RMAN Duplicate is complete, Make sure the LOG_ARCHIVE_DEST* parameter is appropriate.

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL LGWR ASYNC NOAFFIRM DELAY=0 OPTIONAL COMPRESSION=DISABLE MAX_FAILURE=10 MAX_CONNECTIONS=1 REOPEN=15 DB_UNIQUE_NAME=ORCL NET_TIMEOUT=30 VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE)' scope=both;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/s04/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCLSTY' scope=both;

4. Shutdown down the standby database  and start up in mount state.

 SHUTDOWN IMMEDIATE;
 STARTUP NOMOUNT;
 ALTER DATABASE MOUNT STANDBY DATABASE;

Start Applying the Logs:

There are two ways to do it:
  • Automatic recovery of standby
         ALTER DATABASE RECOVER AUTOMATIC STANDBY DATABASE;
  • Foreground redo apply, where control is not returned 
          ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
  • Background redo apply, control is returned to the system but the apply process continues.
          ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

          OR

          ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT; 

For 10g Database, the command is :
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

If you need to cancel the apply process, execute the following command:


           ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Verify the Standby Database (ORCLSTY) DataGuard mode:

SQL> SELECT PROTECTION_MODE, PROTECTION_LEVEL, DATABASE_ROLE, SWITCHOVER_STATUS  FROM V$DATABASE;

PROTECTION_MODE      PROTECTION_LEVEL     DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- -------------------- ---------------- --------------------
MAXIMUM PERFORMANCE  MAXIMUM PERFORMANCE  PHYSICAL STANDBY NOT ALLOWED
SQL> select DATABASE_ROLE from V$DATABASE;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

Transport Redo Transport Verification SQL/Script:

On the Primary Database (ORCL), Run the below script:

SELECT sequence#, first_time, next_time
FROM   v$archived_log
ORDER BY sequence#;

ALTER SYSTEM SWITCH LOGFILE;

On the Standby Database (ORCLSTY), verify that the log are applied using the SQL:

SELECT sequence#, first_time, next_time, applied
FROM   v$archived_log
ORDER BY sequence#; 

OR

SELECT thread#,max(sequence#) FROM V$ARCHIVED_LOG where applied ='YES' group by thread#;

Reference:
Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE (Doc ID 1075908.1)

Top must have iPhone and iPad free apps for 2013

Everyone from age 2 and up knows what is an iPhone and iPad. There are tons of paid and unpaid apps in the App Store. This article list the apps for Apple but I am sure that the almost all the apps are available at the GooglePlay Store.

1. Evernote: Awesome app with limited free space. Once you create a new note or update an existing note, it syncs across. Very clean and highly productive app. Other similar application are One note from Microsoft.

2. Google Maps: Wonderful point-to-point direction tool. This is very updated and user friendly. Other similar apps are Apple Maps (which is built-in), MapQuest . Other navigation apps Waze and Trapster brings add on feature.

3. YouTube: There are tons of streaming video website. YouTube still rules because of the clean look and popularity. Other notable apps are VEVO HD, Crackle.

4. Flixster: Why I like it? Because I love movies. The app is supported by the celebrated movie ratings website - Rotten Tomatoes. This app gives information about current releases, reviews, upcoming movie information, nearest movie location (you have to turn on Location Services), DVDs releases. Other comparable apps are IMDb,  Apple's Trailers.

5. Shazam: If you love music, you will love this app. Imagine you are at a dance club and listen to DJ and want to know what song it is and the artist. This is the app for you. This app helps you to track the song you are listening and instantly take you to iTunes Store or Amazon or GooglePlay to purchase it if you are interested.

5. Facebook/ Twitter/ Pinterest/ Path/ Instagram/ LinkedIn: I am clubbing all the social networking app together. Today you are hesitant to say hello to a person walking by but always open to poke someone on these social media platforms. There is nothing to rank about these apps, it is each of your preference, ease of use and privacy policies. Just a caution that: Anything you tag or do a page like will soon be an advertisement on your homepage.

6. iBooks: Apple is still lacking with the number of books online with Amazon but I love the simplicity of iBooks. Other well-known apps include Kindle, Audible, GoodReads.

7. Pandora/ iHeartRadio: These are the darling apps of the housewives, long working days of husbands, teenage kids.

8. Yelp: This app is a huge aid for travelers. In this mini google, you can find events, popular restaurants, comedy club almost everything with rating. Other similar apps are AroundMe.

9. MyFitnessPal: This app are for those who want to track of their food intake. For a healthy living the amount and the type of food you have plays a significant role. It inspires you to a better living.

10. Score: This prime app is favorite among men. Whenever your wife have to take you with her for a shopping or hold on the home television, you got no better option than Score. Other similar apps include ESPN, CBS SPORTS. If you like NBA there is NBA GameTime app, NFL Mobile for NFL, Yahoo Sports, NHL.

11. Walmart/Target/Amazon/Dick's: These department store apps are great to check for an item in stock, near by location, working hours, reviews and ratings.

12. Walgreen/CVS: Another chain store apps for our needs - Pharmacy. You never know when you need an Advil or DayQuil. These apps would give availability info, location, store hours.

13. Find iPhone: This app is very helpful to track where your phone is. You can track is on web as well as on other Apple Products like iPad.

14. Banking Apps: Similar to social network apps, I am clubbing all the finance apps like Chase, American Express, Wells Fargo and so on. Now a days, multiple banks are offering mobile deposits, mobile receipts and many other features.
 

Oracle RMAN 11g: SQL queries against Catalog Database for backup info

With this blog I am sharing the queries that I use in my environment to gather details about database backup, backup sets. The queries can be executed on the target as well as catalog databases but there are difference in view name.

If you do not use a catalog database(which I highly recommend) and all information are storied in control file, you can use the SQL for target database to find the information. Note: Make sure the DB is in mount state.

For a newbie, 
Target: It is usually the PROD database or the database of which we need to take backup of.
Catalog: This is normal Oracle database where the backup metadata are stored. If you are not using catalog database, the same information can be storied in the Target's controlfile

In target, you can connect as sys as sysdba to run the SQL. In the Catalog Database, connect using the catalog schema.

Query the details for a single archive log:


Target :

select r.sequence#,r.set_stamp,p.handle,p.tag,p.start_time,p.completion_time,r.first_change#,r.next_change#
from V$BACKUP_PIECE p, V$BACKUP_REDOLOG r
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and r.sequence# = 743399;

Here the archive log # that I am checking is 743399.

Catalog DB:

select r.sequence#,r.set_stamp,p.handle,p.tag,p.start_time,p.completion_time,r.first_change#,r.next_change#
from RC_BACKUP_PIECE p, RC_BACKUP_REDOLOG r
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and r.sequence# = 743399;

Find last archive log backed up:

Target:

select r.sequence#,r.set_stamp,p.handle,p.tag,p.start_time,p.completion_time,r.first_change#,r.next_change#
from V$BACKUP_PIECE p, V$BACKUP_REDOLOG r
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
order by sequence# desc;

Catalog DB:

select r.sequence#,r.set_stamp,p.handle,p.tag,p.start_time,p.completion_time,r.first_change#,r.next_change#
from RC_BACKUP_PIECE p, RC_BACKUP_REDOLOG r
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
order by sequence# desc;

Backup Job Details:

Target:

select session_key,input_type,status, to_char(start_time,'yyyy-mm-dd hh24:mi') start_time,to_char(end_time,'yyyy-mm-dd hh24:mi') end_time,output_bytes_display,time_taken_display
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key desc;


Catalog DB:

select session_key,input_type,status, to_char(start_time,'yyyy-mm-dd hh24:mi') start_time,to_char(end_time,'yyyy-mm-dd hh24:mi') end_time,output_bytes_display,time_taken_display
from RC_RMAN_BACKUP_JOB_DETAILS
order by session_key desc;


You can get all these information by standard RMAN commands like LIST, REPORT. All the commands have been tested in Oracle 11g (11.2.0.3).