MERCADOS FINANCIEROS

lunes, 18 de julio de 2016

Metricas x Usuario


METRICAS X USUARIO

 

CACHE HIT RATIO

SELECT   Round(((Sum(Decode(a.name, 'consistent gets', a.value, 0)) +

         Sum(Decode(a.name, 'db block gets', a.value, 0)) -

         Sum(Decode(a.name, 'physical reads', a.value, 0))  )/

           (Sum(Decode(a.name, 'consistent gets', a.value, 0)) +

             Sum(Decode(a.name, 'db block gets', a.value, 0))))

             *100,2) "Hit Ratio %"

FROM   v$sysstat a

 

COMMITS X HORA

select sum(value) sum from v$sysstat where name like 'user commits' or name like 'user rollbacks';

 

CURSORES OPEN CLUSTER

 

select count(*) from gv$open_cursor

where user_name='SYSADM'

and cursor_type='OPEN'

 

ESPACIO USADO AREA DE RECUPERACION

SELECT round(space_used/1024/1024/1024) AS "Space Used (Gb)" FROM v$recovery_file_dest

 

MAXIMO TIEMPO ESPERA CONCURRENCIA

select max(CONCURRENCY_WAIT_TIME) from gv$sql

 

MAXIMO USUARIOS EJECUCION STATEMENT

select max(users_opening) from gv$sql

 


NUMERO DE SESIONES $ PROCESOS ACTIVOS

SELECT count(*)

FROM   gv$session s,

       gv$process p

WHERE  s.paddr  = p.addr

AND    s.status = 'ACTIVE'

ORDER BY s.username, s.osuser

 

NUMERO DE SESIONES $ PROCESOS INACTIVOS

 

SELECT count(*)

FROM   gv$session s,

       gv$process p

WHERE  s.paddr  = p.addr

AND    s.status = 'INACTIVE'

ORDER BY s.username, s.osuser

 

NUMERO DE SESIONES & PROCESOS TOTALES

 

SELECT count(*)

FROM   gv$session s,

       gv$process p

WHERE  s.paddr  = p.addr

ORDER BY s.username, s.osuser

 

NUMERO DE SESIONES CLUSTER

select count(*) from gv$session

 

NUMERO DE SESIONES ESPERA

select count(*) from v$session_wait

 

NUMERO DE DESIONES ESPERA > 60s

select count(*) from v$session_wait

where seconds_in_wait > 60

 

NUMERO DE REGISTROS > TABLA

select max(num_rows) from dba_tables

 

OBJETOS INVALIDOS

 

select count(*) from dba_objects

where status = 'INVALID'

 

TIEMPO SERVICIO PROMEDIO

select ( s.service_seconds + w.wait_seconds) / user_calls service_time

from (

 select

 (sum(value)/100) / ( 3600 * 24 ) service_seconds

 from v$sysstat

 where upper(name) like '%CPU%'

 and class in (1,64) -- User and SQL

) s,

(

 select

 sum(time_waited/100) wait_seconds

 from v$system_event

 where event not like '%timer'

 and event not like '%from client'

) w,

(

 select

 sum(value) user_calls

 from v$sysstat

 where name like 'user%'

) u

 

TOTAL REDO X DIA

select round(sum(blocks*block_size)/1024/1024/1024,2) Gb from v$archived_log

where completion_time between sysdate-1 and sysdate

 

TOTAL REDO X MES

select round(sum(blocks*block_size)/1024/1024/1024,2) Gb from v$archived_log

where completion_time between sysdate-31 and sysdate

 

TRANSACCIONES X SEGUNDO

select round(sum(s.value / (86400 * (SYSDATE - startup_time))),3) "TPS" from v$sysstat s ,v$instance i where s.NAME in ('user commits','transaction rollbacks');

 

TIEMPO CURSORES > 1s

select count(*) from gv$sql

where elapsed_time > 1000000

 

TIEMPO CURSORES > 2s

select count(*) from gv$sql

where elapsed_time > 2000000

 


TIEMPO RESPUESTA > 10s

select count(*) from gv$sql

where cpu_time > 10000000

 

Tiempo Respuesta > 1m

select count(*) from gv$sql

where cpu_time > 60000000

 


Tiempo Respuesta > 1s

 

select count(*) from gv$sql

where cpu_time > 1000000

 

Total Queries Cluster

 

select count(*) from gv$sql;

 


Total Queries Invalid

 

select count(*) from gv$sql where object_status <> 'VALID'

 

 

 

lunes, 11 de julio de 2016

Configuracion de Red Cluster Oracle

# Red publica


172.28.28.10 ct1bosunsipep01

172.28.28.12 ct1bosunsipep02

172.28.28.14 ct1bosunsipep03

172.28.28.16 ct1bosunsipep04


172.28.28.11 ct1bosunsipep01-test1

172.28.28.22 ct1bosunsipep01-test2


#Red Backup


172.28.249.120 ct1bosunsipep01-bk

172.28.249.122 ct1bosunsipep02-bk

172.28.249.121 ct1bosunsipep01-bk-test1



# Red privada Cluster

192.168.250.33 clusternode1-priv

192.168.250.34 clusternode2-priv

192.168.250.35 clusternode3-priv

192.168.250.36 clusternode4-priv


192.168.250.9 ct1bosunsipep01-priv1



# Red VIP oracle

172.28.28.18 ct1bosunsipep01-vip

172.28.28.19 ct1bosunsipep02-vip

172.28.28.20 ct1bosunsipep03-vip

172.28.28.21 ct1bosunsipep04-vip



# Servidor de Backup



# 172.28.250.94 bksrv01







# 172.28.250.205 dboracle



# 172.28.250.207 dboraclenew



# 172.28.255.132 sunmc01







172.28.250.21 mserver01



172.28.250.20 mserver02



172.28.250.97 mserver03







# SERVIDOR TIVOLI MONITORY



10.201.2.130 srvtivcc01



bash-3.00$







LISTENER.ORA







