Tuesday, June 30, 2015

How to Install Oracle's 12c Cloud Control

Installation Guide for 12c Cloud Control

--##################################################
-- ORACLE ENTERPRISE MANAGER CONFIGURATION SIZES
--##################################################

SIZE AGENT COUNT TARGET COUNT CONCURRENT USER SESSIONS

SMALL < 100 < 1000 <10

--#########################################################
-- ORACLE ENTERPRISE MANAGER MINIMUM HARDWARE REQUIREMENTS
--#########################################################

SIZE SMALL
OMS MACHINE COUNT* 1
CORES PER OMS 2
MEMORY PER OMS(GB) 6
STORAGE PER OMS(GB) 15
CORES PER DATABASE MACHINE 2
MEMORY PER DATABASE MACHINE (GB) 6
DATABASE MACHINE COUNT* 1

--#################################################################
-- ORACLE ENTERPRISE MANAGER MINIMUM DATABASE STORAGE REQUIREMENTS
--#################################################################

SIZE MGMT_TABLESPACE (GB) MGMT_ECM_DEPOT_TS (GB) TEMP (GB) ARCHIVE LOG AREA (GB)

SMALL 50 1 10 25

--################################################
-- SMALL CONFIGURATION MINIMUM DATABASE SETTINGS
--################################################

PARAMETER MINIMUM VALUE

Processes 300
pga_aggregate_target* 1024 MB
sga_target* 2 GB
redo log file size 300 MB
shared_pool_size 600 MB


--######################################################
-- Package Requirements for Oracle Management Service
--######################################################

Identifying the Installed Packages

Check the maintenance level using the following command:

$ oslevel -r
7100-03

IBM AIX 7.1

bos.adt.base(0.0)
bos.adt.lib(0.0)
bos.adt.libm(0.0)
bos.perf.libperfstat(0.0)
bos.perf.perfstat(0.0)
bos.perf.proctools(0.0)
rsct.basic.rte(0.0)
rsct.compat.clients.rte(0.0)
xlC.aix61.rte.(9.0.0.0)
xlC.rte.(9.0.0.0)

--Verify that the required packages are installed.

$ lslpp -l bos.adt.base bos.adt.lib bos.adt.libm bos.perf.libperfstat bos.perf.perfstat bos.perf.proctools rsct.basic.rte rsct.compat.clients.rte xlC.aix61.rte xlC.rte

  Fileset                      Level  State      Description
  ----------------------------------------------------------------------------
Path: /usr/lib/objrepos
  bos.adt.base              7.1.3.15  COMMITTED  Base Application Development
                                                 Toolkit
  bos.adt.lib               7.1.2.15  COMMITTED  Base Application Development
                                                 Libraries
  bos.adt.libm               7.1.3.0  COMMITTED  Base Application Development
                                                 Math Library
  bos.perf.libperfstat      7.1.3.15  COMMITTED  Performance Statistics Library
                                                 Interface
  bos.perf.perfstat         7.1.3.15  COMMITTED  Performance Statistics
                                                 Interface
  bos.perf.proctools        7.1.3.15  COMMITTED  Proc Filesystem Tools
  rsct.basic.rte             3.1.5.3  COMMITTED  RSCT Basic Function
  rsct.compat.clients.rte    3.1.5.0  COMMITTED  RSCT Event Management Client
                                                 Function
  xlC.aix61.rte             12.1.0.1  COMMITTED  IBM XL C++ Runtime for AIX 6.1
                                                 and 7.1
  xlC.rte                   12.1.0.1  COMMITTED  IBM XL C++ Runtime for AIX

Path: /etc/objrepos
  bos.adt.base              7.1.3.15  COMMITTED  Base Application Development
                                                 Toolkit
  bos.perf.libperfstat      7.1.3.15  COMMITTED  Performance Statistics Library
                                                 Interface
  bos.perf.perfstat         7.1.3.15  COMMITTED  Performance Statistics
                                                 Interface
  rsct.basic.rte             3.1.5.3  COMMITTED  RSCT Basic Function
$

--####################################################################################################################
-- Package Requirements for Oracle Management Agent (The same packages as the Oracle Management Service are required)
--####################################################################################################################

$ oslevel -r
7100-03

IBM AIX 7.1

bos.adt.base(0.0)
bos.adt.lib(0.0)
bos.adt.libm(0.0)
bos.perf.libperfstat(0.0)
bos.perf.perfstat(0.0)
bos.perf.proctools(0.0)
rsct.basic.rte(0.0)
rsct.compat.clients.rte(0.0)
xlC.aix61.rte.(9.0.0.0)
xlC.rte.(9.0.0.0)

$ lslpp -l bos.adt.base bos.adt.lib bos.adt.libm bos.perf.libperfstat bos.perf.perfstat bos.perf.proctools rsct.basic.rte rsct.compat.clients.rte xlC.aix61.rte xlC.rte

