Apple iTunes 11.0.5 - iTunes "buy all" button / feature of "My Wishlist" page removed

I am a huge fan of Apple and Apple products until I have observed that Apple is running out of fuel for innovation and its basics. There have been many critics both inside and outside of the wall street showing different pictures of Apple Inc., since Tim Cook took over as the CEO.

Feature rich iPhone and iPad is diminishing year by year with low # of new features introduced. Today Apple frustrated me more. iTunes 11.0.5 was released this week. I am sure millions of us would have updated the software. Guess what ? One of the key feature of iTunes is missing - "buy all" button from your iTunes account wishlist page.

If you have been a user like me who click on "Add to Wishlist" whenever you hear a music, video or books to buy later on, then iTunes 11.0.5 makes you feel that you are stupid. Apple have removed the "buy all" feature. You need to buy each and every thing individually which means, each new song have new invoice/bill.

I tried to chat with Apple iTunes Support, it said the wait time was 2 minutes and it didn't come up even after 12 minutes. I closed it. Next option I tired was let Apple call you. I did get the automated call back in 2 minutes. To get  a human behind the voice, I had to wait 5 minutes. The support lady put me on hold twice as she herself couldn't find the button. She had to check with her supervisor and then another supervisor if anything could be done. Finally the response from the lady was - Sorry the "buy all" feature have been removed with new iTunes. Neither she nor her manager know why it was removed. The lady asked me if she can take my case or concern to the development group. That was nice of her to do (I am not sure if she actually did or was trying to calm a customer). I am told that Apple will not update me if they would consider it to enable the button again or not. She asked me to keep on checking for updated for next few weeks. At least the support lady had patience and was able to listen to the customer frustration.

With 10 invoices for 10 songs; the end user, the credit card company and even Apple itself will have tough time managing the iTunes Store business. I am not sure why Apple has decided to add fancy images and all kinds of junk to the clean and simple iTunes and taking away the useful feature.

Eddy Cue (Apple's senior vice president of Internet Software and Services and reports to CEO Tim Cook), could you please listen to the millions of customers and not take away simplicity and elegance from iTunes?

11g RMAN Duplicate Script/Command with HP DataProtector as MML

These are the scripts to clone an Oracle 11g database using RMAN duplicate command. I use HP DataProtector (7.0) as the Media Management Layer (MML). The backup are written to tape drives. System administrator mounts the tape drives to the test servers.

Assumption:
  • You are cloning the DB to different servers. For example: Source is PROD server, Target is TEST server.
  • The file system structure is same between source and the target.
  • There is catalog database for RMAN repository. Auxiliary is the test/target database. The auxiliary instance should be up in nomount state.
  • Make sure you can do tnsping to catalog and   source/prod database.
  • HP DataProtector libraries are already installed on the target/test servers.
  • The # of channels opened are based on the network, how many tape drives are available for PROD backup and mounted on the test server by system administrator.

Usually I make rman script and save it as [SID]_clone.rman and execute it from the command line.
rman cmdfile=applet_clone.rman log=applet_clone_FEB11.log 

1. SET UNTIL TIME

Here I am trying to restore and recover the database to a certain time. I have cleaned out the target database file system before the script is executed.

Source DB: APPLE
Target/Test DB: APPLET
Oracle Version: 11.2.0.3
OS: HP UX Itanium 11.31

script:
connect auxiliary /
connect catalog APPLE/APPLE@CATLOGDB
run {
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=APPLE,OB2BARLIST=APPLE_DB_3A)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=APPLE,OB2BARLIST=APPLE_DB_3A)';
 duplicate database APPLE to APPLET
 NOFILENAMECHECK
 until time "to_date('2013-07-12 19:00:00','YYYY-MM-DD HH24:MI:SS')"
 pfile=/a01/oracle/db/11.2.0/dbs/initAPPLET.ora
 LOGFILE
   GROUP 10 (
     '/a08/appldata/log10a.dbf',
     '/a11/appldata/log10b.dbf'
   ) SIZE 400M,
   GROUP 11 (
     '/a08/appldata/log11a.dbf',
     '/a11/appldata/log11b.dbf'
   ) SIZE 400M,
   GROUP 12 (
     '/a08/appldata/log12a.dbf',
     '/a11/appldata/log12b.dbf'
   ) SIZE 300M;
   }





