Data Guard Physical Standby Setup in Oracle Database 11g
Data guard is Technology by Oracle, used for disaster recovery and high availability so Data guard, They have many ways to implement but This article contains Manual steps and Duplicate steps.
Step to set Data Guard
On Primary
On Standby
Role Transitions
|
Environment
Source (Primary) |
Target (Standby) |
IP Address : 192.168.75.140 Hostname : dblabt1 DB Name : DB11G Unique Name : DB11G Port : 1521 Version : 11.2.0.1 |
IP Address : 192.168.75.139 Hostname : dblabt3 DB Name : DB11G Unique Name : DB11G_STDBY Port : 1521 Version : 11.2.0.1 |
Setup Connection between Primary and Standby
On Primary
Location file (listener.ora and tnsnames.ora)
$ORACLE_HOME/network/admin/listener.ora
$ORACLE_HOME/network/admin/tnsnames.ora
Listener.oraLISTENER_DB11G = SID_LIST_LISTENER_DB11G = |
tnsnames.oraDB11G = DB11G_STDBY = |
On Standby
listener.oraLISTENER_DB11G_STDBY = SID_LIST_LISTENER_DB11G_STDBY = |
tnsnames.oraDB11G_STDBY = DB11G = |
On Primary
- check archive log mode
if your database is no archivelog mode, You must set it to archivelog mode
SQL> SELECT log_mode FROM v$database;
LOG_MODE SQL> ALTER SYSTEM SET log_archive_dest_1=’LOCATION=/home/oracle/arch’; System altered. SQL> shutdown immediate; Total System Global Area 1068937216 bytes Database altered. SQL> alter database open; Database altered. SQL> SELECT log_mode FROM v$database; LOG_MODE |
- set up parameter on primary for data guard
location :: $ORACLE_HOME/dbs/initxxxx.ora
alter system set log_archive_config=’dg_config=(DB11G,DB11G_STDBY)’ scope=both; alter system set LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=DB11G’ scope=both; alter system set LOG_ARCHIVE_DEST_2=’SERVICE=DB11G_STDBY VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB11G_STDBY’ scope=both; alter system set log_archive_dest_state_1=ENABLE scope=both; alter system set log_archive_dest_state_2=ENABLE scope=both; alter system set standby_file_management=AUTO scope=both; alter system set standby_archive_dest=’/home/oracle/arch’ scope=both; alter system set FAL_SERVER=DB11G_STDBY scope=both; alter system set FAL_CLIENT=DB11G scope=both; |
- backup database with archivelog (device type disk) (send bk file to standby, in case, if you want to manually restore for data guard)
$ rman target /
RUN RMAN> exit $ scp -rp /home/oracle/rman_bk oracle@192.168.75.139:/home/oracle |
- create pfile and send to standby (send to the same path as primary)
SQL> create pfile=’/home/oracle/initdb11g_stdby.ora’ from spfile;
File created. SQL> exit $scp /home/oracle/initdb11g_stdby.ora oracle@192.168.75.139:/home/oracle/product/11.2.0/db/dbs |
- create controlfile for standby and send to standby (send to the same path as primary)
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘/home/oracle/db11g_stdby.ctl’;
Database altered. SQL> exit $ scp db11g_stdby.ctl oracle@192.168.75.139:/home/oracle/oradata/DB11G/control01.ctl |
- Create Standby logfile
create standby logfile for configured to switchover task. on Standby create automatically when you make standby by duplicate.
SQL> alter database add standby logfile group 4; Database altered.SQL> alter database add standby logfile group 5; Database altered.SQL> alter database add standby logfile group 6; Database altered.SQL> select * from v$logfile;GROUP# STATUS TYPE MEMBER IS_ ———- ——- ——- ————————————— — 3 ONLINE /home/oracle/oradata/DB11G/redo03_1.log NO 3 ONLINE /home/oracle/oradata/DB11G/redo03_2.log NO 2 ONLINE /home/oracle/oradata/DB11G/redo02_1.log NO 2 ONLINE /home/oracle/oradata/DB11G/redo02_2.log NO 1 ONLINE /home/oracle/oradata/DB11G/redo01_1.log NO 1 ONLINE /home/oracle/oradata/DB11G/redo01_2.log NO 4 STANDBY /home/oracle/flash_recovery_area/DB11G/onlinelog/o1_mf_4_g84woh1m_.log YES 5 STANDBY /home/oracle/flash_recovery_area/DB11G/onlinelog/o1_mf_5_g84wovm3_.log YES 6 STANDBY /home/oracle/flash_recovery_area/DB11G/onlinelog/o1_mf_6_g84wp4t5_.log |
On Standby
- Check and edit pfile.
DB11G.__db_cache_size=444596224 DB11G.__java_pool_size=4194304 DB11G.__large_pool_size=4194304 DB11G.__oracle_base=’/home/oracle’#ORACLE_BASE set from environment DB11G.__pga_aggregate_target=432013312 DB11G.__sga_target=641728512 DB11G.__shared_io_pool_size=0 DB11G.__shared_pool_size=176160768 DB11G.__streams_pool_size=0 *.audit_file_dest=’/home/oracle/admin/DB11G/adump’ *.compatible=’11.2.0.0.0′ *.control_files=’/home/oracle/oradata/DB11G/control01.ctl’,’/home/oracle/flash_recovery_area/DB11G/control02.ctl’ *.core_dump_dest=’/home/oracle/diag/rdbms/db11g/DB11G/cdump’ *.db_block_size=8192 *.db_domain=” *.db_name=’DB11G’ *.db_recovery_file_dest=’/home/oracle/flash_recovery_area’ *.db_recovery_file_dest_size=4070572032 *.db_unique_name=’DB11G_STDBY’ *.dg_broker_start=FALSE *.diagnostic_dest=’/home/oracle’ *.dispatchers='(PROTOCOL=TCP) (SERVICE=DB11GXDB)’ *.fal_client=’DB11G_STDBY’ *.fal_server=’DB11G’ *.fast_start_mttr_target=300 *.job_queue_processes=20 *.local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.75.139)(PORT=1521)))’ *.log_archive_config=’dg_config=(db11g,db11g_stdby)’ *.log_archive_dest_1=’LOCATION=/home/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db11g_stdby’ *.log_archive_dest_2=’SERVICE=db11g VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db11g’ *.log_archive_dest_state_1=’ENABLE’ *.log_archive_dest_state_2=’ENABLE’ *.log_archive_format=’db11g_%t_%s_%r.dbf’ *.log_archive_max_processes=2 *.open_cursors=300 *.processes=150 *.query_rewrite_enabled=’FALSE’ *.remote_login_passwordfile=’EXCLUSIVE’ *.standby_file_management=’AUTO’ *.star_transformation_enabled=’FALSE’ *.timed_statistics=TRUE *.undo_management=’AUTO’ |
- Check the Connection and create a password file
$ sqlplus sys@db11g_stdby as sysdba
$ tnsping db11g_stdby $ orapwd file=$ORACLE_HOME/dbs/orapwDB11G password=xxxxxxxx entries=10 ignorecase=Y |
- Restore for Standby (Manual step)
startup database with pfile only.
$export ORACLE_SID=DB11G
$ sqlplus “/as sysdba” SQL> startup pfile=’/home/oracle/initdb11g_stdby.ora’ nomount; SQL> alter database mount; SQL> create spfile from pfile=’/home/oracle/initdb11g_stdby.ora’ ; $ rman target / RMAN> RMAN> restore database; |
- Restore for Standby (Duplicate)
rman TARGET sys/syspassword@DB11G AUXILIARY sys/syspassword@DB11G_STDBY
run { if you already edit pfile just use the command below. run { |
- check the role database and Start Apply process (mrp0 process)
$ sqlplus “/as sysdba”
SQL> select name,database_role,OPEN_MODE from v$database; NAME DATABASE_ROLE OPEN_MODE SQL> select process from v$managed_standby; PROCESS SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; Database altered. SQL> select process from v$managed_standby; PROCESS |
- Test log transport on primary
On PrimarySQL> alter switch logfile; On Standby (check alert log)Location Alertlog file :: $ORACLE_BASE/diag/rdbms/db11g/DB11G_STDBY/trace In alterlog file shown below. Media Recovery Log /home/oracle/arch/db11g_1_16_999272166.dbf ****Note**** Media Recovery xxxxx, it’s mean, it already apply archivelog. |
finished to make Data Guard.
Role Transitions
- Test Switchover
- Test Failover