Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

How to configure physical cascade standby dataguard in oracle database

Answer:
In this article i will explained step by step how to setup  cascade standby  dataguard in oracle database here i wrote a shell script for dataguard setup it will be finish your dataguard setup within 15-30 minutes
                  PRIMARY(initd1.ora) STANDBY1(initd2.ora)  STANDBY2(initd3.ora)
db_name        --> d1                           d1                 d1
db_unique_name --> d1                           d2                 d3
directory_name --> d1                           d2                 d3
server_ip      --> 192.168.62.128       192.168.62.129       192.168.62.130
tns_name       --> d1tns                        d2tns              d3tns
**********************************************************************************
short steps:
step 0) Install the same version of OS and oracle software
step 1) create the rquired directory for two standby
step 2)run the "dbd1.sh" script  at primary it will create the new db with dataguard parameter
step 3) Configure the Tns and Listener for all server(3 server ) and start the all listner then ping the all server (Eexple. ping 192.168.62.129,.....)
step 4)shut down the primary database then send primary datafile ,pfile and control file  to 2 standby server using  scp
step 5)Run this script at standby1 server this will create the database using below pfile script
step 6)Run this script at standby2 server this will create the database using below pfile script
step 7)Start up the standby1 server as standby database then start the standby2 same as standby1 then start the primary database
-------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>------------->>>>>>>>>>>>
1) create the directory for two  standby databse

for standby1
cd
mkdir d2
cd d2
mkdir admin oradata
cd admin
mkdir pfile diag create
cd ..
cd oradata
mkdir control log archive data
cd
tree d2

for standby 2
cd
mkdir d3
cd d3
mkdir admin oradata
cd admin
mkdir pfile diag create
cd ..
cd oradata
mkdir control log archive data
cd
tree d3
----->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-------------------->>>>>>>>>>>>>>>>>>>>>>>
2)Run this script at primary database this following shell script will be create the new database including  dataguard parameter also it will create the PASSWORD file
vi dbd1.sh     
mkdir d1
cd d1
mkdir admin oradata
cd admin
mkdir pfile diag create
cd ..
cd oradata
mkdir control log archive data
cd
cp /home/oracle/pfd1  /home/oracle/d1/admin/pfile/initd1.ora
cd
export ORACLE_SID=d1
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/d1/admin/pfile/initd1.ora' nomount;
create database d1
datafile '/home/oracle/d1/oradata/data/system01.dbf' size 400m
sysaux datafile '/home/oracle/d1/oradata/data/systemaux01.dbf' size 300m
undo tablespace undo01 datafile '/home/oracle/d1/oradata/data/undo01.dbf' size 100m
default temporary tablespace temp01 tempfile '/home/oracle/d1/oradata/data/temp01.dbf' size 100m
logfile group 1 '/home/oracle/d1/oradata/log/log01.log' size 10m,
        group 2 '/home/oracle/d1/oradata/log/log02.log' size 10m;
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
create spfile from pfile='/home/oracle/d1/admin/pfile/initd1.ora';
alter database add standby logfile group 3 '/home/oracle/d1/oradata/log/std3.log' size 100m;
alter database add standby logfile group 4 '/home/oracle/d1/oradata/log/std4.log' size 100m;
create table kf(id number(10));
create tablespace tbs datafile '/home/oracle/d1/oradata/data/tbs.dbf' size 500m;
alter database close;
alter database archivelog;
shut immediate;

!
EOF
export ORACLE_SID=d1
sqlplus / as sysdba   <<EOF
startup pfile='/home/oracle/d1/admin/pfile/initd1.ora';
create spfile from pfile='/home/oracle/d1/admin/pfile/initd1.ora';
alter database close;
alter database create standby controlfile as '/home/oracle/control01.ctl';
shut immediate;
!cd $ORACLE_HOME/dbs
!export ORACLE_SID=d1
!orapwd file=orapwd1 password=sys force=y
!cp $ORACLE_HOME/dbs/orapwk1 /home/oracle/orapwd2
!cp $ORACLE_HOME/dbs/orapwk1 /home/oracle/orapwd3

