Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

How will you configure physical standby in same server

Answer:                              
In this article i will explained about how to configure oracle physical standby dataguard in the same server
              PRIMARY(initkfc.ora)              STANDBY(initkfcd.ora)
dbname      -->         kfc                                             kfc
uniquename -->       u1                                             u2
--Check The Ip information
[root@test1 ~]# neat
[root@test1 ~]# /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D1:B2:76
          inet addr:192.168.211.130  Bcast:192.168.211.255  Mask:255.255.255.0
1)CREATE  LISTENER  AND  TNSNAMES FILE USING netca utility
[oracle@test1 admin]$ netca
--Configure the tns for both standby and primary
[oracle@production admin]$ vi tnsnames.ora
 
u1tns=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = production.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = u1)
    )
  )

u2tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = production.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = u2)
    )
  )
2)Configure the listener for both primary and standby database
[oracle@production admin]$ vi listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = production.localdomain)(PORT = 1521))
    )  
  )    
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = u1)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
    )
    (SID_DESC =
      (SID_NAME = u2)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
    )
 
  )                                                                           
3) create Directory FOR standby database at same server
[oracle@production ~]$ mkdir kfcd
[oracle@production ~]$ cd kfcd/
[oracle@oracle nij]$ mkdir admin oradata admin/create admin/diag admin/pfile oradata/control oradata/log oradata/data oradata/archive
[oracle@production ~]$ tree kfcd
kfcd
|-- admin
|   |-- create
|   |-- diag
|   `-- pfile
`-- oradata
    |-- archive
    |-- control
    |-- data
    `-- log
4)Edit  the pfile in existing database  and put in required dataguard parameter
VI initkfc.ora   
db_name=kfc
sga_target=400m
control_files='/home/oracle/kfc/oradata/control/control01.ctl'
diagnostic_dest='/home/oracle/kfc/admin/diag'
log_archive_config='DG_CONFIG=(u1,u2)'
 db_unique_name=u1
log_archive_dest_2='SERVICE=u2tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=u2'
db_file_name_convert='/home/oracle/kfcd/oradata/data','/home/oracle/kfc/oradata/data'
log_file_name_convert='/home/oracle/kfcd/oradata/log','/home/oracle/kfc/oradata/log'
fal_client=u1tns
fal_server=u2tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
5) After modified primary database pfile then restart that
SQL>startup pfile='/home/oracle/kfc/admin/pfile/initkfc.ora' force;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1339740 bytes
Variable Size             230690468 bytes
Database Buffers          599785472 bytes
Redo Buffers                5160960 bytes
Database mounted.
Database opened.
6)Add the two standby logfile in primary database
SQL> alter database add standby logfile group 3 '/home/oracle/kfc/oradata/log/std3.log' size 100m;
     
       Database altered.
  SQL> alter database add standby logfile group 4 '/home/oracle/kfc/oradata/log/std4.log' size 100m;
     
       Database altered.
 SQL> create spfile from pfile='/home/oracle/kfc/admin/pfile/initkfc.ora';              

    File created.

 SQL> shut immediate;
   Database closed.
   Database dismounted.
   ORACLE instance shut down.
7)Create the PASSWORD FILE FOR primary database then overwrite that to standby database like following tutorial here u1 called primary database unique name u2 means standby unique name if you create individual PASSWORDFILE means you will get heartbeat error that is why i copied from u1 to u2 .
[oracle@production ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@production dbs]$ export ORACLE_SID=kfc
[oracle@production dbs]$ orapwd file=orapwu1 password=sys force=y
[oracle@production dbs]$ cp orapwu1 orapwu2
8) Create the standby control file at primary database as mount stage 
SQL> startup mount;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1339740 bytes
Variable Size             230690468 bytes
Database Buffers          599785472 bytes
Redo Buffers                5160960 bytes
Database mounted.

SQL>alter database create standby controlfile as '/home/oracle/kfcd/oradata/control/control01.ctl';
   
    Database altered.
9)After shutdown the database copy the primary database datafile to standby datafile location if you configure dataguard other server you can send that data through scp
SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
[oracle@production ~]$ cp -r kfc/oradata/data/* kfcd/oradata/data/
[oracle@production ~]$
10)copy the primay pfile and send it to the standby pfile location the change the dataguard parameter as per standby
[oracle@production ~]$ cp -r kfc/admin/pfile/initkfc.ora kfcd/admin/pfile/
[oracle@production ~]$ mv  kfcd/admin/pfile/initkfc.ora   kfcd/admin/pfile/initkfcd.ora
[oracle@production ~]$ vi kfcd/admin/pfile/initkfcd.ora

db_name=kfc
sga_target=400m
control_files='/home/oracle/kfcd/oradata/control/control01.ctl'
diagnostic_dest='/home/oracle/kfcd/admin/diag'
log_archive_config='DG_CONFIG=(u2,u1)'
db_unique_name=u2
log_archive_dest_2='SERVICE=u1tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=u1'
db_file_name_convert='/home/oracle/kfc/oradata/data','/home/oracle/kfcd/oradata/data'
log_file_name_convert='/home/oracle/kfc/oradata/log','/home/oracle/kfcd/oradata/log'
fal_client=u2tns
fal_server=u1tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
11) start the standby databse untill nomount stage then mount the database as standby using " standby " keyword then open the database if you are using 10g means it will come until mount stage but 11g will be come to open stage  this is why 11gr2 called active dataguard.
[oracle@test1 ~]$ export ORACLE_SID=kfcd
[oracle@test1 ~]$ sqlplus / as sysdba
SQL> startup pfile='/home/oracle/kfcd/admin/pfile/initkfcd.ora' nomount;
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1339740 bytes
Variable Size             230690468 bytes
Database Buffers          599785472 bytes
Redo Buffers                5160960 bytes

SQL> alter database mount standby database;

Database altered.

SQL> alter database open;

Database altered.
12)create the pfile for primary unique database for you want to connect unique name
[oracle@production ~]$ export ORACLE_SID=u1
[oracle@production ~]$ sqlplus / as sysdba

SQL> startup pfile='/home/oracle/kfc/admin/pfile/initkfc.ora';
ORACLE instance started.

Total System Global Area  836976640 bytes
Fixed Size                  1339740 bytes
Variable Size             230690468 bytes
Database Buffers          599785472 bytes
Redo Buffers                5160960 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/home/oracle/kfc/admin/pfile/initkfc.ora';

File created.
13)create pfile for standby unique databse
[oracle@production ~]$ export ORACLE_SID=u2
[oracle@production ~]$ sqlplus / as sysdba

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

Total System Global Area  836976640 bytes
Fixed Size                  1339740 bytes
Variable Size             230690468 bytes
Database Buffers          599785472 bytes
Redo Buffers                5160960 bytes
SQL>alter database mount standby database;

Database altered.

SQL> alter database open;

Database altered.

SQL> create spfile from pfile='/home/oracle/kfcd/admin/pfile/initkfcd.ora';

File created.
14)Starting sync
SQL>recover managed standby database disconnect from session;
Media recovery complete.


15)REAL TIME APPLY
SQL> recover managed standby database using current logfile disconnect from session;
Media recovery complete.


16)STOPING SYNC
SQL> recover managed standby database cancel;
Media recovery complete.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     378
Next log sequence to archive   0
Current log sequence           379



17)CHECK THE DATABASE ROLE WHETHER PHYSICAL OR LOGICAL AT STANDBY

SQL> select name,db_unique_name,database_role from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE
--------- ------------------------------ ----------------
KFC       u2                             PHYSICAL STANDBY
18)AT PRIMARY
SQL> select name,db_unique_name,database_role from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE
--------- ------------------------------ ----------------
KFC       u1                             PRIMARY
19)FOR SYNC CHECKING CREATE THE TABLE THE SWITCH THE LOG FILE
SQL> create table kf(id number(10));

Table created.

SQL> alter system switch logfile;

System altered.

SQL> /
/
/

System altered.

SQL>
System altered.

SQL>
System altered.
20)CHECK THAT PRIMARY  TABLE IN STANDBY DB
SQL> desc kf;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER(38)

21)CHECK THE SEQUENCE AT PRIMARY
SQL>select APPLIED,CREATOR,SEQUENCE# from v$archived_log;
APPLIED   CREATOR  SEQUENCE#
--------- ------- ----------
YES       LGWR           415
NO        ARCH           415
NO        LGWR           416
NO        ARCH           416
22)AT STANDBY DB
SQL>select APPLIED,CREATOR,SEQUENCE# from v$archived_log;

APPLIED   CREATOR  SEQUENCE#
--------- ------- ----------
YES       ARCH           410
YES       ARCH           411
YES       ARCH           412
YES       ARCH           413
YES       ARCH           414
YES       ARCH           415
YES       ARCH           416

23)IF ANY ARCHIVE GAP OCCURS
select * from v$archive_gap;
Related Articles:




errors:-
ORA-16187: LOG_ARCHIVE_CONFIG contains duplicate
if given log_archive_config='DG_CONFIG(u1,u2)'
solution:-
log_archive_config='DG_CONFIG=(u1,u2)'

                                                                               
                                                                                             
                                                                                             
                                                                                             





                                                                                             
                                                                                             
                                                                                             
                                                                                             


Comments

Popular posts from this blog

VMWARE WORKSTATION 3,4,5,6,7,8,9,10,11,12,14,15...etc LICENSE KEYS COLLECTION

Top 10 Highest Paying URL Shortener Companies - Best URL Shorteners To Earn Fast

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

rman interview and scenario based questions and answer and also rman(backup and recovery) discussions panel

aireplay-ng