--###############################
-- Kernel Parameter Requirements
--###############################

Verifying UDP and TCP Kernel Parameters

Set TCP/IP ephemeral port range parameters to provide enough ephemeral ports for the anticipated server workload. Ensure that the lower range is set to at least 11,000 or higher, to avoid Well Known 
ports, and to avoid ports in the Registered Ports range commonly used by Oracle and other server ports.

Set the port range high enough to avoid reserved ports for any applications you may intend to use. If the lower value of the range you have is greater than 11,000, and the range is large enough for your
anticipated workload, then you can ignore OUI warnings regarding the ephemeral port range.

For example, with IPv4, use the following command to check your current range for ephemeral ports:

$ cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000

In the preceding example, the lowest port (32768) and the highest port (61000) are set to the default range.

If necessary, update the UDP and TCP ephemeral port range to a range high enough for anticipated system workloads, and to ensure that the ephemeral port range starts at 11,000 and above.

For example:

# echo 11000 65500 > /proc/sys/net/ipv4/ip_local_port_range

--############################################
-- Setting Up kernel.shmmax Kernel Parameter
--############################################

To set the value for kernel.shmmax parameter, do the following:

1.  Log in as root.

2.  Open the /etc/sysctl.conf file.

3.  Set the kernel.shmmax parameter to 4294967295.

    By setting the value in the /etc/sysctl.conf file, the value persists even when you restart the system.

--#################################################################################
-- Creating Operating System Groups and Users for Enterprise Manager Cloud Control
--#################################################################################

$ id oracle

If the oracle user exists, then the output from this command looks like this:

uid=440(oracle) gid=200(oinstall) groups=201(dba),202(oper)


--#################################################################################
-- Creating middleware home and agent base directories
--#################################################################################

Create the middleware home

mkdir /u01/app/Oracle/Middleware/

Create the agent base directory 

mkdir /u01/app/Oracle/agent12c


--##################################################
-- Configuring Oracle Software Owner Environment
--##################################################

--Start CYGWIN

