Data Guard Setup Step by Step
Data Guard Setup Step by Step
Data Guard Setup Step by Step
Step Procedure
Confirm that the ORACLE_SID and ORACLE_BASE environment variables are set properly
ORACLE_BASE= /d01/app/oracle
ORACLE_SID= ORACLE
$ sqlplus / as sysdba
SQL> show parameter db_unique_name
Complete the following step only if: db_unique_name is not set to ORACLE_A
• Confirm Modification
• Shutdown and Startup (to use spfile so following commands will not fail)
SQL> shutdown
SQL> startup
For the following command, ensure that the log_archive_dest location folder is created
SQL> HOST mkdir -p /backup/raddpi/arch/ORACLE/BK_STB
4.Update pfile with spfile (will be used later for the standby database)
5.Backup the Primary database using this rman script. (See appendix).
Verify if the database is in archive log mode with the following SQL:
$ mkdir -p /d01/app/oracle/admin/ORACLE/rman
Copy the backup_db_for_standby.rcv rman script from the appendix to the rman folder
ORACLE_A =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.37)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORACLE)
)
)
ORACLE_B =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.38)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORACLE)
)
)
LISTENER_ORACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.37)(PORT = 1521)
)
SID_LIST_LISTENER_ORACLE =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /d01/app/oracle/product/10.2.0)
(SID_NAME = ORACLE)
)
)
8 Depending of the message you get you might need to Stop and or Start the Listener
$ sqlplus / as sysdba
Notes: The standby logfile sizes must be identical on the primary and standby databases and the
number of standby redo logfile groups should be at least the same as the redo logfile groups on the
primary database.
SQL> startup
SQL> exit
Confirm that the ORACLE_SID and ORACLE_BASE environment variables are set properly
ORACLE_BASE= /d01/app/oracle
ORACLE_SID= ORACLE
$ mkdir -p /backup/raddpi/arch/ORACLE/BK_STB
$ cd /backup/raddpi/arch/ORACLE/BK_STB
$ sftp oradpi@172.16.118.37
Password: ************
sftp> cd /backup/raddpi/arch/ORACLE/BK_STB
sftp> ls
sftp> get <filename1>
sftp> get <filename2>
……
sftp> get <filenamex>
sftp> exit
Notes: Get all the files starting with inc0 and cf. You can also use the mget command with a
combination of asterisk (ex: mget inc0*.*)
cd /backup/raddpi/arch/ORACLE
sftp oradpi@172.16.118.37
Password: ************
sftp> cd /backup/raddpi/arch/ORACLE
sftp> ls
sftp> get <filename1>
sftp> get <filename2>
……
sftp> get <filenamex>
sftp> exit
Notes: Need to get the recent archived logs, these generated after finishing backup with
RMAN. Most of the archive logs are already included in the RMAN backup, but if the database
is still open with activities, some archive logs following the last one included in the RMAN
backup could be necessary to complete recovery. You can also use the mget command with
a combination of asterisk (ex: mget *.arc)
3 From the file obtained at the previous step modify the following entries to initORACLE.ora :
*.db_domain='***'
*.db_name='ORACLE'
*.db_unique_name='ORACLE_B'
*.fal_client='ORACLE_B'
*.fal_server='ORACLE_A'
*.log_archive_config='DG_CONFIG=(ORACLE_A,ORACLE_B)'
*.log_archive_dest_1='LOCATION=/backup/raddpi/arch/ORACLE/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORACLE_B'
*.log_archive_dest_2='SERVICE=ORACLE_A LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORACLE_A'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=3
*.log_archive_min_succeed_dest=1
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
(/d01/app/oracle/product/10.2.0/network/admin)
ORACLE_A =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.37)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORACLE)
)
)
ORACLE_B =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.38)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORACLE)
)
)
LISTENER_ORACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.118.38)(PORT = 1521))
)
SID_LIST_LISTENER_ORACLE =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /d01/app/oracle/product/10.2.0)
(SID_NAME = ORACLE)
)
)
7. Create password file (enter the sys password in the password parameter)
$ /d01/app/oracle/product/10.2.0/bin/orapwd
File=/d01/app/oracle/product/10.2.0/dbs/orapwORACLE password=<password>
8. Create spfile
9. Restore database
SQL> exit
$ mkdir -p /d01/app/oracle/admin/ORACLE/rman
Copy the restore_db_for_standby.rcv script from the appendix to the rman folder
$ cd /d01/app/oracle/admin/ORACLE/rman
sqlplus / as sysdba
Step Procedure
$ sqlplus / as sysdba
SQL> alter database recover managed standby database disconnect from session parallel 4;
2 Primary database:172.16.118.37
Appendixes
Appendix A : backup_db_for_standby.rcv
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
backup
incremental level 0
database
tag inc0_db_open
filesperset=5
format '/backup/raddpi/arch/ORACLE/BK_STB/inc0_df_%U.dat'
include current controlfile for standby;
Appendix B : restore_db_for_standby.rcv
run {
allocate auxiliary channel d1 type disk;
allocate auxiliary channel d2 type disk;
allocate auxiliary channel d3 type disk;
allocate auxiliary channel d4 type disk;
duplicate target database for standby nofilenamecheck dorecover;
}