# listener.ora.ct1bosunsipep01 Network Configuration File: /app/oracle/dbs/10.2.0.3/network/admin/listener.ora.ct1bosunsipep01



# Generated by Oracle configuration tools.







LISTENER_CT1BOSUNSIPEP01 =


(DESCRIPTION_LIST =


(DESCRIPTION =


(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep01-vip)(PORT = 1521)(IP = FIRST))



(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.10)(PORT = 1521)(IP = FIRST))


)



)







SID_LIST_LISTENER_CT1BOSUNSIPEP01 =



(SID_LIST =



(SID_DESC =



(SID_NAME = PLSExtProc)



(ORACLE_HOME = /app/oracle/dbs/10.2.0.3)



(PROGRAM = extproc)



)



(SID_DESC =



(SID_NAME = sirspe1)



(ORACLE_HOME = /app/oracle/dbs/10.2.0.3)



(GLOBAL_DBNAME = sirspe)



)



)











MAQUINA 2







# listener.ora.ct1bosunsipep02 Network Configuration File: /app/oracle/dbs/10.2.0.3/network/admin/listener.ora.ct1bosunsipep02



# Generated by Oracle configuration tools.







LISTENER_CT1BOSUNSIPEP02 =



(DESCRIPTION_LIST =



(DESCRIPTION =



(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep02-vip)(PORT = 1521)(IP = FIRST))



(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.12)(PORT = 1521)(IP = FIRST))



)



)







SID_LIST_LISTENER_CT1BOSUNSIPEP02 =



(SID_LIST =



(SID_DESC =



(SID_NAME = PLSExtProc)



(ORACLE_HOME = /app/oracle/dbs/10.2.0.3)



(PROGRAM = extproc)



)



(SID_DESC =



(SID_NAME = sirspe2)



(ORACLE_HOME = /app/oracle/dbs/10.2.0.3)



(GLOBAL_DBNAME = sirspe)



)



)







TNSNAMES.ORA




LISTENERS_SIRSPE =



(ADDRESS_LIST =



(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.18)(PORT = 1521))



(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.19)(PORT = 1521))


(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep03-vip)(PORT = 1521))



(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep04-vip)(PORT = 1521))


)




SIRSPE4 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep04-vip)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = sirspe)

(INSTANCE_NAME = sirspe4)

)



)



SIRSPE3 =


(DESCRIPTION =


(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep03-vip)(PORT = 1521))


(CONNECT_DATA =


(SERVER = DEDICATED)


(SERVICE_NAME = sirspe)



(INSTANCE_NAME = sirspe3)



)



)







SIRSPE2 =


(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.19)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = sirspe)

(INSTANCE_NAME = sirspe2)



)



)







SIRSPE1 =


(DESCRIPTION =


(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.18)(PORT = 1521))


(CONNECT_DATA =


(SERVER = DEDICATED)


(SERVICE_NAME = sirspe)

(INSTANCE_NAME = sirspe1)

)



)



SIRSPE_SRV =


(DESCRIPTION =


(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.18)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.19)(PORT = 1521))


(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.20)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.21)(PORT = 1521))


(LOAD_BALANCE = yes)


(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = sirspe_srv)

(FAILOVER_MODE =

(TYPE = SELECT)

(METHOD = BASIC)

(RETRIES = 180)

(DELAY = 5)

)



)



)


SIRSPE =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.18)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.19)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep03-vip)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = ct1bosunsipep04-vip)(PORT = 1521))

(LOAD_BALANCE = yes)



(CONNECT_DATA =



(SERVER = DEDICATED)



(SERVICE_NAME = sirspe)



)



)







LISTENERS_CT1BOSUNSIPEP02 =



(ADDRESS_LIST =



(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.28.19)(PORT = 1521))



)







CAT10G =



(DESCRIPTION =



(ADDRESS = (PROTOCOL = TCP)(HOST = dboraclenew)(PORT = 1528))



(CONNECT_DATA =



(SERVER = DEDICATED)



(SERVICE_NAME = cat10g)



)



)












viernes, 17 de junio de 2016

Example Redefinition Desde Enterprise Manager

--   Base de datos destino: USCS90PR
--   Script generado en: 17-JUN-2016   11:51
CREATE TABLE "SYSADM"."LC_MNT_CLASS_CA$REORG" ( "INSTITUTION" VARCHAR2(5) NOT NULL ,  "CAMPUS" VARCHAR2(5) NOT NULL ,  "ACAD_CAREER" VARCHAR2(4) NOT NULL ,  "STRM" VARCHAR2(4) NOT NULL ,  "CRSE_ID" VARCHAR2(6) NOT NULL ,  "CRSE_OFFER_NBR" NUMBER NOT NULL ,  "CLASS_NBR" NUMBER NOT NULL ,  "SESSION_CODE" VARCHAR2(3) NOT NULL ,  "CLASS_SECTION" VARCHAR2(4) NOT NULL ,  "LC_EST_MIGRACION" VARCHAR2(1) NOT NULL ,  "DESCRLONG" CLOB) TABLESPACE "PSDEFAULT" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE  ( INITIAL 64K BUFFER_POOL DEFAULT)  LOGGING  NOCOMPRESS  LOB ("DESCRLONG") STORE AS  BASICFILE ( TABLESPACE "PSDEFAULT" CHUNK 8192  STORAGE ( INITIAL 64K BUFFER_POOL DEFAULT)  RETENTION  NOCACHE  LOGGING )
COMMIT
BEGIN DBMS_REDEFINITION.START_REDEF_TABLE('"SYSADM"', '"LC_MNT_CLASS_CA"', '"LC_MNT_CLASS_CA$REORG"', NULL, DBMS_REDEFINITION.CONS_USE_ROWID); END;
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES"
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES_ITIS"
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES_USBBO"
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES_USBCA"
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES_USBCT"
{SYSADM} GRANT SELECT ON "SYSADM"."LC_MNT_CLASS_CA$REORG" TO "CES_USBME"
BEGIN DBMS_STATS.GATHER_TABLE_STATS('"SYSADM"', '"LC_MNT_CLASS_CA$REORG"', estimate_percent=>NULL, cascade=>TRUE); END;
BEGIN DBMS_REDEFINITION.FINISH_REDEF_TABLE('"SYSADM"', '"LC_MNT_CLASS_CA"', '"LC_MNT_CLASS_CA$REORG"'); END;
DROP TABLE "SYSADM"."LC_MNT_CLASS_CA$REORG" CASCADE CONSTRAINTS PURGE