startxwin
xhost +
export DISPLAY=10.10.10.10:0.0 (DISPLAY = The IP Address of your local PC not the server you're running the scirpt.)


--############################
-- UMASK Value Requirements
--############################

Ensure that you set the default file mode creation mask (umask) to 022 in the shell startup file.

Bourne or Korn Shell

$ . ./.profile


--##################################################
-- CLASSPATH Environment Variable Requirements
--##################################################

Unset the CLASSPATH environment variable. You can always reset the variable to the original value after the installation is complete.



--#########################################
-- File Descriptor Requirements
--######################################### 

• Ensure that the maximum user process limit is set to 13312 or greater. However, do not set it to unlimited.

  To verify the current value that is set, run the following command:

  ulimit -u

  To verify whether it is set to unlimited, run the following command. If it is set to unlimited, the output will be unlimited.

  ulimit -n

  If the current value is not set to 13312 or greater, or if it is set to unlimited, then contact your system administrator to correct it.

• Ensure that you set the soft limit of the file descriptor to a minimum of 4096 and the hard limit to less then or equal to 16384.

  To verify the current value set, run the following commands:

  For Soft Limit:

  /bin/sh -c "ulimit -n"

  For Hard Limit:

  /bin/sh -c "ulimit -Hn"

  If the current value is not 4096 or greater, then as a root user, update the /etc/security/limits.conf file with the following entries:

  <UID> soft nofile 4096

  <UID> hard nofile 16384


--#########################################
-- Host File Requirements 
--#########################################

Ensure that the host name specified in the /etc/hosts file is unique, and ensure that it maps to the correct host name or IP address of that host. Otherwise, the installation can fail on the product-specific prerequisite check page.


--########################
-- Port Requirements
--########################

Ensure that the ports you assign (within the given range) to the following components are free and available:

• Admin Server HTTP SSL Port = 7101 - 7200
• Enterprise Manager Upload HTTP Port = 4889 - 4898
• Enterprise Manager Upload HTTP SSL Port = 1159, 4899 - 4908
• Enterprise Manager Central Console HTTP Port = 7788 - 7798
• Enterprise Manager Central Console HTTP SSL Port = 7799 - 7809
• Oracle Management Agent Port = 3872, 1830 - 1849
• Node Manager HTTP SSL Port = 7401 - 7500
• Managed Server HTTP Port = 7201 - 7300
• Managed Server HTTPS Port = 7301 - 7400

To verify if a port is free, run the following command:

• On Unix:

netstat -an | grep <port no>


--#############################################################################################
-- 6.6 Installing an Enterprise Manager System for a Production Site (Advanced Configuration)
--#############################################################################################


http://docs.oracle.com/cd/E24628_01/install.121/e22624/install_em_exist_db.htm#EMBSC166


--#####################################################################
-- Useful links and documentation for Enterprise Manager Cloud Control
--#####################################################################

Meeting Hardware Requirements for Enterprise Manager Cloud Control
http://docs.oracle.com/cd/E24628_01/install.121/e22624/preinstall_req_hw.htm#EMBSC121

Creating a Database Instance with Preconfigured Repository Using Database Templates
http://docs.oracle.com/cd/E24628_01/install.121/e22624/appdx_seed_db_template.htm#EMBSC242

Oracle Enterprise Manager Cloud Control Documentation 12c Release 4
http://docs.oracle.com/cd/E24628_01/index.htm

Enterprise Manager 12c Cloud Control Sizing Guidelines
http://www.oracle.com/technetwork/oem/framework-infra/em12c-sizing-1590739.pdf

Sample OEM 12C CLOUD CONTROL INSTALLATION - Advanced Option 
http://www.askmlabs.com/2014/03/oem-12c-cloud-control-installation.html

How to reset the Password for ASMSNMP user in an ASM instance

Here we will see 2 methods to achieve it:

--#########################################
--# 1)  Using Alter User Command
--#########################################

$ export ORACLE_SID=+ASM
$ . oraenv
$ sqlplus / as sysasm

SQL> Alter user asmsnmp identified by <password>;
User altered.

--###############################################################################
--# 2)  Using ASMCMD Prompt. In a clusted environmet this method would update the password on all nodes in the cluster.
--###############################################################################

We can modify the password for ASMSNMP user using asmcmd command "orapwusr"

orapwusr --modify --password asmsnmp


[oracle@host01 ~]$ asmcmd -p
ASMCMD [+] > lspwusr
Username sysdba sysoper sysasm
     SYS   TRUE    TRUE   TRUE
 ASMSNMP   TRUE   FALSE  FALSE
ASMCMD [+] >

ASMCMD [+] > orapwusr --modify --password asmsnmp
Enter password: **********
ASMCMD [+] >

RMAN Commands

LIST Command

LIST BACKUP; #List all your backup sets.
LIST BACKUPSET; #Lists only backup sets and proxy copies.
LIST COPY; #Lists of Image copies and Archive Logs.
LIST EXPIRED BACKUP; #Backups did not found after crosscheck. That is backup is manually moved or deleted from OS.
LIST EXPIRED BACKUPSET;
LIST RECOVERABLE BACKUPSET;
LIST BACKUP BY FILE; #List backup by Datafile, controlfile, spfile.
LIST BACKUP SUMMARY; #Lists backup sets, proxy copies, and disk copies.
LIST BACKUP OF DATABASE; LIST BACKUP LIKE '/tmp/%'; list backup of datafile 1;
LIST ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
LIST COPY OF DATAFILE 2 COMPLETED BETWEEN '17-MAR-2008' AND '22-MAR-2008'; are also available.
LIST INCARNATION; LIST INCARNATION OF DATABASE; to see the incarnations of your database.

ADVICE FAILURE;

REPORT Command

REPORT NEED BACKUP; # Determine which database files need backup under a specific retention policy. #
REPORT UNRECOVERABLE; #Report which database files require backup because they have been affected by some NOLOGGING operation.
REPORT SCHEMA; #Lists and displays information about the database files.
REPORT OBSOLETE; #REPORT OBSOLETE displays the backups that are obsolete according to the current retention policy
REPORT NEED BACKUP RECOVERY WINDOW OF 2 DAYS DATABASE SKIP TABLESPACE data01;
REPORT SCHEMA AT TIME 'SYSDATE-1';

DELETE Command

DELETE BACKUPSET ALL; - Delete all Backup setDELETE COPY ALL; -Delete all image copies
DELETE OBSOLETE; -Delete obsolete Backups
BACKUP ARCHIVELOG ALL DELETE ALL INPUT;
DELETE ARCHIVELOG ALL BACKED UP 1 TIMES TO DEVICE TYPE SBT_TAPE;

CROSSCHECK Command

CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE EXPIRED BACKUP;
DELETE EXPIRED ARCHIVELOG ALL

Expired and Obselete difference -

DELETE removes the physical files from the backup media, deletes the record of the backup from the recovery catalog
(if RMAN is connected to a recovery catalog), and updates the records of these backups in the control file to status DELETED.
in the obsolete case, what helps to clarify the difference between OBSOLETE and EXPIRED is the retention policy.
If a backup item is no longer needed for recovery because it is older than the retention policy
then it is obsolete.

What does DELETE OBSOLETE do?
The RMAN DELETE command supports an OBSOLETE option, which deletes backups that are obsolete, that is, no longer
needed to satisfy specified recoverability requirements. You can delete files obsolete according to the configured
default retention policy, or another retention policy that you specify as an option to the DELETE OBSOLETE command.
As with other forms of the DELETE command, the files deleted are removed from backup media, deleted from the recovery
catalog, and marked as DELETED in the control file.

The next clarification concerns the EXPIRED status. How does an object become expired?
When the CROSSCHECK command is used to determine whether backups recorded in the repository still exist on disk or tape,
if RMAN cannot locate the backups, then it updates their records in the RMAN repository to EXPIRED status. You can then
use the DELETE EXPIRED command to remove records of expired backups from the RMAN repository. If the expired files still
exist, then the DELETE EXPIRED command terminates with an error.

Delete Backup from Disk

ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET;
CROSSCHECK COPY;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED BACKUP DEVICE TYPE DISK;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL DEVICE TYPE DISK

Delete Backup from TAPE

ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE SBT;
CROSSCHECK BACKUP; CROSSCHECK COPY;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED BACKUP DEVICE TYPE SBT;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL DEVICE TYPE SBT;

COMPRESSED BACKUP

BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG DELETE INPUT;

RECOVER SYSTEM DATAFILE

1. startup mount;
2. restore datafile 1;
3. recover datafile 1;
4. alter database open;

RECOVER DATAFILE

1. restore datafile 4;
2. recover datafile 4;
3. sql 'alter tablespace users online' ;

RECOVER CONTROL FILE

1. SET DBID $v_dbid;
2. STARTUP NOMOUNT;
3. RESTORE CONTROLFILE FROM AUTOBACKUP;
4. ALTER DATABASE MOUNT;
5. RECOVER DATABASE;
6. ALTER DATABASE OPEN RESETLOGS;

COMPLETE RECOVERY

1. SET DBID $v_dbid;
2. STARTUP NOMOUNT;
3. RESTORE SPFILE FROM AUTOBACKUP ;
4. STARTUP FORCE NOMOUNT;
5. RESTORE CONTROLFILE FROM AUTOBACKUP;
6. ALTER DATABASE MOUNT;

run { set until sequence $v_seq thread 1;
restore database;
recover database; }
ALTER DATABASE OPEN RESETLOGS;


ENABLE BLOCK TRACKING

CTWR background process is wrting to Change block tracking File at OS level..Not implemented in Our environment
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '+fradg';

select FILENAME, STATUS, BYTES from v$block_change_tracking;


PRINT GLOBAL SCRIPTS

RMAN> print global script level0_sapr01_backup;

printing stored global script: level0_sapr01_backup
{set command id to 'rman_sapr01_incrlevel0';
delete noprompt backup completed before 'sysdate-6';
delete noprompt archivelog all completed before 'sysdate-3';
crosscheck backup; crosscheck archivelog all;
backup as compressed backupset incremental level 0 TAG = SAPR01_LEVEL0 database plus archivelog;
report obsolete; delete noprompt backup completed before 'sysdate-6';
report need backup database; resync catalog;}

WINDOWS TO SCHEDULE BACKUP

rman_level0_sapr01_dailybackup.cmd which contains=
c:\oracle\product\10.2.0\db_1\bin\RMAN TARGET sys/alta02sys@sapr01
CATALOG rc/alta0racle@rc
CMDFILE=
CMDFILE=C:\oracle_scripts\sapr01\rman_sapr01_backup\rman_level0_sapr01_backup.rcv LOG=C:\oracle_scripts\sapr01\rman_sapr01_backup\rman_level0_sapr01_backup.log append
rman_level0_sapr01_backup.rcv contains
RUN {EXECUTE GLOBAL SCRIPT level0_sapr01_backup;}

Steps to recover database

RMAN target=/

RMAN> SET DBID 669001291; ### it'is part of the name of autobackup file. So if autobackup file name is 'c-669001291-20070129-03' then DBID is669001291

RMAN> startup force nomount;
and run recovery of SPFILE
RMAN> RESTORE SPFILE FROM AUTOBACKUP;
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
RMAN> STARTUP FORCE NOMOUNT:
RMAN> LIST BACKUP SUMMARY;
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
363 B F A SBT_TAPE 28/09/2011 19:39:04 1 1 NO TAG20110928T193859
368 B A X SBT_TAPE 29/09/2011 12:10:43 1 1 YES TAG20110929T120531
387 B A X SBT_TAPE 29/09/2011 12:56:42 1 1 YES TAG20110929T125641
388 B A X SBT_TAPE 29/09/2011 12:56:42 1 1 YES TAG20110929T125641
390 B F X SBT_TAPE 29/09/2011 13:22:11 1 1 NO TAG20110929T132206
RMAN> LIST BACKUP SET 390;
List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
390 Full 14.25M SBT_TAPE 00:00:05 29/09/2011 13:22:11 
BP Key: 5105 Status: EXPIRED Compressed: NO Tag: TAG20110929T132206 
Handle: BILIVE.c-3181441601-20110929-01.oraclebi1.controlfile Media: 000327L3 
Control File Included: Ckp SCN: 16039296565 Ckp time: 18/10/2011 20:51:29 
SPFILE Included: Modification time: 26/09/2011 07:00:04 
SPFILE db_unique_name: ABC 
RMAN> RUN { SET UNTIL SCN 16039296565 
RESTORE DATABASE: 
RECOVER DATABASE:} 
RMAN> ALTER DATABASE OPEN RESTLOGS;

RECOVER SP FILE

1. SET DBID $v_dbid; rman < set DBID=12345;
2. STARTUP NOMOUNT FORCE;
3. RESTORE SPFILE FROM AUTOBACKUP; or RESTORE SPFILE FROM 'PATH_OF_BACKUP'

Saturday, June 27, 2015

How to setup Active Dataguard and Dataguard Broker

Primary Database : TIGGER
 DBNAME : TIGGER
 DB UNIQUE NAME : TIGGER
 Instances : TIGGER on dgprm.racattack
 Oracle Home: /u01/app/oracle/product/12.1.0/dbhome_1
 GRID Homes:  /u01/app/oracle/product/12.1.0/grid

Standby Database : TIGGER_STBY
 DBNAME : TIGGER
 DB UNIQUE NAME : TIGGER_STBY
 Instances : TIGGER on dgstby.racattack
 Oracle Home: /u01/app/oracle/product/12.1.0/dbhome_1
 GRID Homes:  /u01/app/oracle/product/12.1.0/grid


--*************************************************
-- Information about Primary Database:
--*************************************************

set linesize 1000
column host_name format a15
select host_name, instance_name, INSTANCE_ROLE, archiver, version, status, database_status  from v$instance
/

HOST_NAME       INSTANCE_NAME    INSTANCE_ROLE      ARCHIVE VERSION           STATUS       DATABASE_STATUS
--------------- ---------------- ------------------ ------- ----------------- ------------ -----------------
dgprm.racattack tigger           PRIMARY_INSTANCE   STOPPED 12.1.0.1.0        OPEN         ACTIVE


select name, db_unique_name, log_mode, force_logging, database_role from v$database;

NAME      DB_UNIQUE_NAME                 LOG_MODE     FORCE_LOGGING                           DATABASE_ROLE
--------- ------------------------------ ------------ --------------------------------------- ----------------
TIGGER    tigger                         NOARCHIVELOG NO                                      PRIMARY


select name from v$controlfile;

NAME
------------------------------------------------------------
+DATA/TIGGER/CONTROLFILE/current.261.856706525
+FRA/TIGGER/CONTROLFILE/current.256.856706525

select name from v$datafile;

NAME
------------------------------------------------------------
+DATA/TIGGER/DATAFILE/system.258.856706425
+DATA/TIGGER/DATAFILE/sysaux.257.856706319
+DATA/TIGGER/DATAFILE/undotbs1.260.856706491
+DATA/TIGGER/DATAFILE/users.259.856706489

select member from v$logfile;

MEMBER
------------------------------------------------------------
+DATA/TIGGER/ONLINELOG/group_3.264.856706541
+FRA/TIGGER/ONLINELOG/group_3.259.856706545
+DATA/TIGGER/ONLINELOG/group_2.263.856706535
+FRA/TIGGER/ONLINELOG/group_2.258.856706539
+DATA/TIGGER/ONLINELOG/group_1.262.856706531
+FRA/TIGGER/ONLINELOG/group_1.257.856706533

SQL> show parameter broker

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
connection_brokers                   string      ((TYPE=DEDICATED)(BROKERS=1)),((TYPE=EMON)(BROKERS=1))
dg_broker_config_file1               string      /u01/app/oracle/product/12.1.0/dbhome_1/dbs/dr1tigger.dat
dg_broker_config_file2               string      /u01/app/oracle/product/12.1.0/dbhome_1/dbs/dr2tigger.dat
dg_broker_start                      boolean     FALSE


--*************************************************
-- 1. On the primary database enable force logging:
--*************************************************

SQL> alter database force logging;

You can confirm this by following query

SQL> select force_logging from V$DATABASE;

FOR
---
YES

--*************************************************
-- 2. Verify Archivelog Mode is enabled:
--*************************************************

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     52309
Next log sequence to archive   52310
Current log sequence           52310

SQL>

shutdown immediate;
startup mount
alter database archivelog
alter database open

--********************************************************************************
-- 3. Copy the Password File from the Primary database to all of the Standby nodes
--********************************************************************************

$ cd /u01/app/oracle/product/12.1.0/dbhome_1/dbs/
$ scp orapwtigger oracle@dgstby:/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwtigger

--********************************************************************
-- 4. Modify Dataguard related init Parameters on Primary
--********************************************************************

DB_NAME=TIGGER
DB_UNIQUE_NAME=TIGGER
LOG_ARCHIVE_CONFIG='DG_CONFIG=(TIGGER,TIGGER_STBY)'
LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=TIGGER'
LOG_ARCHIVE_DEST_2='SERVICE=TIGGER_STBY ARCH VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TIGGER_STBY'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=8
FAL_SERVER=TIGGER_STBY
DB_FILE_NAME_CONVERT='TIGGER_STBY','TIGGER'
LOG_FILE_NAME_CONVERT= 'TIGGER_STBY','TIGGER'
STANDBY_FILE_MANAGEMENT=AUTO

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(TIGGER,TIGGER_STBY)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=TIGGER' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=TIGGER_STBY ARCH VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TIGGER_STBY' scope=both sid='*'; --- If your enabling the dataguard broker don't set this paramerter. The broker configuration does that for you. Verify the configuration afterwards.
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server='TIGGER_STBY' scope=both sid='*';
alter system set db_file_name_convert='TIGGER_STBY','TIGGER' scope=spfile sid='*';
alter system set log_file_name_convert='TIGGER_STBY','TIGGER' scope=spfile sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';

Verify that the values are set correctly for these parameters after bouncing the database.

set linesize 1000 pages 0
col value for a100
col name for a70

select name, value
from v$parameter
where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2',
               'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile',
               'log_archive_format','log_archive_max_processes','fal_server','db_file_name_convert',
                     'log_file_name_convert', 'standby_file_management')