2. SET UNTIL SEQUENCE

Here I am trying to restore and recover the database to a certain sequence number . I have cleaned out the target database file system before the script is executed. 

How to get sequence#:
If you know the time, check the alert log of the source database

Source DB: TEX
Target/Test DB: TEXT
Oracle Version: 11.2.0.2
OS: HP UX Itanium 11.31

script:
connect auxiliary /
connect target sys/SYSPASSWORD@TEX
connect catalog TEX/TEX@CATLOGDB
run {
 SET UNTIL SEQUENCE 18394;
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 allocate auxiliary channel 'dev_2' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 duplicate database TEX to TEXT
 NOFILENAMECHECK
 pfile=/t01/oracle/texora/11.2.0/dbs/initTEXT.ora
 LOGFILE
   GROUP 1 ('/t03/texdata/redo01_a.log') SIZE 2048M,
   GROUP 2 ('/t04/texdata/redo02_a.log') SIZE 2048M,
   GROUP 3 ('/t03/texdata/redo03_a.log') SIZE 2048M,
   GROUP 4 ('/t04/texdata/redo04_a.log') SIZE 2048M,
   GROUP 5 ('/t03/texdata/redo05_a.log') SIZE 2048M;
   } 


3.  SET UNTIL SCN:

Here I am trying to restore and recover the database to a certain SCN (System Change Number) . I have cleaned out the target database file system before the script is executed. 

How to get source database SCN#:
If you know the time, run the below SQL in source DB. In this example,  the time is 19-AUG-13 01:03 AM.

SELECT LTRIM(RTRIM(TIMESTAMP_TO_SCN('19-AUG-13 01.03.00 AM'))) FROM DUAL;

or

SELECT LTRIM(RTRIM(TIMESTAMP_TO_SCN(TO_TIMESTAMP('08/19/2013 01:03:00','MM/DD/YYYY HH24:MI:SS')))) AS SCN FROM DUAL;

You can verify it by checking time with SCN value as below:

SELECT SCN_TO_TIMESTAMP(217348050501) AS TIMESTAMP FROM DUAL;

Source DB: AAM
Target/Test DB: AAMT
Oracle Version: 11.2.0.2
OS: HP UX Itanium 11.31 

script:
connect auxiliary /
connect target sys/SYSPASSWORD@AAM
connect catalog AAM/AAM@CATLOGDB
run {
 SET UNTIL SCN 209049958452;
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 allocate auxiliary channel 'dev_2' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 duplicate database AAM to AAMT
 NOFILENAMECHECK
 pfile=/m01/oracle/aamora/11.2.0/dbs/initAAMT.ora
 LOGFILE
   GROUP 1 ('/m03/aamdata/redo01_a.log') SIZE 2048M,
   GROUP 2 ('/m04/aamdata/redo02_a.log') SIZE 2048M,
   GROUP 3 ('/m03/aamdata/redo03_a.log') SIZE 2048M,
   GROUP 4 ('/m04/aamdata/redo04_a.log') SIZE 2048M,
   GROUP 5 ('/m03/aamdata/redo05_a.log') SIZE 2048M;
   }


Note: It is not mandatory to give OB2BARLIST when restore/recover is performed with HP DataProtector. It is ignored internally by the MML i.e,

allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM)';

Reference:
RMAN: Configuring HP Omniback with RMAN (Doc ID 77552.1)
RMAN and Specific Media Managers Environment Variables. (Doc ID 312737.1)

Oracle Database: UTL_FILE_DIR init Parameter validation script

From Oracle 10g and above, Oracle have been encouraging users to use DIRECTORY instead of UTL_FILE_DIR. The new 'DIRECTORY' is very flexible to add, edit and delete than UTL_FILE_DIR. Whenever you want to include a directory structure to the UTL_FILE_DIR parameter a database bounce is required.

Below are couple of scripts to verify that directories listed in utl_file_dir or DIRECTORY_PATH is open to write/read. All these scripts are from Oracle Metalink. Replace the directory path (marked in red) with your value of utl_file_dir directory path or DIRECTORY_NAME.

