Primary Site:
Physical IPs: 192.168.1.1 , 192.168.1.2
VIPs: 192.168.1.3 , 192.168.1.4
DB_Unique_Name: racdb
Standby Site:
Physical IPs: 192.168.2.1 , 192.168.2.2
VIPs: 192.168.2.3 , 192.168.2.4
DB_Unique_Name: racdr
##########################################
Steps on Production/Primary Server
1- Modify or add dataguard related init Parameters on production:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdr scope=both sid='*'; ----FAL server (typically this is the database running in the primary role).
alter system set FAL_Client='racdb' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
2- Enable Archivelog Mode:
srvctl stop database -d racdb
startup mount ----(only one instance)
alter database archivelog;
alter database force logging;
alter database open;
srvctl start database -d racdb ----This will start the remaining Instances on the cluster.
3- Tns Entries on all servers (copy these entires on both nodes of standby server),
Note that add new entries with VIP instead of scan name:
racdb =
(DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.3)(PORT=1521))
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521))
(CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
(SERVICE_NAME=racdb)))
racdr =
(DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.3)(PORT=1521))
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.4)(PORT=1521))
(CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
(SERVICE_NAME=racdr)))
4- Create the Standby Redo Logs (SRLs) on Primary and Standby:
alter system set standby_file_management=manual scope=both sid='*';
alter database add standby logfile thread 1 group 1 '+DATA/racdb/onlinelog/standbyredo1.log' size 52M;
alter database add standby logfile thread 2 group 1 '+DATA/racdb/onlinelog/standbyredo2.log' size 52M;
alter database add standby logfile thread 1 group 2 '+DATA/racdb/onlinelog/standbyredo3.log' size 52M;
alter database add standby logfile thread 2 group 2 '+DATA/racdb/onlinelog/standbyredo4.log' size 52M;
alter database add standby logfile thread 1 group 3 '+DATA/racdb/onlinelog/standbyredo5.log' size 52M;
alter database add standby logfile thread 2 group 3 '+DATA/racdb/onlinelog/standbyredo6.log' size 52M;
alter system set standby_file_management=auto scope=both sid='*';
5- Copy password file to standby nodes.
scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.1:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.2:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
created password file on production and copied and renamed it with standby database name(orapwracdr1) on both nodes. we do not need to create password file in the standby server.
6- Backup Primary DB:
rman target /
sql "alter system switch logfile";
BACKUP AS COMPRESSED BACKUPSET DATABASE format '/u01/app/oracle/backup/rman_%n_%T_%s_%p.bk' tag 'FORSTANDBY';
BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/u01/app/oracle/backup/ForStandbyCTRL.bck';
7- Compressed the backup folder:
tar -zcvf backup.tar.gz /u01/app/oracle/backup
8- Copy Compressed backup directory to Standby:
scp -r backup.tar.gz oracle@192.168.2.1:/u01/app/oracle/
Steps on Standby Server
9- Modify/add follwoing parameters on Standby site:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdb scope=both sid='*';
alter system set FAL_Client='racdr' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
9- Un-compressed the backup folder:
tar -zxvf backup.tar.gz -C /u01/app/oracle/
10- Start Standby in no mount mode:
srvctl stop database -d racdr
startup nomount -----one instance
11- Connect to rman on standby server and restore the backup:
rman target /
11.1- Restore controlfile and mount the database:
restore standby controlfile from '/u01/app/oracle/backup/ForStandbyCTRL.bck';
sql 'alter database mount standby database';
11.2- Now restore the database backup:
run {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK ;
restore database;
switch datafile all ;
}
12- Open the database in read only mode:
alter database open read only;
13- Start active recovery on standby database:
recover managed standby database cancel; ---if media recovery already running
recover managed standby database disconnect using current logfile;
14- Check dataguard status
select status, error from v$archive_dest where dest_id=2;
select name,open_mode,db_unique_name,database_role,protection_mode from v$database;
15- On the primary server, check the latest archived redo log and force a log switch:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
ALTER SYSTEM SWITCH LOGFILE;
16- Check the new archived redo log has arrived at the standby server and been applied:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
SELECT sequence#, to_char(first_time,'dd-mon-yy hh:mi:ss am'), next_time, applied FROM v$archived_log ORDER BY sequence#;
Physical IPs: 192.168.1.1 , 192.168.1.2
VIPs: 192.168.1.3 , 192.168.1.4
DB_Unique_Name: racdb
Standby Site:
Physical IPs: 192.168.2.1 , 192.168.2.2
VIPs: 192.168.2.3 , 192.168.2.4
DB_Unique_Name: racdr
##########################################
Steps on Production/Primary Server
1- Modify or add dataguard related init Parameters on production:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdr scope=both sid='*'; ----FAL server (typically this is the database running in the primary role).
alter system set FAL_Client='racdb' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
2- Enable Archivelog Mode:
srvctl stop database -d racdb
startup mount ----(only one instance)
alter database archivelog;
alter database force logging;
alter database open;
srvctl start database -d racdb ----This will start the remaining Instances on the cluster.
3- Tns Entries on all servers (copy these entires on both nodes of standby server),
Note that add new entries with VIP instead of scan name:
racdb =
(DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.3)(PORT=1521))
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521))
(CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
(SERVICE_NAME=racdb)))
racdr =
(DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.3)(PORT=1521))
(ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.4)(PORT=1521))
(CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
(SERVICE_NAME=racdr)))
4- Create the Standby Redo Logs (SRLs) on Primary and Standby:
alter system set standby_file_management=manual scope=both sid='*';
alter database add standby logfile thread 1 group 1 '+DATA/racdb/onlinelog/standbyredo1.log' size 52M;
alter database add standby logfile thread 2 group 1 '+DATA/racdb/onlinelog/standbyredo2.log' size 52M;
alter database add standby logfile thread 1 group 2 '+DATA/racdb/onlinelog/standbyredo3.log' size 52M;
alter database add standby logfile thread 2 group 2 '+DATA/racdb/onlinelog/standbyredo4.log' size 52M;
alter database add standby logfile thread 1 group 3 '+DATA/racdb/onlinelog/standbyredo5.log' size 52M;
alter database add standby logfile thread 2 group 3 '+DATA/racdb/onlinelog/standbyredo6.log' size 52M;
alter system set standby_file_management=auto scope=both sid='*';
5- Copy password file to standby nodes.
scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.1:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.2:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
created password file on production and copied and renamed it with standby database name(orapwracdr1) on both nodes. we do not need to create password file in the standby server.
6- Backup Primary DB:
rman target /
sql "alter system switch logfile";
BACKUP AS COMPRESSED BACKUPSET DATABASE format '/u01/app/oracle/backup/rman_%n_%T_%s_%p.bk' tag 'FORSTANDBY';
BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/u01/app/oracle/backup/ForStandbyCTRL.bck';
7- Compressed the backup folder:
tar -zcvf backup.tar.gz /u01/app/oracle/backup
8- Copy Compressed backup directory to Standby:
scp -r backup.tar.gz oracle@192.168.2.1:/u01/app/oracle/
Steps on Standby Server
9- Modify/add follwoing parameters on Standby site:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdb scope=both sid='*';
alter system set FAL_Client='racdr' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
9- Un-compressed the backup folder:
tar -zxvf backup.tar.gz -C /u01/app/oracle/
10- Start Standby in no mount mode:
srvctl stop database -d racdr
startup nomount -----one instance
11- Connect to rman on standby server and restore the backup:
rman target /
11.1- Restore controlfile and mount the database:
restore standby controlfile from '/u01/app/oracle/backup/ForStandbyCTRL.bck';
sql 'alter database mount standby database';
11.2- Now restore the database backup:
run {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK ;
restore database;
switch datafile all ;
}
12- Open the database in read only mode:
alter database open read only;
13- Start active recovery on standby database:
recover managed standby database cancel; ---if media recovery already running
recover managed standby database disconnect using current logfile;
14- Check dataguard status
select status, error from v$archive_dest where dest_id=2;
select name,open_mode,db_unique_name,database_role,protection_mode from v$database;
15- On the primary server, check the latest archived redo log and force a log switch:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
ALTER SYSTEM SWITCH LOGFILE;
16- Check the new archived redo log has arrived at the standby server and been applied:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
SELECT sequence#, to_char(first_time,'dd-mon-yy hh:mi:ss am'), next_time, applied FROM v$archived_log ORDER BY sequence#;
No comments:
Post a Comment