/

--********************************************************************
-- 5. Configure Listeners on each site Primary and Standby
--********************************************************************

SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
     (GLOBAL_DBNAME=TIGGER_DGMGRL)
     (ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
     (SID_NAME=tigger)
    )
  )

SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
     (GLOBAL_DBNAME=TIGGER_STBY_DGMGRL)
     (ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
     (SID_NAME=tigger)
    )
  )



--********************************************************************
-- 6. Configure Oracle Networking on both Primary and Standby Nodes
--********************************************************************

TIGGER_DGMGRL =
(DESCRIPTION_LIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgprm)(PORT = 1521))
    (CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = TIGGER_DGMGRL)))
)

TIGGER_STBY_DGMGRL =
(DESCRIPTION_LIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgstby)(PORT = 1521))
    (CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = TIGGER_STBY_DGMGRL)))
)



--***************************
-- 6.1 Check DB connectivity
--***************************

Check that you are able to connect to database using tnsnames.ora entries

tnsping TIGGER_DGMRL

sqlplus sys@TIGGER as sysdba

Standby Site:

Add an oratab entry to make sure you have a SID to set the environment variables.

tigger:/u01/app/oracle/product/12.1.0/dbhome_1:N:             # line added by Agent

tnsping TIGGER_DGMGRL

sqlplus sys/racattack@TIGGER_DGMGRL as sysdba