jueves, 9 de junio de 2016

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

Applies to:

Oracle Database - Enterprise Edition - Version 9.2.0.8 and later
Information in this document applies to any platform.
Checked for relevance on 21-AUG-2015


Goal


Step by step guide on how to create a physical standby database using RMAN DUPLICATE FROM ACTIVE DATABASE command without shutting down the primary and using primary active database files (No need to take a backup)
This is feature available in Oracle11g onwards.
In case you may want or need more about your current topic - please also access the Backup & Recover Community of Customers and Oracle Specialists directly via:
https://community.oracle.com/community/support/oracle_database/database_backup_and_recovery

Database Name :- chicago
Primary db_unique_name :- chicago
standby db_unique_name :- Boston

For duplicating a NON-Standby database, see :
   Note 452868.1 RMAN 'Duplicate From Active Database' Feature in 11G

Solution

1. Make the necessary changes to the primary database.
    a. Enable force logging.
    b. Creating the password file if one does not exist.
    c. Create standby redologs.
    d. Modify the parameter file suitable for Dataguard.
2. Ensure that the sql*net connectivity is working fine.
3. Create the standby database over the network using the active(primary) database files.
    a. Create the password file
    b. Create the initialization parameter file for the standby database (auxiliary database)
    c. Create the necessary mount points or the folders for the database files
    d. Run the standby creation ON STANDBY by connecting to primary as target database.

DUPLICATE TARGET DATABASE 
FOR STANDBY
FROM ACTIVE DATABASE
SPFILE
   PARAMETER_VALUE_CONVERT '', ''
   SET DB_FILE_NAME_CONVERT '', ''
   SET LOG_FILE_NAME_CONVERT '', ''
   SET SGA_MAX_SIZE 200M
   SET SGA_TARGET 125M;
4. Check the log shipping and apply.

PROCEDURE:

While creating the standby database we use the active database files i.e., this command will be useful in creating the physical standby database using active database files over the network.

1. Prepare the production database to be the primary database

a. Ensure that the database is in archivelog mode .
SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

b. Enable force logging
SQL> ALTER DATABASE FORCE LOGGING;

c. Create standby redologs
SQL> alter database add standby logfile '' size ;

d. Modify the primary initialization parameter for dataguard on primary,
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)';
System altered.

SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/databases/chicago/redo/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=chicago';
System altered.

SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=boston LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=boston';
System altered.

SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
System altered.

SQL> alter system set FAL_SERVER=boston;
System altered.

SQL> alter system set FAL_CLIENT=chicago;
System altered.

SQL> alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/databases/boston/data/','/u01/app/oracle/databases/chicago/data' scope=spfile;
System altered.

SQL> alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/databases/boston/redo/','/u01/app/oracle/databases/chicago/redo' scope=spfile;
System altered.

2. Ensure that the sql*net connectivity is working fine.

Insert a static entry for Boston in the listener.ora file of the standby system.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
     (GLOBAL_DBNAME = boston.us.oracle.com)
     (ORACLE_HOME = /u01/app/oracle/product/OraHome111)
     (SID_NAME = boston)
    )
   )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521))
  )

TNSNAMES.ORA for the Primary and Standby should have BOTH entries

CHICAGO =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521))
    )
    (CONNECT_DATA = (SERVICE_NAME = chicago.us.oracle.com))
  )

BOSTON =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521))
    )
    (CONNECT_DATA = (SERVICE_NAME = boston.us.oracle.com))
  )
Check with the SQL*Net configuration using the following commands on the Primary AND Standby
% tnsping chicago
% tnsping boston

3. Create the standby database

a. Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.
The username is required to be SYS and the password needs to be the same on the Primary and Standby.
The best practice for this is to copy the passwordfile as suggested.
The password file name must match the instance name/SID used at the standby site, not the DB_NAME.
b. Create a initialization parameter with only one parameter DB_NAME.
DB_NAME=chicago
DB_UNIQUE_NAME=boston
DB_BLOCK_SIZE=
c. Create the necessary directories in the standby location to place database files and trace files ($ADR_HOME).

d. Set the environment variable ORACLE_SID to the standby service and start the standby-instance.
% export ORACLE_SID=boston
% sqlplus "/ as sysdba"
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initcore1.ora
NOTE : Use either PFILE or SPFILE

# Addtl. comment
# If DUPLICATE without TARGET connection is used you cannot use SPFILE
# else getting

RMAN-05537: DUPLICATE without TARGET connection when auxiliary instance is started with spfile cannot use SPFILE clause

e. Verify if the connection 'AS SYSDBA' is working
% sqlplus /nolog
SQL> connect sys/SQL> connect sys/@chicago AS SYSDBA

f. On the primary system invoke the RMAN executable and connect to the primary and the auxiliary database ( i.e., the standby)
$ rman target sys/sys@chicago auxiliary sys/sys@boston

connected to target database: CHICAGO (DBID=761464750)
connected to auxiliary database: CHICAGO (not mounted)

RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;

duplicate target database for standby from active database
spfile
  parameter_value_convert 'chicago','boston'
  set db_unique_name='boston'
  set db_file_name_convert='/chicago/','/boston/'
  set log_file_name_convert='/chicago/','/boston/'
  set control_files='/u01/app/oracle/oradata/control01.ctl'
  set log_archive_max_processes='5'
  set fal_client='boston'
  set fal_server='chicago'
  set standby_file_management='AUTO'
  set log_archive_config='dg_config=(chicago,boston)'
  set log_archive_dest_2='service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'
