I. Data Guard
Oracle data guard used to make database configuration, primary database with one or more standby database (copy from primary database). Oracle Data Guard ensure high availability, data protection, and disaster recovery with more quick recovery time when the primary database got crashed, because standby database can be easily switchover from standby database to primary database.
II. Data Guard Configuration
Oracle Data Guard Configuration consist of on database production (primary database) and one or more standby database.Production and standby database connected through oracle net
II.1 Primary Database
Primary database is the operasional database accessed by users or aplications.
II.2 Standby Database
Standby database is copy from primary database. Production and standby database connected through oracle net. Primary database send archive log to standby database and then archived log will be apply in the standby database.
III. Installation steps Oracle Data Guard
III.1 Oracle software install
For this post i’m using O/S Red Hat Enterprise Linux AS release 4 (Nahant Update 7) 64 bit and Oracle 10.2.0.1. When we install the Oracle 10.2.0.1 we have to choose Installation type Enterprise Edition, because it have oracle data guard feature.
Do Oracle installation on production database and standby database with installation type Enterprise Edition.
In production database we install Oracle with the database (the database instance named borneodb)
In standby database install just install the oracle instance , because the database for standby database is copy from primary database (cold backup primary and the restore tostandby).
III.2 Preparation in production database (oraDBServer1) for data guard installation
There are many things that we hav e to prepare before configuring database for oracle database and create the standby database using oracle data guard configuration :
1.Enable Force Logging
After oracle installation and database installation had completed we have to alter database to force logging mode with this sql below :
SQL> ALTER DATABASE FORCE LOGGING;
2.Make a Password file
$ orapwd file=orapw password=top_secret
3.Make standby redo log
alter database add standby logfile group 6
(‘/u01/app/oracle/oradata/borneodb/DRCREDO_01.log’) size 5242880;
To see the redo log file in primary we can use this query : select * from v$logfile;
From Oracle documentation ‘A standby redo log is required for the maximum protection and maximum availability modes and the LGWR ASYNC transport mode is recommended for all databases. Data Guard can recover and apply more redo data from a standby redo log than from archived redo log files alone. ‘
4.Init file for data guard configuration
Make init file from spfile with command :
SQL> create pfile=’$ORACLE_HOME/dbs/initborneodb.ora’ from spfile
Then edit pfile for data guard configuration :
borneodb.__db_cache_size=1207959552
borneodb.__java_pool_size=16777216
borneodb.__large_pool_size=16777216
borneodb.__shared_pool_size=352321536
borneodb.__streams_pool_size=0
db_name=’borneodb’
db_unique_name=’borneodb’
service_names=’borneodb’
fal_client=’borneodb’
fal_server=’borneodrc’
log_archive_config=’dg_config=(borneodb,borneodrc)’
log_archive_dest_1=’LOCATION=/data/oracle/borneodb/archived’
log_archive_dest_2=’service=BORNEODBDRC valid_for=(ALL_LOGFILES,PRIMARY_ROLES) db_unique_name=borneodrc lgwr async=20480′
log_archive_dest_state_1=’ENABLE’
log_archive_dest_state_2=’DEFER’
log_archive_format=’%t_%s_%r.dbf’
standby_archive_dest=’/data/oracle/borneodb/archived’
standby_file_management=’auto’
*.audit_file_dest=’/u01/app/oracle/admin/borneodb/adump’
*.background_dump_dest=’/u01/app/oracle/admin/borneodb/bdump’
*.compatible=’10.2.0.1.0′
5.Enable mode archive log
To activate archivelog mode :
SQL > Shutdown immediate;
SQL > Startup mount pfile=initborneodb.ora;
SQL > alter database archivelog;
6.Start data guard broker and check the status (untuk switchover)
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE;
SQL> SHOW PARAMETER DG_BROKER_START
7.Listener configuration for file LISTENER.ORA
Example :
LISTENER = (DESCRIPTION =
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)
(PORT=port_num))))
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=sid_name)
(GLOBAL_DBNAME=db_unique_name_DGMGRL.db_domain)
(ORACLE_HOME=oracle_home)))
LISTENER.ORA pada BORNEODDB :
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = borneodb_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = borneodb)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oraDBServer1)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
8.Make tnsnames.ora for connection to drc (borneodrc)
BORNEODB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oraDBServer1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = borneodb)
)
)
#ListenerForDRC
BORNEODBDRC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.128.16.126)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = borneodrc)
)
)
9.Create standby control file from primary to be copied to standby database
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘/data/standby_control01.ctl’;
SQL> SHUTDOWN IMMEDIATE;
10.Copy all database file from primary database to standby database
Copy datafile, standby control file, initialization file to standby database.
III.3 Preparation in standby database (oraDBServer2)
After Copy all database file from primary database to standby database have been completed :
1.Edit initialization parameter file from primary database for standby database (file $ORACLE_HOME/dbs/initborneodb.ora)
borneodb.__db_cache_size=1207959552
borneodb.__java_pool_size=16777216
borneodb.__large_pool_size=16777216
borneodb.__shared_pool_size=352321536
borneodb.__streams_pool_size=0
db_name=’borneodb’
db_unique_name=’borneodrc’
service_names=’borneodb’
fal_client=’borneodrc’
fal_server=’borneodb’
log_archive_config=’dg_config=(borneodb,borneodrc)’
log_archive_dest_1=’LOCATION=/data/oracle/borneodb/archived’
log_archive_dest_2=’service=borneodb valid_for=(ALL_LOGFILES,PRIMARY_ROLES) db_unique_name=borneodrc lgwr async=20480′
log_archive_dest_state_1=’ENABLE’
log_archive_dest_state_2=’DEFER’
log_archive_format=’%t_%s_%r.dbf’
standby_archive_dest=’/data/oracle/borneodb/archived’
standby_file_management=’auto’
*.audit_file_dest=’/u01/app/oracle/admin/borneodb/adump’
*.background_dump_dest=’/u01/app/oracle/admin/borneodb/bdump’
*.compatible=’10.2.0.1.0′
@
2.Edit file listener.ora dan start listener
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DNAME = borneodrc_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = borneodb)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = oraDBServer2)(PORT = 1521))
)
)
Start listener : #lsnrctl start
3.Startup mount and change database mode to manage standby
#sqlplus / as sysdba
SQL> startup mount pfile=’initborneodb.ora’;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
IV. START THE ORACLE DATA GUARD
1.in primary startup oracle using pfile that have been modified
#sqlplus / as sysdba
SQL> startup open pfile=’initborneodb.ora’
2.Di primary ubah log_archive_dest_state_2 menjadi ENABLE
SQL> Alter system set log_archive_dest_state_2=’ENABLE’;
3.Di primary lakukan log switch untuk pembuatan archive log
SQL> alter system switch logfile
4.Check status of redo log send from primary database to standby database :
SQL>select dest_id, destination, status, error from v$archive_dest;
See destination 2, destination to standby database. If archive from primary not standby has not sent, status column from above query will give error message. If archive log send from primary to standby database succes then the value of status column is VALID.
5.Monitor archived in standby database sent from primary database
SQL>select name,to_char(FIRST_TIME,’dd-mon-yy hh24:mi:ss’) TIME ,sequence#,applied from v$archived_log order by sequence#
6.Cek archive gap in standby database
SQL> select * from v$archive_gap;
7.Cek sequence in standby database is it already same with primary database
SQL>select max(sequence#) from v$log_history;
V. Cek standby database
To make sure the data guard configuration have been success and standby database identic with primary database we can alter standby database to open read only with these steps :
1.Login to sqlplus
#sqlplus / as sysdba
2.Do these sql below
SQL>alter database recover managed standby database cancel;
SQL>alter database open read only;
3.Query to check table :
Contoh : SQL>select * from tab; →check this on primary too.
4.to alter back to standby mode
alter database recover managed standby database disconnect from session;