sqlplus sys/racattack@TIGGER_STBY_DGMGRL as sysdba


--********************************************************************
-- 7. Duplicate the primary database to the standby site
--********************************************************************

--Please Note: Execute the duplicate from active database command from the Standby site to pull the files over the network.

--Create the adump directory first before running the rman duplicate command. If you don't the rman command will fail.
mkdir /u01/app/oracle/admin/tigger_stby/adump

Force the startup of a “Dummy” instance

rman target /
RMAN> startup nomount force
RMAN> exit

Connect to the target and auxiliary

$ rman target sys@TIGGER_DGMGRL auxiliary sys@TIGGER_STBY_DGMGRL

Perform the Active Duplicate using RMAN

RMAN> 

duplicate target database for standby from active database
spfile
parameter_value_convert 'tigger','tigger_stby'
set db_unique_name='tigger_stby'
set db_file_name_convert='tigger','tigger_stby'
set log_file_name_convert='tigger','tigger_stby'
set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=TIGGER_STBY'
set LOG_ARCHIVE_DEST_2='SERVICE=TIGGER_DGMGRL ARCH VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TIGGER' --- If your enabling the dataguard broker don't set this paramerter. The broker configuration does that for you. Verify the configuration afterwards.
set control_files='+DATA/TIGGER_STBY/CONTROLFILE/control01.ctl','+FRA/TIGGER_STBY/CONTROLFILE/control01.ctl'
set standby_file_management='AUTO'
set db_recovery_file_dest='+FRA'
set FAL_SERVER='TIGGER_DGMGRL'
set log_archive_max_processes='8'
set audit_file_dest='/u01/app/oracle/admin/tigger_stby/adump';