EOF
---------------------------------------------------------------------
This is for primary database pfile after executed dbd1.sh script this pfd1 file will be copied to (/home/oracle/d1/admin/pfile/initd1.ora) primary initialization file
vi home/oracle/pfd1
db_name=d1
sga_target=600m
control_files='/home/oracle/d1/oradata/control/control01.ctl'
diagnostic_dest='/home/oriacle/d1/admin/diag'
log_archive_config='DG_CONFIG=(d1,d2,d3)'
db_unique_name=d1
log_archive_dest_2='SERVICE=d2tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=d2'
log_archive_dest_3='SERVICE=d3tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=d3'
db_file_name_convert='/home/oracle/d2/oradata/data','/home/oracle/d1/oradata/data'
log_file_name_convert='/home/oracle/d2/oradata/log','/home/oracle/d1/oradata/log'
fal_client=d1tns
fal_server=d2tns,d3tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
------->>>>>>>>>>>>>>>>>-------------------->>>>>>>>>>>>>>>-------------------->>>>>>>
3)primary database listener and tns    
]$ cd $ORACLE_HOME/network/admin
 vi listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.128)(PORT = 1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = d1)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
    )
tnsnames.ora

d1tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d1)
    )
  )
d2tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = k2)
    )
  )
d3tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = k3)
    )
  )
------------------------------------------------------------------------

standby1 listener and tns
]$ cd $ORACLE_HOME/network/admin

vi listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.129)(PORT = 1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = d2)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
     )

  )
tnsnames.ora


d1tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = k1)
    )
  )
k2tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d2)
    )
  )

d3tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d3)
    )
  )
-----------------------------------------------------------------------
Standby2 listener and tns
]$ cd $ORACLE_HOME/network/admin
vi listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.130)(PORT = 1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = d3)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
     )

  )
tnsnames.ora


d1tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d1)
    )
  )
d2tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d2)
    )
  )
d3tns =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.62.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = d3)
    )
  )
--start the listner then check the firewall
[root@localhost6 ~]# /sbin/ifconfig
[root@localhost6 ~]# neat
[root@localhost6 ~]# service network restart
[root@test3 ~]# service iptables status
Firewall is stopped.
[root@test3 ~]# service iptables stop
[root@test3 ~]#
-------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>----------->>>>>>>>>>>>>>>>>

4)shut down the primary database then send primary datafile ,pfile and control file  to 2 standby server using  scp
shut immediate;
send datafile and controlfile  to  standby 1:-
scp /home/oracle/control01.ctl  oracle@192.168.62.129:/home/oracle/d2/oradata/control/
             (copy paste individual)