;
}

using target database control file instead of recovery catalog
allocated channel: prmy1
channel prmy1: SID=147 device type=DISK

allocated channel: prmy2
channel prmy2: SID=130 device type=DISK

allocated channel: prmy3
channel prmy3: SID=137 device type=DISK

allocated channel: prmy4
channel prmy4: SID=170 device type=DISK

allocated channel: stby
channel stby: SID=98 device type=DISK

Starting Duplicate Db at 19-MAY-08

contents of Memory Script:
{
backup as copy reuse
file '/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore1'
file'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore.ora' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora' ;
sql clone "alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora''";
}
executing Memory Script

Starting backup at 19-MAY-08
Finished backup at 19-MAY-08

sql statement: alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora''

contents of Memory Script:
{
sql clone "alter system set audit_file_dest =''/u02/app/oracle/admin/boston/adump'' comment='''' scope=spfile";
sql clone "alter system set dispatchers =''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment='''' scope=spfile";
sql clone "alter system set db_unique_name =''boston'' comment='''' scope=spfile";
sql clone "alter system set db_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set log_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set control_files =''/u01/app/oracle/oradata/control01.ctl'' comment='''' scope=spfile";
sql clone "alter system set log_archive_max_processes =5 comment='''' scope=spfile";
sql clone "alter system set fal_client =''boston'' comment='''' scope=spfile";
sql clone "alter system set fal_server =''chicago'' comment='''' scope=spfile";
sql clone "alter system set standby_file_management =''AUTO'' comment='''' scope=spfile";
sql clone "alter system set log_archive_config =''dg_config=(chicago,boston)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment='''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script

sql statement: alter system set audit_file_dest = ''/u02/app/oracle/admin/boston/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''boston'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/control01.ctl'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile
sql statement: alter system set fal_client = ''boston'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''chicago'' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(chicago,boston)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 845348864 bytes

Fixed Size 1303188 bytes
Variable Size 482348396 bytes
Database Buffers 356515840 bytes
Redo Buffers 5181440 bytes

contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/control01.ctl';
sql clone 'alter database mount standby database';
}
executing Memory Script

Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
copying standby control file
output file name=/u02/app/oracle/product/11.1.0/db_1/dbs/snapcf_chicago.f tag=TAG20080519T173406 RECID=2 STAMP=655148053
channel prmy1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 19-MAY-08

sql statement: alter database mount standby database

