Step by Step Creating a physical standby database on Oracle 11.2.0.1.0 using RMAN

Creating a physical standby database on Oracle 11.2.0.1.0 using RMAN :-

OS Version:-Red Hat Enterprise Linux Server release 6.4
Oracle version:- Oracle Database 12c Enterprise Edition Release 11.2.0.1.0 64bit
Primary database:- prim   
Standby database:- stand

System Configuration

primary server:-

edit the following files

vi /etc/hosts

192.168.2.102   server1.soumya.com      server1
192.168.2.104   server2.soumya.com      server2

:wq

vi /etc/sysconfig/network
HOSTNAME=server1.soumya.com

:wq

vi /etc/sysconfig/network-scripts/ifcfg-eth0

NETMASK=255.255.255.0
IPADDR=192.168.2.102
GATEWAY=192.168.2.1

:wq

Standby Server:-

edit the following files

vi /etc/hosts

192.168.2.102   server1.soumya.com      server1
192.168.2.104   server2.soumya.com      server2
:wq

vi /etc/sysconfig/network

HOSTNAME=server2.soumya.com

:wq

vi /etc/sysconfig/network-scripts/ifcfg-eth0

NETMASK=255.255.255.0
IPADDR=192.168.2.104
GATEWAY=192.168.2.1

:wq

In both server-- # service network restart
                 # service NetworkManager restart
                 # service iptables stop
                 # chkconfig iptables off
                 #vi /etc/selinux/config and disable selinux .
                  After changing inside the file please restart the server.       
               
We have a database called prim on primary server and  we will install only oracle binaries on
standby server(192.168.2.104).No database should be running in standby server.
                 



Oracle Net configuration:-

Listener.ora configuration for primary database (prim) in primary server (192.168.2.102)

vi $ORACLE_HOME/network/admin/listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = prim)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = prim)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server1.soumya.com)(PORT = 1521))
  )
ADR_BASE_LISTENER = /u01/app/oracle

:wq

Listener.ora configuration for standby database (stand) in standby server (192.168.2.104)
vi $ORACLE_HOME/network/admin/listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = stand)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = stand)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server2.soumya.com)(PORT = 1521))
  )
ADR_BASE_LISTENER = /u01/app/oracle

:wq

On both server(192.168.2.102 & 192.168.2.104), add Oracle Net aliases for both databases and aux alias for RMAN DUPLICATE in
tnsnames.ora:

vi $ORACLE_HOME/network/admin/tnsnames.ora

prim =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server1.soumya.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prim)
    )
  )

stand =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server2.soumya.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = stand)
    )
  )

-save & exit(:wq )

Now we will have to start listener in primary and standby server:-

$ lsnrctl start

Check "tnsping prim" & "tnsping stand"  in both server. If output of both command is
coming as "ok" that means oracle net service has been added successfully.

In primary database:-
Put the database in archivelog mode.
SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     2
Current log sequence           4

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup mount
ORACLE instance started.

Total System Global Area  629145600 bytes
Fixed Size                  2927528 bytes
Variable Size             511706200 bytes
Database Buffers          109051904 bytes
Redo Buffers                5459968 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

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

SQL> alter database open;

In Primary Database:-

Enable force logging The FORCE LOGGING option to ensure that all the changes made in the database
will be captured and available for recovery in the redo logs.

SQL> alter database force logging;
Database altered.

SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES

Create a password file
$ orapwd file=$ORACLE_HOME/dbs/orapwprim password=redhat
$ cd $ORACLE_HOME/dbs/
$ chmod 775 orapwprim
$ cp orapwprim orapwstand

Now transfer the password file  into standby server using scp command
$ scp orapwstand oracle@192.168.2.104:/u01/app/oracle/product/11.2.0/db_1/dbs/


Add following parameter in pfile for primary database.

create pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora' from spfile;   

vi /u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora

*.db_name='prim'
*.db_unique_name='prim'
*.log_archive_config='DG_CONFIG=(prim, stand)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/flash_recovery_area VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prim'
*.log_archive_dest_2='SERVICE=stand LGWR ASYNC VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=stand'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.FAL_SERVER=stand
*.FAL_CLIENT=prim
*.db_file_name_convert='/u01/app/oracle/oradata/stand/','/u01/app/oracle/oradata/prim/'
*.log_file_name_convert='/u01/app/oracle/oradata/stand/','/u01/app/oracle/oradata/prim/'
*.standby_file_management=auto   