--*****************************************************************************************************************
-- 8.  Create standby redo logs on the primary and standby database that are the same size of the online redo logs. 
--*****************************************************************************************************************

Oracle recommends having the same number plus one additional standby redo log for each thread. 

For example: Minimum of (threads)*(groups Per Threads + 1) 

(3)*(2 + 1) = 9 Redo Logs

You can check the number and group numbers of the redo logs by querying the V$LOG view:
SQL> SELECT * FROM V$LOG;
You can check the results of the previous statements by querying the V$STANDBY_LOG view:
SQL> SELECT * FROM V$STANDBY_LOG;
You can also see the members created by querying the V$LOGFILE view:
SQL> SELECT * FROM V$LOGFILE;

SQL> select max (bytes)/1024/1024, count (1) from v$log;


    GROUP# BYTES/1024/1024
---------- ---------------
         1             250
         2             250
         3             250
         4             250
         5             250
         6             250

6 rows selected.

alter database add standby logfile size 52428800;
alter database add standby logfile size 52428800;
alter database add standby logfile size 52428800;
alter database add standby logfile size 52428800;

--*********************************************************
-- 9 Startup Active Dataguard from the Standby Database
--*********************************************************

SQL> startup mount
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> select status,instance_name, database_role,open_mode from v$database, v$instance;