Script(1):

set serveroutput on
DECLARE
   file_name   VARCHAR2 (256) := 'utlfile.txt';
   file_text   VARCHAR2 (256) := 'Hello World';
   file_id     UTL_FILE.file_type;
BEGIN
   file_id := UTL_FILE.fopen ('/u03/out/fromerp', file_name, 'W');
   UTL_FILE.put_line (file_id, file_text);
   UTL_FILE.fclose (file_id);
EXCEPTION
   WHEN UTL_FILE.INVALID_PATH
   THEN
      DBMS_OUTPUT.put_line ('Invalid path ' || SQLERRM);
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Others ' || SQLCODE || ' ' || SQLERRM);
END;

/


Another Script (2):

Step 1: Create  a test table

create table testtab (c1 number, c2 number);
insert into testtab values (10,25);
insert into testtab values (20,50);
commit;

Step 2: Create the procedute

CREATE OR REPLACE PROCEDURE utl_test1
IS
   file_handle        UTL_FILE.FILE_TYPE;       -- file handle of OS flat file
   col1               NUMBER;               -- C1 retrieved from testtab table
   retrieved_buffer   VARCHAR2 (100);         -- Line retrieved from flat file
BEGIN
   -- Open file to write into  and get it's file_handle
   file_handle :=
      UTL_FILE.FOPEN ('/u03/out/fromerp', 'myfile.txt', 'W');

   -- Write a line of text out to the file.
   UTL_FILE.PUT_LINE (file_handle, 'this is line 1 as a test');

   -- Select the c1 from the testtab table where empno = 7900
   SELECT c1
     INTO col1
     FROM testtab
    WHERE c2 = 25;

   -- Using PUTF write text with the col1 argument out to the file.
   UTL_FILE.PUTF (file_handle,
                  'This is the c1 %s when the c2 is %s.\n',
                  col1,
                  '25');

   -- Close the file.
   UTL_FILE.FCLOSE (file_handle);

   -- Open the same file to read from
   file_handle :=
      UTL_FILE.FOPEN ('/u03/out/fromerp', 'myfile.txt', 'R');

   -- Read a line from the file.
   UTL_FILE.GET_LINE (file_handle, retrieved_buffer);

   -- Print fetched line out to the SQL*PLUS prompt.
   DBMS_OUTPUT.PUT_LINE (retrieved_buffer);

   -- CLose the file.
   UTL_FILE.FCLOSE (file_handle);
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      DBMS_OUTPUT.PUT_LINE ('no_data_found');
      UTL_FILE.FCLOSE (file_handle);
   WHEN UTL_FILE.INVALID_PATH
   THEN
      DBMS_OUTPUT.PUT_LINE ('UTL_FILE.INVALID_PATH');
      UTL_FILE.FCLOSE (file_handle);
   WHEN UTL_FILE.READ_ERROR
   THEN
      DBMS_OUTPUT.PUT_LINE (' UTL_FILE.READ_ERROR');
      UTL_FILE.FCLOSE (file_handle);
   WHEN UTL_FILE.WRITE_ERROR
   THEN
      DBMS_OUTPUT.PUT_LINE ('UTL_FILE.WRITE_ERROR');
      UTL_FILE.FCLOSE (file_handle);
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE ('other stuff');
      UTL_FILE.FCLOSE (file_handle);
END;

/

To execute the above procedure:
set serveroutput on
execute utl_test1

This script also works to test 'DIRECTORY'.

Reference:
Using utl_file, how file permissions are determined, working sample (Doc ID 74268.1)
ORA-29280: invalid directory path' is returned when using spaces within the directory (Doc ID 1063519.6)
UTL_FILE_DIR path test : http://gavinsoorma.com/2009/07/utl_file_dir-path-test/

OS commands to list only the directories in Linux or Unix

Sometimes a folder may contains 1000s of files and few directories and if we want to list only directories within a folder in UNIX and Linux, these commands can become helpful.

ls -l | egrep '^d'




Another easy way to perfom is to create an alias (I prefer this):

alias ldir="ls -l | egrep '^d'"





Another method to list only directory is using find command.

find . -type d

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)