-save & exit(:wq)

SQL> shut immediate;

SQL>  startup mount pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora';
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora';

SQL> alter database open;
Total System Global Area  413372416 bytes
Fixed Size                  2213896 bytes
Variable Size             339740664 bytes
Database Buffers           67108864 bytes
Redo Buffers                4308992 bytes
Database mounted.
Database opened.

At Standby database:-
Create the necessary directory structure:-
$ mkdir -p /u01/app/oracle/oradata/stand/
$ mkdir -p /u01/app/oracle/admin/stand/adump
$ mkdir -p /u01/app/oracle/flash_recovery_area/stand/
$ chmod 775 -Rf /u01

Configure .bash_profile
[oracle@server2 ~]$ vi .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=server2.soumya.com
export ORACLE_UNQNAME=stand
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=stand
export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

Now start the instance in nomount mode with minimal options

vi initstand.ora
DB_NAME=prim
DB_UNIQUE_NAME=stand
DB_BLOCK_SIZE=8192

:wq


SQL> startup nomount pfile='/home/oracle/initstand.ora';
ORACLE instance started.

Total System Global Area  413372416 bytes
Fixed Size                  2213896 bytes
Variable Size             339740664 bytes
Database Buffers           67108864 bytes
Redo Buffers                4308992 bytes

At primary database:-
Add the standby redologs.
SQL>  select group#, members , bytes /1024 /1024 from v$log;

    GROUP#    MEMBERS BYTES/1024/1024
---------- ---------- ---------------
         1          1              50
         2          1              50
         3          1              50
       
SQL> select group# , member from v$logfile;
    GROUP# MEMBER
---------- --------------------------------------------------
         3 /u01/app/oracle/oradata/prim/redo03.log
         2 /u01/app/oracle/oradata/prim/redo02.log
         1 /u01/app/oracle/oradata/prim/redo01.log       
       
       
SQL> alter database add standby logfile group 4 '/u01/app/oracle/oradata/prim/redos4A.log' size 50M;
SQL> alter database add standby logfile group 5 '/u01/app/oracle/oradata/prim/redos5A.log' size 50M;
SQL> alter database add standby logfile group 6 '/u01/app/oracle/oradata/prim/redos6A.log' size 50M;
SQL> alter database add standby logfile group 7 '/u01/app/oracle/oradata/prim/redos7A.log' size 50M;

SQL> select group# , member from v$logfile;
    GROUP# MEMBER
---------- --------------------------------------------------------------------------------
         3 /u01/app/oracle/oradata/prim/redo03.log
         2 /u01/app/oracle/oradata/prim/redo02.log
         1 /u01/app/oracle/oradata/prim/redo01.log
         4 /u01/app/oracle/oradata/prim/redos4A.log
         5 /u01/app/oracle/oradata/prim/redos5A.log
         6 /u01/app/oracle/oradata/prim/redos6A.log
         7 /u01/app/oracle/oradata/prim/redos7A.log


At standby database:-
Now once the redoglogs have been created in primary database,we will create the following RMAN run commands and  the changes to the standby’s spfile in this RMAN block.

[oracle@server2 ]rman target sys/redhat@prim auxiliary sys/redhat@stand   
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Sep 7 14:43:25 2015

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

connected to target database: PRIM (DBID=4130009889)
connected to auxiliary database: PRIM (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 'prim','stand'
set db_unique_name='stand'
set db_file_name_convert='/u01/app/oracle/oradata/prim/','/u01/app/oracle/oradata/stand/'
set log_file_name_convert='/u01/app/oracle/oradata/prim/','/u01/app/oracle/oradata/stand/'
set control_files='/u01/app/oracle/oradata/stand/control01.ctl','/u01/app/oracle/oradata/stand/control02.ctl'
set log_archive_max_processes='10'
set fal_client='stand'
set fal_server='prim'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(prim,stand)'
set log_archive_dest_2='service=prim ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prim'
;
}

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

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

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

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

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

Starting Duplicate Db at 16-MAY-13

contents of Memory Script:
{
 backup as copy reuse
 targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwprim' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwstand' targetfile
 '/u01/app/oracle/product/11.2.0/db_1/dbs/spfileprim.ora' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/spfilestand.ora' ;
 sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilestand.ora''";
}
executing Memory Script