STATUS       INSTANCE_NAME    DATABASE_ROLE    OPEN_MODE
------------ ---------------- ---------------- --------------------
OPEN         tigger           PHYSICAL STANDBY READ ONLY

SQL> alter database recover managed standby database disconnect from session;

SQL> select process,status,sequence# from v$managed_standby;

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CLOSING              27
ARCH      CLOSING              28
ARCH      CONNECTED             0
ARCH      CONNECTED             0
RFS       IDLE                  0
RFS       IDLE                  0
RFS       IDLE                  0

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
MRP0      WAIT_FOR_LOG         29

--*************************************************************************************
-- Do some log switches from the Primary database an confirm the results on both sides.
--*************************************************************************************

alter system switch logfile;

--*********************************************************
-- 10 Shutdown Active Dataguard from the Standby Database
--*********************************************************

SQL> alter database recover managed standby database cancel;

SQL>shutdown immediate;



--********************************************
-- 11 Configure Dataguard Broker
--********************************************

Primary: 

ASMCMD> mkdir +FRA/TIGGER/DATAGUARDCONFIG

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1='+FRA/TIGGER/DATAGUARDCONFIG/dr1TIGGER.dat' SCOPE=BOTH sid='*';
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2='+FRA/TIGGER/DATAGUARDCONFIG/dr2TIGGER.dat' SCOPE=BOTH sid='*';
alter system set dg_broker_start=true scope=both sid='*';

Standby: 

ASMCMD> mkdir +FRA/TIGGER_STBY/DATAGUARDCONFIG

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1='+FRA/TIGGER_STBY/DATAGUARDCONFIG/dr1TIGGER.dat' SCOPE=BOTH sid='*';
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2='+FRA/TIGGER_STBY/DATAGUARDCONFIG/dr2TIGGER.dat' SCOPE=BOTH sid='*';
alter system set dg_broker_start=true scope=both sid='*';


SQL> show parameter broker

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /u01/app/oracle/product/12.1.0/dbhome_1/dbs/dr1tigger_stby.dat
dg_broker_config_file2               string      /u01/app/oracle/product/12.1.0/dbhome_1/dbs/dr2tigger_stby.dat
dg_broker_start                      boolean     FALSE
use_dedicated_broker                 boolean     FALSE
                                               
--*************************************************************************************************************
-- 11.1 Create the Data Guard configuration using the Primary site. This can only be done from the Primary site.
--*************************************************************************************************************

$> dgmgrl
DGMGRL> connect /
DGMGRL> create configuration tigger_dgb as primary database is tigger connect identifier is TIGGER_DGMGRL;
DGMGRL> add database tigger_stby as connect identifier is TIGGER_STBY_DGMGRL maintained as physical;

Enable the Data Guard configuration
DGMGRL> enable configuration;

--********************************
-- 11.2 Verify Configuration 
--********************************

DGMGRL> show configuration;
DGMGRL> show database verbose tigger
DGMGRL> show database verbose tigger_stby
DGMGRL> show instance verbose tigger on database tigger
DGMGRL> show instance verbose tigger on database tigger_stby

--*******************************************************
-- Useful commands to modify Dataguard Broker Properties
--*******************************************************

DGMGRL> edit database 'tigger' set property  'DGConnectIdentifier' = 'TIGGER_DGMGRL'
DGMGRL> edit database 'tigger' set property 'StaticConnectIdentifier' = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.81)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TIGGER_DGMGRL)(INSTANCE_NAME=tigger)(SERVER=DEDICATED)))'
DGMGRL> edit database 'tigger_stby' set property 'StaticConnectIdentifier' = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgstby.racattack)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=TIGGER_STBY_DGMGRL)(INSTANCE_NAME=tigger)(SERVER=DEDICATED)))'
DGMGRL> show database tigger InconsistentProperties
DGMGRL> show database tigger_stby InconsistentProperties

SQL> alter system set archive_lag_target=0 scope=both sid='*';
SQL> alter system set log_archive_min_succeed_dest=1 scope=both sid='*';