contents of Memory Script:
{
set newname for tempfile 1 to"/u02/app/oracle/oradata/boston/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to "/u02/app/oracle/oradata/boston/system01.dbf";
set newname for datafile 2 to "/u02/app/oracle/oradata/boston/sysaux01.dbf";
set newname for datafile 3 to "/u02/app/oracle/oradata/boston/undotbs01.dbf";
set newname for datafile 4 to "/u02/app/oracle/oradata/boston/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format "/u02/app/oracle/oradata/boston/system01.dbf"
datafile 2 auxiliary format "/u02/app/oracle/oradata/boston/sysaux01.dbf"
datafile 3 auxiliary format "/u02/app/oracle/oradata/boston/undotbs01.dbf"
datafile 4 auxiliary format "/u02/app/oracle/oradata/boston/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u02/app/oracle/oradata/boston/temp01.dbf in control file

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
input datafile file number=00001 name=/u02/app/oracle/oradata/chicago/system01.dbf
channel prmy2: starting datafile copy
input datafile file number=00002 name=/u02/app/oracle/oradata/chicago/sysaux01.dbf
channel prmy3: starting datafile copy
input datafile file number=00003 name=/u02/app/oracle/oradata/chicago/undotbs01.dbf
channel prmy4: starting datafile copy
input datafile file number=00004 name=/u02/app/oracle/oradata/chicago/users01.dbf
output file name=/u02/app/oracle/oradata/boston/undotbs01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy3: datafile copy complete, elapsed time: 00:00:24
output file name=/u02/app/oracle/oradata/boston/users01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy4: datafile copy complete, elapsed time: 00:00:16
output file name=/u02/app/oracle/oradata/boston/system01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy1: datafile copy complete, elapsed time: 00:02:32
output file name=/u02/app/oracle/oradata/boston/sysaux01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy2: datafile copy complete, elapsed time: 00:02:32
Finished backup at 19-MAY-08

sql statement: alter system archive log current

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/users01.dbf
Finished Duplicate Db at 19-MAY-08
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4

4. Start managed recovery

Connect to standby using SQL*Plus and start the MRP (Managed Recovery Process). Compare the primary last sequence and MRP (Managed Recovery Process) applying sequence.
Example :
SQL> alter database recover managed standby database disconnect from session;

5. Open standby database in Read Only (active dataguard)

If you are licensed to use Active Dataguard (ADG) than open the Standby Database in READ ONLY and start the recovery.
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> alter database recover managed standby database disconnect;

Creating a physical standby from ASM primary (Doc ID 787793.1)

To BottomTo Bottom

In this Document
Goal
Solution
References

Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 12.1.0.2 [Release 10.2 to 12.1]
Information in this document applies to any platform.
** checked for relevance '7-Jul-2015' **


Goal

** checked for relevance '7-Jul-2015' **
This document offers step by step procedure to create physical standby from ASM primary.
Database Name :- chicago
Primary db_unique_name :- chicago
standby db_unique_name :- Boston

Primary Hostname :- raca.idc.oracle.com
standby Hostname :- core1.idc.oracle.com

Solution

1. Enable Force Logging,

SQL> ALTER DATABASE FORCE LOGGING;

Database altered. 


2. On the primary node, create a staging directory. For example:
[oracle@raca chicago]$ mkdir –p /home/oracle/stage

3. Create the same exact path on the standby host:
[oracle@core1 ~]$ mkdir -p /home/oracle/stage


4. On the primary node, connect to the primary database and create a PFILE from the SPFILE in the staging directory. For example:
create pfile='/home/oracle/stage/boston.ora' from spfile;


5. On the primary node, perform an RMAN backup of the primary database that places the backup pieces into the staging directory. For example:
RMAN> run{
2> backup device type disk format '/home/oracle/stage/%U' database;
3> backup device type disk format '/home/oracle/stage/%U' current controlfile for standby;
4> }

Starting backup at 24-FEB-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=30 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA/chicago/datafile/system.271.679675991
input datafile fno=00003 name=+DATA/chicago/datafile/sysaux.273.679676023
input datafile fno=00002 name=+DATA/chicago/datafile/undo1.272.679676015
channel ORA_DISK_1: starting piece 1 at 24-FEB-09
channel ORA_DISK_1: finished piece 1 at 24-FEB-09
piece handle=/home/oracle/stage/01k8650r_1_1 tag=TAG20090224T154323 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 24-FEB-09
channel ORA_DISK_1: finished piece 1 at 24-FEB-09
piece handle=/home/oracle/stage/02k8651v_1_1 tag=TAG20090224T154323 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-FEB-09

Starting backup at 24-FEB-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including standby control file in backupset
channel ORA_DISK_1: starting piece 1 at 24-FEB-09
channel ORA_DISK_1: finished piece 1 at 24-FEB-09
piece handle=/home/oracle/stage/03k86525_1_1 tag=TAG20090224T154405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-FEB-09

RMAN>

6. Copy the contents of the staging directory from primary to standby's staging location. For example
[oracle@raca stage]$ scp /home/oracle/stage/* oracle@core1:/home/oracle/stage/
oracle@core1's password:
01k8650r_1_1 100% 236MB 10.7MB/s 00:22
02k8651v_1_1 100% 6016KB 5.9MB/s 00:00
03k86525_1_1 100% 5984KB 5.8MB/s 00:01
boston.ora 100% 458 0.5KB/s 00:00
[oracle@raca stage]$


7. Prepare the initialization file for standby instance
[oracle@core1 ~]$ mkdir -p /u01/app/oracle/product/10.2/oradata
[oracle@core1 ~]$ cd /u01/app/oracle/product/10.2/oradata
[oracle@core1 oradata]$ mkdir redo data ctrl bdump udump srl arc1
[oracle@core1 oradata]$
Set the below parameters in init.ora of standby,
*.db_name='chicago'
*.db_create_file_dest='/u01/app/oracle/product/10.2/oradata/boston/data/'
*.db_create_online_log_dest_1='/u01/app/oracle/product/10.2/oradata/boston/redo/'
*.db_file_name_convert='+DATA/chicago/datafile/','/u01/app/oracle/product/10.2/oradata/boston/data/','+DATA/chicago/tempfile/','/u01/app/oracle/product/10.2/oradata/boston/data/'
*.log_file_name_convert='+DATA/chicago/onlinelog/','/u01/app/oracle/product/10.2/oradata/boston/redo/'
*.db_unique_name=boston

NOTE: For RAC primary to non RAC standby , include below line in the standby init.ora,
cluster_database=false

8. Create password file for standby database
[oracle@core1 boston]$ export ORACLE_SID=boston
[oracle@core1 dbs]$orapwd file=orapwboston password=oracle
[oracle@core1 dbs]$ ls -ltr *boston*
-rw-r----- 1 oracle oinstall 1536 Mar 3 15:55 orapwboston

9. Compose a tnsnames or connect string at standby server

chicago =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =raca.idc.oracle.com )(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = chicago)
)
)

boston =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =core1.idc.oracle.com )(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = boston)
)
)
Note:-

chicago will connect to primary while boston connects to standby itself
10. Create standby database
[oracle@core1 boston]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 3 16:55:19 2009

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

Connected to an idle instance.

SQL> create spfile from pfile='/u01/app/oracle/product/10.2/oradata/boston/initboston.ora';

File created.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 327155712 bytes
Fixed Size 1218844 bytes
Variable Size 150996708 bytes
Database Buffers 104857600 bytes
Redo Buffers 70082560 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

[oracle@core1 boston]$ /u01/app/oracle/product/10.2/bin/rman target sys/oracle@chicago auxiliary /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 3 16:56:09 2009

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

connected to target database: CHICAGO (DBID=1289394690)
connected to auxiliary database: CHICAGO (not mounted)

RMAN> duplicate target database for standby;

Starting Duplicate Db at 03-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

contents of Memory Script:
{
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script

Starting restore at 03-MAR-09
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/stage/03k86525_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/home/oracle/stage/03k86525_1_1 tag=TAG20090224T154405
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u01/app/oracle/product/10.2/oradata/boston/ctrl/ctrl01.ctl
Finished restore at 03-MAR-09

sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1

contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/product/10.2/oradata/boston/data/tmp1.274.679676043";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/product/10.2/oradata/boston/data/system.271.679675991";
set newname for datafile 2 to
"/u01/app/oracle/product/10.2/oradata/boston/data/undo1.272.679676015";
set newname for datafile 3 to
"/u01/app/oracle/product/10.2/oradata/boston/data/sysaux.273.679676023";
restore
check readonly
clone database
;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /u01/app/oracle/product/10.2/oradata/boston/data/tmp1.274.679676043 in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 03-MAR-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/product/10.2/oradata/boston/data/system.271.679675991
restoring datafile 00002 to /u01/app/oracle/product/10.2/oradata/boston/data/undo1.272.679676015
restoring datafile 00003 to /u01/app/oracle/product/10.2/oradata/boston/data/sysaux.273.679676023
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/stage/01k8650r_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/home/oracle/stage/01k8650r_1_1 tag=TAG20090224T154323
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 03-MAR-09

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy recid=4 stamp=680547428 filename=/u01/app/oracle/product/10.2/oradata/boston/data/system.271.679675991
datafile 2 switched to datafile copy
input datafile copy recid=5 stamp=680547428 filename=/u01/app/oracle/product/10.2/oradata/boston/data/undo1.272.679676015
datafile 3 switched to datafile copy
input datafile copy recid=6 stamp=680547428 filename=/u01/app/oracle/product/10.2/oradata/boston/data/sysaux.273.679676023
Finished Duplicate Db at 03-MAR-09

RMAN>
11 Add standby redo logs to standby database
SQL> alter database add standby logfile group 3 '/u01/app/oracle/product/10.2/oradata/boston/srl/srl3a.log' size 150m;

Database altered.

SQL> alter database add standby logfile group 4 '/u01/app/oracle/product/10.2/oradata/boston/srl/srl4a.log' size 150m;

Database altered.

SQL> alter database add standby logfile group 5 '/u01/app/oracle/product/10.2/oradata/boston/srl/srl5a.log' size 150m;

Database altered.

SQL> alter database recover managed standby database using current logfile disconnect;

Database altered.

SQL>
12. Establish the communication to primary from standby
SQL> select name,database_role from v$database;

NAME DATABASE_ROLE
--------- ----------------
CHICAGO PHYSICAL STANDBY

SQL> alter system set standby_archive_dest='/u01/app/oracle/product/10.2/oradata/boston/arc1/';

System altered.

SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/product/10.2/oradata/boston/arc1/ valid_for=(all_logfiles,all_roles) db_unique_name=boston';


SQL> alter system set log_archive_config='dg_config=(chicago,boston)';

System altered.

SQL> alter system set log_archive_dest_2='service=chicago lgwr async noaffirm valid_for=(online_logfiles,primary_role) db_unique_name=chicago';

System altered.

SQL> alter system set fal_client=boston;

System altered.

SQL> alter system set fal_server=chicago;

System altered.

SQL> alter system set standby_file_management=auto;

System altered.

13. Compose tnsnames or connect strings at Primary server

chicago =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =raca.idc.oracle.com )(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = chicago)
)
)

boston =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =core1.idc.oracle.com )(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = boston)
)
)
Note:-

Boston will connect to standby while chicago connects to primary itself

From 11g we can use RMAN>DUPLICATE FROM ..ACTIVE DATABASE,
DUPLICATE TARGET DATABASE 
FOR STANDBY
FROM ACTIVE DATABASE
SPFILE
   PARAMETER_VALUE_CONVERT '', ''
   SET DB_FILE_NAME_CONVERT '', ''
   SET LOG_FILE_NAME_CONVERT '', ''
   SET SGA_MAX_SIZE 200M
   SET SGA_TARGET 125M;
For STEP 10 detailed Step on DUPLICATE from ACTIVE DATABSE refer,
Note 1075908.1Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE

14. Establish the communication to standby from primary
SQL> alter system set log_archive_config='dg_config=(chicago,boston)';

System altered.

SQL> alter system set log_archive_dest_2='service=boston lgwr async noaffirm valid_for=(online_logfiles,primary_role) db_unique_name=boston';

System altered.

SQL> alter system set fal_client=chicago;

System altered.

SQL> alter system set fal_server=boston;

System altered.

SQL> select name,database_role from v$database;

NAME DATABASE_ROLE
--------- ----------------
CHICAGO PRIMARY

SQL>

15. Set role transition specific parameters for current primary
SQL> alter system set db_file_name_convert='/u01/app/oracle/product/10.2/oradata/boston/data/','+DATA/chicago/datafile/','/u01/app/oracle/product/10.2/oradata/boston/data/','+DATA/chicago/tempfile/' scope=spfile;

System altered.

SQL> alter system set log_file_name_convert='/u01/app/oracle/product/10.2/oradata/boston/redo/','+DATA/chicago/onlinelog/' scope=spfile;

System altered.

SQL> alter system set standby_file_management=auto;

System altered.
16. Configure a Standby Redo Log,
SQL> alter database add standby logfile group 3 size 150m;

Database altered.

SQL>alter database add standby logfile group 4 size 150m

Database altered.

SQL>alter database add standby logfile group 5 size 150m

Database altered.

Creating a Physical Standby Database File System My Oracle Support

To BottomTo Bottom

To BottomTo Bottom

In this Document
Purpose
Scope
Details
 Prerequisites and Assumptions to get started
 Environment Information
 Preparing the Environment and Standby Instance
 Create the Physical Standby Database
 Creating a Standby Database via User Managed Backups
 Creating a Standby Database using RMAN (Backup based)
 Creating a Standby Database using RMAN without Backup (from active Database)
 Post-Creation Steps to make the Data Guard Environment operational
 Optional additional Steps
References

Applies to:

Oracle Database - Enterprise Edition - Version 10.1.0.2 to 12.1.0.2 [Release 10.1 to 12.1]
Information in this document applies to any platform.

Purpose

** checked for relevance '7-Jul-2015' **
This Document shows the various Possibilities to create a Physical Standby Database on Oracle Database 11.2.0.x.
It should be seen as an Addition and Clarification to the Documentation. You may also review
Oracle® Data Guard, Concepts and Administration, 11g Release 2 (11.2), E25608-0x
Chapter 3: Creating a Physical Standby Database
Appendix E: Creating a Standby Database with Recovery Manager
which is the Base for this Document. We take an Example Database and show the various Methods to create the Standby Database. Note that only the basic Concepts are shown. Further more complex Scenarios are possible as well, of course. Take a Look into the corresponding Documentation to get the deeper Insight.
 
Would you like to explore this Topic further with other Oracle Customers, Oracle Employees and Industry Experts ??
You can discuss this Note, show your Experiences or ask Questions about it directly right at the Bottom of this Note in the Discussion Thread about this Document.
If you want to discover Discussions about other Articles und Subjects or even post new Discussions you can access the My Oracle Support Community Page for High Availability Data Guard

Scope

This Document is intended for System Adminstrators planning to setup a Standby Database. Depending on the Needs and Prerequisites on the existing Environment you can choose any of the mentioned Ways to create the Standby Database and Data Guard Environment.
Note that this Note does not cover Setting up Log Transport and Log Apply Services in Detail - we take the basic default Setup here. The same is true for the RMAN Environment in Case where different Backup Types and Scenarios are possible. We just try to show the basic Concept here.

Details


Prerequisites and Assumptions to get started


-          There already exists a Primary Database you want to create your Standby Database for
-          Primary Database is in ARCHIVELOG-Mode and local Archiving is using Fast Recovery Area
-          FORCE LOGGING is enabled on the Primary Database
-          The Primary Database is using a SPFILE
-          On the Standby Site ORACLE_HOME is installed using the same Oracle Release and Patchlevel
-          The Platform of the Standby Database is the same as the Primary Site or a supported Combination as per Note 413484.1
-          There is Network Connectivity between the Primary and Standby System
-          Listener is configured and running on the Primary and Standby Site
-          We are creating a Standby Database using default Log Transport Services in Maximum Performance Mode


Environment Information


For all mentioned Possibilities we are using this Environment

OS:                                                                       Linux x64-64
Hostname (Primary):                                    TSTPRIM
Hostname (Standby):                                   TSTSTBY
Database Version:                                         11.2.0.x
DB_NAME (Primary and Standby):         prim_db
SID/DB_UNIQUE_NAME (Primary):       prim_db
SID/DB_UNIQUE_NAME (Standby):      stby_db
Listener Port (Primary and Standby):     1521
Primary Database Files Location:             /oracle/oradata/prim_db
Standby Database Files Location:            /oracle/oradata/stby_db


Preparing the Environment and Standby Instance


-          Create TNS-Alias to resolve the Standby Database later. The TNS-Alias to resolve the Primary and Standby Database must be present in the Primary and Standby Database TNSNAMES.ORA. Here it looks like that:
 
PRIM_DB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTPRIM)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prim_db.world)
    )
  )

STBY_DB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTSTBY)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = stby.world)
    )
  )
 
-          Create Folders in ADMIN- and ORADATA-Folders to host the Database Files and Dumpfiles (can use $ORACLE_BASE/admin of the Primary as a Reference which Folders to create – typically those are the ‘adump’- and ‘dpdump’-Folders)

$ cd $ORACLE_BASE/admin
$ mkdir stby_db
$ cd stby_db
$ mkdir adump
$ mkdir dpdump

-          Create a PFILE from the Primary PFILE in the Format ‘init.ora’

SQL> create pfile=’/tmp/initstby_db.ora’ from spfile;

 -          Set the following Initialization Parameters on the Primary Database:
  • log_archive_dest_1 = ‘location=USE_DB_RECOVERY_FILE_DEST’
  • log_archive_dest_2 = ’service=stby_db async valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=stby_db’
  • log_archive_dest_state_2 = ’defer’
  • log_archive_config= ’dg_config=(prim_db,stby_db)’
  • log_archive_max_processes = 8

-> Those Parameters prepare the Primary Database to support a Standby Database ’stby_db’. log_archive_dest_2 is responsible for transferring Redo to the Standby Site later – currently it is deferred, we will enable later once the Standby Database exists. log_archive_config records all db_unique_name’s participating in this Configuration.

-          Modify the following Initialization Parameters in the PFILE (initstby_db.ora) for the Standby Database we created before:
  • log_archive_dest_1 = ‘location=USE_DB_RECOVERY_FILE_DEST’
  • log_archive_config= ’dg_config=(prim_db,stby_db)’
  • log_archive_max_processes = 8
  • fal_server = ‘prim_db’
  • log_file_name_convert = ‘’,’
  • db_file_name_convert = ‘’,’
  • db_unique_name = ‘stby_db’

-> Those Parameters are required to be adjusted for the Standby Database. log_archive_dest_1 here defines the local Archive Destination where we will put ArchiveLogs arriving from the Primary Database later. log_archive_config and db_unique_name are required for the Data Guard Configuration (like on the Primary) and fal_server is required for Gap Resolution to be able to automatically fetch Archive Logs from the Primary again in Case there is a Gap. To automate the Substitution of Database File Locations we set db_file_name_convert and log_file_name_convert. Those Pairs of Values are a simple String Substitution. See Note 1367014.1 for further Details.
-> You may also adjust audit_file_dest and control_files to match with your Environment and Locations.

-          Copy prepared ‘initstby_db.ora’ together with the Passwordfile of the Primary Database (orapwprim_db in $ORACLE_HOME/dbs) to the Standby Site and place both into ‘$ORACLE_HOME/dbs’-Folder. Then you have to rename the Passwordfile to match with the Standby SID:

$ mv orapwprim_db orapwstby_db
 

Create the Physical Standby Database


In the previous Section we prepared the Environments and the Primary Database to support a Standby Database. Now we can proceed and create the Physical Standby Database itself. There are 3 common Ways to perform this which will be shown in the next Section. You can choose any Way most suitable for you:
  1. Creating manually via User-Managed Backups
  2. Using RMAN Backup-based Duplication
  3. Creating a Standby Database from the active Primary Database without a Backup using RMAN Duplicate

Creating a Standby Database via User Managed Backups

We can use a Hot or Cold Database Backup to create the Standby Database. It is only important to create the Standby Controlfile from the Primary after the Backup has completed.
For a Cold Backup we simply perform a clean shutdown of the Primary Database and copy all Datafiles to a temporary Location, then startup the Primary Database again:

SQL> shutdown immediate;
$ cp /oracle/oradata/prim_db/*.dbf /backup/
SQL> startup
 
-          If you want to use a Host Backup, we have to put the Primary Database into Backup Mode and copy the Datafiles:

SQL> alter database begin backup;
$ cp /oracle/oradata/prim_db/*.dbf /backup/
SQL> alter database end backup;
 
-          We can create the Standby Controlfile since the Backup is complete (either Hot or Cold Backup)

SQL> alter database create standby controlfile as ‘/backup/control01.ctl’;
 
-          Now the required Files for the Standby Database are complete and we can transfer those to the Standby Database and place them into the Standby Database File-Folder (in our Example to ‘/oracle/oradata/stby_db/’)
-          Once the Datafiles are there we can set the Environment and first mount the Standby Database

$ export ORACLE_SID = stby_db
SQL> connect / as sysdba
SQL> startup mount
 
-          When the Database is mounted proceed with the Post-Creation Steps below


Creating a Standby Database using RMAN (Backup based)

Instead of creating a User-Managed Backup we can also use a RMAN Backup to create the Standby Database.
-          In this Case we have to create a RMAN Backup of the Primary Database first:

RMAN> connect target /
RMAN> backup database plus archivelog format ‘/backup/STBY_%U’;

-          Since the Backup already includes the Controlfile, there is no Need to backup or create a Standby Controlfile separately
-          Transfer all Backuppieces created by the RMAN Backup to the exact same Folder (in our Case ‘/backup/’) on the Standby Database
-          Startup nomount the Standby Database

$ export ORACLE_SID = stby_db
SQL> startup nomount

 -          At this Point we can now start the RMAN Duplicate to create the Standby Database

$ export ORACLE_SID = stby_db
RMAN> connect target sys/@prim_db
RMAN> connect auxiliary /
RMAN> duplicate target database for standby nofilenamecheck;
 
-> The RMAN Duplicate now extracts the Controlfile and Datafiles from the Backup to build the Standby Database. Once done it mounts the Standby Database.  So we can now proceed with the Post-Creation Steps below.

Creating a Standby Database using RMAN without Backup (from active Database)

It is now possible to create a Physical Standby Database from the active Primary Database, ie. It is not necessary to create a Backup first. The Blocks are transferred to the Standby Database via the Network during the RMAN Duplicate. Before you decide to use this Option to create your Standby Database you should ensure you sufficient Bandwith available to transfer all Database Blocks of the Primary to the Standby. Depending on the Size of your Primary Database and the Bandwith available it might take long Time to complete this Task. If you have a large Database or a slow Network Connection you may consider to use another Option to create your Standby Database.
The Steps to create the Standby Database that Way are similar to a Backup-based RMAN Duplicate, but we don’t have to take the Backup, we can directly start the RMAN Duplicate from the Standby Site:

$ export ORACLE_SID = stby_db
SQL> startup nomount
RMAN> connect target sys/@prim_db
RMAN> connect auxiliary /
RMAN> duplicate target database for standby from active database nofilenamecheck;

-> The RMAN Duplicate first copies the Controlfile from the Primary Database as a Standby Controlfile, then mounts the Standby Database with this Conrolfile and creates the Datafiles/copies the Database Blocks from the Primary. Once done the Duplicate finishes and leaves the Database in mount-Status. So we can now proceed with the Post-Creation Steps below.
NOTE : If primary and standby sharing same storage do not use NOFILENAMECHECK clause unless you are sure about the directories are different.
ref,
<NOTE 789370.1> -  Creating Physical Standby using RMAN Duplicate Without Shutting down The Primary

Post-Creation Steps to make the Data Guard Environment operational


In the previous Chapters we prepared and created the Physical Standby Database. Now we can start the Log Transport and Log Apply Services to have the Data Guard Environment completely operational.
-          First of all we should now add Standby RedoLogs to the new created Standby Database to collect the current Redo arriving from the Primary Database. We can add those using

SQL> alter database add standby logfile (‘’) size ;

You should add at least one more Standby RedoLogs Group than corresponding Online RedoLog Group. See Note 219344.1 for further Details and Examples.

-          Next we can enable Log Transport Services on the Primary Database which have been prepared initially – performing a Logfile Switch afterwards will finally enable it (all changes to log_archive_dest_n and log_archive_dest_state_n become active after the next Log Switch once set).

SQL> alter system set log_archive_dest_state_2 = ‘enable’ scope=both;
SQL> alter system switch logfile;
 
To verify if Standby RedoLogs get allocated on the Standby Database and so Log Transport Services are running query v$standby_log on the Standby Database:

SQL> select * from v$standby_log;
  -          Assuming that Log Transport Services are running now, we can finally start Log Apply Services (Managed Recovery):
 SQL> alter database recover managed standby database using current logfile disconnect;

Query v$managed_standby to monitor the Progress of the Managed Recovery:

SQL> select * from v$managed_standby where process = ‘MRP0’;

Most likely there will now be a FAL Gap Request first to ship and apply all ArchiveLogs created since we took the Backup. Depending on the Time and Amount of Redo generated on the Primary meanwhile it may take a while.
Note that starting Managed Recovery will also attempt to clear/create the Online RedoLogs on the Standby Database proactive to reduce Switchover/Failover Time.

Optional additional Steps


Basically we have now an active Data Guard Configuration. Depending on your Requirements you can proceed performing those Steps:
-          Create an SPFILE from the current PFILE on the Standby Database
-          Enable Flashback to be able to Flashback this Database (eg. instead of the Primary Database to get historical Data or avoid having to recreate the Standby Data in Case of a RESETLOGS-Operation on the Primary Database)
-          Setup and enable a Data Guard Broker Configuration – the Data Guard Broker is an Offset to Data Guard in order to make monitoring and administering of a Data Guard Configuration much easier. Note that using a Data Guard Configuration with Cloud Control (formerly Grid Control) requires the Data Guard Broker
-          Raise Protection Mode to Maximum Availability or Maximum Protection
-          Proactive setup Log Transport Services from Standby Database to the Primary and create Standby RedoLogs on the Primary for Switchover Purposes is used
-          Open the Standby Database READ ONLY and restart Managed Recovery (Active Data Guard). Note that this requires Licensing of the ‘Active Data Guard’-Option. However you can open the Standby Database open READ ONLY without Apply Services; this does not require this Option to be licensed
-          Setup Fast-Start Failover (requires the Data Guard Broker, too)
-          Add additional Standby Database(s)
-          Turn the just created Physical Standby Database into a Logical Standby Database