Starting backup at 16-MAY-13
Finished backup at 16-MAY-13

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilestand.ora''

contents of Memory Script:
{
 sql clone "alter system set audit_file_dest =
 ''/u01/app/oracle/oradata/dump/stand/adump'' comment=
 '''' scope=spfile";
 sql clone "alter system set diagnostic_dest =
 ''/u01/app/oracle/oradata/dump/stand'' comment=
 '''' scope=spfile";
 sql clone "alter system set log_archive_dest_1 =
 ''location=use_db_recovery_file_dest valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=stand'' comment=
 '''' scope=spfile";
 sql clone "alter system set db_unique_name =
 ''stand'' comment=
 '''' scope=spfile";
 sql clone "alter system set db_file_name_convert =
 ''/u01/app/oracle/oradata/prim/prim/datafile/'', ''/u01/app/oracle/oradata/stand/stand/datafile/'' comment=
 '''' scope=spfile";
 sql clone "alter system set log_file_name_convert =
 ''/u01/app/oracle/oradata/prim/prim/onlinelog/'', ''/u01/app/oracle/oradata/stand/stand/onlinelog/'' comment=
 '''' scope=spfile";
 sql clone "alter system set control_files =
 ''/u01/app/oracle/oradata/stand/control/control01.ctl'', ''/u01/app/oracle/oradata/stand/control/control02.ctl'' comment=
 '''' scope=spfile";
 sql clone "alter system set log_archive_max_processes =
 10 comment=
 '''' scope=spfile";
 sql clone "alter system set fal_client =
 ''stand'' comment=
 '''' scope=spfile";
 sql clone "alter system set fal_server =
 ''prim'' 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=(prim,stand)'' comment=
 '''' scope=spfile";
 sql clone "alter system set log_archive_dest_2 =
 ''service=prim ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prim'' comment=
 '''' scope=spfile";
 shutdown clone immediate;
 startup clone nomount;
}
executing Memory Script

sql statement: alter system set audit_file_dest = ''/u01/app/oracle/oradata/dump/stand/adump'' comment= '''' scope=spfile

sql statement: alter system set diagnostic_dest = ''/u01/app/oracle/oradata/dump/stand'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_1 = ''location=use_db_recovery_file_dest valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=stand'' comment= '''' scope=spfile

sql statement: alter system set db_unique_name = ''stand'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/prim/prim/datafile/'', ''/u01/app/oracle/oradata/stand/stand/datafile/'' comment= '''' scope=spfile

sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/oradata/prim/prim/onlinelog/'', ''/u01/app/oracle/oradata/stand/stand/onlinelog/'' comment= '''' scope=spfile

sql statement: alter system set control_files = ''/u01/app/oracle/oradata/stand/control/control01.ctl'', ''/u01/app/oracle/oradata/stand/control/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set log_archive_max_processes = 10 comment= '''' scope=spfile

sql statement: alter system set fal_client = ''stand'' comment= '''' scope=spfile

sql statement: alter system set fal_server = ''prim'' 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=(prim,stand)'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_2 = ''service=prim ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prim'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 534462464 bytes

Fixed Size 2230072 bytes
Variable Size 163580104 bytes
Database Buffers 364904448 bytes
Redo Buffers 3747840 bytes
allocated channel: stby
channel stby: SID=18 device type=DISK

contents of Memory Script:
{
 backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/stand/control/control01.ctl';
 restore clone controlfile to '/u01/app/oracle/oradata/stand/control/control02.ctl' from
 '/u01/app/oracle/oradata/stand/control/control01.ctl';
}
executing Memory Script

Starting backup at 16-MAY-13
channel prmy1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_prim.f tag=TAG20130516T084319 RECID=7 STAMP=815561001
channel prmy1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 16-MAY-13

Starting restore at 16-MAY-13

channel stby: copied control file copy
Finished restore at 16-MAY-13

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

sql statement: alter database mount standby database

contents of Memory Script:
{
 set newname for tempfile 1 to
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_temp_8qbok7fk_.tmp";
 switch clone tempfile all;
 set newname for datafile 1 to
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_system_8ocl7bho_.dbf";
 set newname for datafile 2 to
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sysaux_8ocl7k6n_.dbf";
 set newname for datafile 3 to
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf";
 set newname for datafile 4 to
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_users_8qbolh3g_.dbf";
 backup as copy reuse
 datafile 1 auxiliary format
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_system_8ocl7bho_.dbf" datafile
 2 auxiliary format
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sysaux_8ocl7k6n_.dbf" datafile
 3 auxiliary format
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf" datafile
 4 auxiliary format
 "/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_users_8qbolh3g_.dbf" ;
 sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/stand/stand/datafile/o1_mf_temp_8qbok7fk_.tmp in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 16-MAY-13
channel prmy1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/prim/prim/datafile/o1_mf_system_8ocl7bho_.dbf
channel prmy2: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/prim/prim/datafile/o1_mf_sysaux_8ocl7k6n_.dbf
channel prmy3: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/prim/prim/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf
channel prmy4: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/prim/prim/datafile/o1_mf_users_8qbolh3g_.dbf
output file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf tag=TAG20130516T084335
channel prmy3: datafile copy complete, elapsed time: 00:00:45
output file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_users_8qbolh3g_.dbf tag=TAG20130516T084335
channel prmy4: datafile copy complete, elapsed time: 00:00:55
output file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_system_8ocl7bho_.dbf tag=TAG20130516T084335
channel prmy1: datafile copy complete, elapsed time: 00:01:05
output file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sysaux_8ocl7k6n_.dbf tag=TAG20130516T084335
channel prmy2: datafile copy complete, elapsed time: 00:01:05
Finished backup at 16-MAY-13

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=7 STAMP=815561103 file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_system_8ocl7bho_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=815561104 file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sysaux_8ocl7k6n_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=815561104 file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=815561104 file name=/u01/app/oracle/oradata/stand/stand/datafile/o1_mf_users_8qbolh3g_.dbf
Finished Duplicate Db at 16-MAY-13
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4
released channel: stby

RMAN> exit

Now at standby database:-

SQL>shut immediate;
SQL>startup mount
SQL>alter database recover managed standby database disconnect from session;

Now for real time apply:-

SQL> alter database recover managed standby database cancel;

SQL> alter database open;

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

SQL>select open_mode from v$database; (Output : read only with apply)


There are various ways to see if this is working or not. You can use it in the following query to see what was the last archive received/applied in the Standby Database.

On standby database

SQL> SELECT 'Last Applied : ' Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log WHERE applied='YES'
)
UNION
SELECT 'Last Received : ' Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS') TIME,thread#,sequence#
FROM v$archived_log
WHERE sequence# =
(SELECT MAX(sequence#) FROM v$archived_log );

LOGS             TIME                  THREAD#  SEQUENCE#
---------------- ------------------ ---------- ----------
Last Applied :   07-SEP-15:11:53:22          1         17
Last Received :  07-SEP-15:11:53:22          1         17
While in the Primary Database, you can check what is the current sequence and what is the pending sequence to be applied.

On primary database

SQL> SELECT
 (SELECT name FROM V$DATABASE
 ) name,
 (SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
 ) Current_primary_seq,
 (SELECT MAX (sequence#)
 FROM v$archived_log
 WHERE TRUNC(next_time) > SYSDATE - 1
 AND dest_id = 2
 ) max_stby,
 (SELECT NVL (
 (SELECT MAX (sequence#) - MIN (sequence#)
 FROM v$archived_log
 WHERE TRUNC(next_time) > SYSDATE - 1
 AND dest_id = 2
 AND applied = 'NO'
 ), 0)
 FROM DUAL
 ) "To be applied",
 (
 (SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 1
 ) -
 (SELECT MAX (sequence#) FROM v$archived_log WHERE dest_id = 2
 )) "To be Shipped"
FROM DUAL;

NAME      CURRENT_PRIMARY_SEQ   MAX_STBY To be applied To be Shipped
--------- ------------------- ---------- ------------- -------------
PRIM                       17         17             0             0


Finally Test on primary database to check if the datas are being replicated to standby or not
SQL> create user soumya identified by soumya;
SQL>grant connect , resource to soumya;
SQL> conn soumya/soumya
SQL>create table test (id number);
SQL>insert into test values(1);
SQL> /
SQL> /
SQL> commit;

Now on standby database:-
sqlplus soumya/soumya

SQL> select * from test;

        ID
----------
         1
         1
       
So we can see the datas are applying on standby real time.



Please share your ideas and opinions about this topic.

If you like this post, then please share with others.
Please subscribe on email for every updates on mail.      

Nenhum comentário:

Postar um comentário

Related Posts Plugin for WordPress, Blogger...