scp /home/oracle/d1/oradata/data/* oracle@192.168.62.129:/home/oracle/d2/oradata/data/
              (copy paste individual)
scp /home/oracle/orapwd2   oracle@192.168.62.129:/home/oracle/
send datafile and controlfile  to standby 2:-
scp /home/oracle/control01.ctl  oracle@192.168.62.130:/home/oracle/d3/oradata/control/
             (copy paste individual)
scp /home/oracle/d1/oradata/data/* oracle@192.168.62.130:/home/oracle/d3/oradata/data/
              (copy paste individual)
scp /home/oracle/orapwd3   oracle@192.168.62.130:/home/oracle/
Note:don't open the primary database if you open the primary database before opening slave you will get recovery needed errors
-------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>----------->>>>>>>>>>>>>>>>>

5)Run this script at standby1 server this will create the database using below pfile script
vi dbd2.sh
cp /home/oracle/pfd2 /home/oracle/d2/admin/pfile/initd2.ora
cd $ORACLE_HOME/dbs
rm orapwd2
cd
export ORACLE_SID=d2      
mv /home/oracle/orapwd2 $ORACLE_HOME/dbs
cd
export ORACLE_SID=d2
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/d2/admin/pfile/initd2.ora' nomount;
alter database mount standby database;
alter database open;
alter database recover managed standby database disconnect from session;
create spfile from pfile='/home/oracle/d2/admin/pfile/initd2.ora';
shut immediate;

!
EOF
export ORACLE_SID=d1  
sqlplus / as sysdba  <<EOF
startup pfile='/home/oracle/d2/admin/pfile/initd2.ora' nomount;
alter database mount standby database;
alter database open;
alter database recover managed standby database disconnect from session;
create spfile from pfile='/home/oracle/d2/admin/pfile/initd2.ora';
EOF
--------------------------------------------------------------------------
This is standby2 database pfile after executed dbd2.sh script this pfd2 file will be copied to (/home/oracle/d2/admin/pfile/initd2.ora) primary initialization file
vi pfd2
db_name=d1
sga_target=600m
control_files='/home/oracle/d2/oradata/control/control01.ctl'
diagnostic_dest='/home/oracle/d2/admin/diag'
log_archive_config='DG_CONFIG=(d2,d1)'
db_unique_name=d2
log_archive_dest_2='SERVICE=d1tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=d1'
db_file_name_convert='/home/oracle/d1/oradata/data','/home/oracle/d2/oradata/data'
log_file_name_convert='/home/oracle/d1/oradata/log','/home/oracle/d2/oradata/log'
fal_client=d2tns
fal_server=d1tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>---------------->>>>>>>>>>>>>>>>>>>-------
6)Run this script at standby2 server this will create the database using below pfile script
vi dbd3.sh
cp /home/oracle/pfd3 /home/oracle/d3/admin/pfile/initd3.ora
cd $ORACLE_HOME/dbs
rm orapwd3
export ORACLE_SID=d3
mv /home/oracle/orapwd3 $ORACLE_HOME/dbs
cd
export ORACLE_SID=d3
sqlplus / as sysdba <<EOF
startup pfile='/home/oracle/d3/admin/pfile/initd3.ora' nomount;
alter database mount standby database;
alter database open;
alter database recover managed standby database disconnect from session;
create spfile from pfile='/home/oracle/d3/admin/pfile/initd3.ora';
shut immediate;

!
EOF
export ORACLE_SID=d1  
sqlplus / as sysdba  <<EOF
startup pfile='/home/oracle/d3/admin/pfile/initd3.ora' nomount;
alter database mount standby database;
alter database open;
alter database recover managed standby database disconnect from session;
create spfile from pfile='/home/oracle/d3/admin/pfile/initd3.ora';
EOF

--------------------------------------------------------------------------------
This is standby3 database pfile after executed dbd3.sh script this pfd3 file will be copied to (/home/oracle/d3/admin/pfile/initd3.ora) primary initialization file
vi pfd3 
db_name=d1
sga_target=600m
control_files='/home/oracle/d3/oradata/control/control01.ctl'
diagnostic_dest='/home/oracle/d3/admin/diag'
log_archive_config='DG_CONFIG=(d3,d2,d1)'
db_unique_name=d3
log_archive_dest_2='SERVICE=d2tns ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=d2'
db_file_name_convert='/home/oracle/d2/oradata/data','/home/oracle/d3/oradata/data'
log_file_name_convert='/home/oracle/d2/oradata/log','/home/oracle/d3/oradata/log'
fal_client=d3tns
fal_server=d2tns,d1tns
standby_file_management=auto
remote_login_passwordfile=exclusive
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>------------>>>>>>>>>>>>>>>>>>>>>---------
7) Start up the standby1 server as standby database then start the standby2 same as standby1 then start the primary database 

At standby1 and standby2
startup nomount;
alter database mount standby database;
alter database open;

At Primary database 
startup
alter system switch logfile;

At standby1 and standby2
alter database recover managed standby database disconnect from session;

select name,db_unique_name,database_role,SWITCHOVER_STATUS from v$database;
select APPLIED,CREATOR,SEQUENCE# from v$archived_log;

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 ?

aireplay-ng

2017 Shortern URL - Other Website Like ADFOC.US