Warning: ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting
Warning: ORA-16714: the value of property LogArchiveMinSucceedDest is inconsistent with the database setting

--***************************************************
-- Some useful My Oracle Support notes and websites:
--***************************************************

Creating a Standby using RMAN Duplicate (RAC or Non-RAC) (Doc ID 1617946.1)

Doc ID 241438.1 - Script to Collect Data Guard Physical Standby Diagnostic Information
Doc ID 241374.1 - Script to Collect Data Guard Primary Site Diagnostic Information
Doc ID 316740.1 - How to configure Client Failover after Data Guard Switchover or Failover
Doc ID 1199943.1 - Data Guard Physical Standby Changing the SYS password when a broker configuration exists
Doc ID 278641.1 - How do you apply a Patchset, PSU or CPU in a Data Guard Physical Standby configuration
Doc ID 730361.1 - Changing the network used by the Data Guard Broker Version 10.2 for redo transport
Doc ID 1349977.1 - Data Guard Physical Standby 11.2 RAC Primary to RAC Standby using a second network

http://www.oracle.com/au/products/database/dataguard11g-rac-maa-1-134639.pdf
http://askdba.org/weblog/oracle11g/dataguard/11gr2-rac-dataguard-setup-using-asm/
http://www.oracle.com/technetwork/database/features/availability/maa-wp-10g-racprimaryracphysicalsta-131940.pdf
http://wiki.tapriuneclak.com/index.php?title=Oracle_-_Step_By_Step_of_Configuring_Oracle_11gR2_(11.2.0.1)_RAC_to_RAC_Dataguard
http://www.oracle.com/technetwork/database/features/availability/dataguardoverview-083155.html
http://www.oracle.com/technetwork/database/features/availability/oracle-database-maa-best-practices-155386.html

Oracle Data Guard Concepts and Administration 11g Release 2 (11.2)
http://docs.oracle.com/cd/E11882_01/server.112/e25608/toc.htm

Oracle® Database High Availability Best Practices 11g Release 2 (11.2)
http://docs.oracle.com/cd/E11882_01/server.112/e10803/toc.htm

Oracle Data Guard Broker and Static Service Registration (Doc ID 1387859.1)

Oracle Data Guard Broker 11g Release 2 (11.2)
http://docs.oracle.com/cd/E11882_01/server.112/e17023/toc.htm

DGMGRL> show configuration;

Configuration - tigger_dgb

  Protection Mode: MaxPerformance
  Databases:
  tigger      - Primary database
    tigger_stby - Physical standby database
      Error: ORA-16664: unable to receive the result from a database

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

09/11/2014 16:13:06
Failed to connect to remote database tigger. Error is ORA-12154
Warning: Property 'ArchiveLagTarget' has inconsistent values:METADATA='0', SPFILE='', DATABASE='0'
Warning: Property 'LogArchiveMinSucceedDest' has inconsistent values:METADATA='1', SPFILE='', DATABASE='1'
Failed to send message to site tigger. Error code is ORA-16501.

DGMGRL> show configuration

Configuration - tigger_dgb

  Protection Mode: MaxPerformance
  Databases:
  tigger      - Primary database
    tigger_stby - Physical standby database
      Warning: ORA-16792: configurable property value is inconsistent with database setting

Fast-Start Failover: DISABLED

Configuration Status:
WARNING

DGMGRL> show database tigger_stby InconsistentProperties
INCONSISTENT PROPERTIES
   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE
          tigger     ArchiveLagTarget                    0                                         0
          tigger LogArchiveMinSucceedDest                    1                                         1

DGMGRL> show database tigger InconsistentProperties
INCONSISTENT PROPERTIES
   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE



--**************************************************************
-- 9 Modified Startup Active Dataguard from the Standby Database
--**************************************************************

SQL> startup
SQL> alter database recover managed standby database cancel;
SQL> alter database recover managed standby database disconnect from session;

SQL> select status,instance_name, database_role,open_mode from v$database, v$instance;

STATUS       INSTANCE_NAME    DATABASE_ROLE    OPEN_MODE
------------ ---------------- ---------------- --------------------
OPEN         tigger           PHYSICAL STANDBY READ ONLY

SQL> select process,status,sequence# from v$managed_standby;

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CLOSING              27
ARCH      CLOSING              28
ARCH      CONNECTED             0
ARCH      CONNECTED             0
RFS       IDLE                  0
RFS       IDLE                  0
RFS       IDLE                  0

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
MRP0      WAIT_FOR_LOG         29

--*************************************************************************************
-- Do some log switches from the Primary database an confirm the results on both sides.
--*************************************************************************************

alter system switch logfile;

--*********************************************************
-- 10 Shutdown Active Dataguard from the Standby Database
--*********************************************************

SQL> alter database recover managed standby database cancel;

SQL>shutdown immediate;