Thursday, January 10, 2013

10 easy steps to configure Datagurad on Windows 7

Hey folks! I am not going to bore you with stories on dataguard; it is 90% practical. If you need definitions or explanations of why you need dataguard, please visit this oracle site

Here is the step by step guide on how to configure dataguard on a Windows 7 environment.

Version: Oracle 11.2.0
Hardware: Windows 7

Prerequisite:

a.) Archivelog mode. Here is the step to put your database in archivelog mode

SQL> shutdown immediate
startup mount;
alter database archivelog;
alter database force logging;
alter database open;

b.) Start your listener


c:\> LSNRCTL START

c.) create TNSNAMES.ORA

use netca to create tnsnames for 'orcl1' and 'orclstby'

Please Note:

1. You have to take a backup of your database before you start, otherwise you will get an error

c:\> set ORACLE_SID=orcl1
c:\> rman target /
RMAN> backup database including archivelog;

2. You need to create ORACLE_SID using oradim utility. Please use this command:

create instance
---------------------
C:\app\kelebute\product\11.2.0\dbhome_1\BIN>oradim -NEW -SID orclstby -SYSPWD oracle -pfile initorclstby.ora
Instance created.

3. Use NetMgr to register the databases ('orcl1' and 'orclstby'):

click Start
Click All Programs
Click Oracle Dbhome_1
Click Configuration and Migration tools
Then click "Net Mgr"

NOTE: NetMgr will not accept ORACLE_SID name that is more than 8 characters.

Make sure you verify your TNSNAMES registration in NetMgr.

4. Create a pfile using this command on primary:

SQL> create pfile='c:\app\kelebute\initorclstby.ora' from spfile;

5. create pfile for standby

C:\Windows\system32>sqlplus sys/oracle@psi as sysdba
SQL> create pfile='c:\APP\KELEBUTE\PRODUCT\11.2.0\DBHOME_1\DATABASE\INITPSI2.ORA
' from spfile;

6. Add standby redo log files on primary
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
C:\APP\KELEBUTE\ORADATA\PSI\REDO03.LOG
C:\APP\KELEBUTE\ORADATA\PSI\REDO02.LOG
C:\APP\KELEBUTE\ORADATA\PSI\REDO01.LOG

SQL> alter database add standby logfile
2 'C:\APP\KELEBUTE\ORADATA\PSI\REDO04.LOG' size 50m;
Database altered.
SQL> alter database add standby logfile
2 'C:\APP\KELEBUTE\ORADATA\PSI\REDO05.LOG' size 50m;
Database altered.
SQL> alter database add standby logfile
2 'C:\APP\KELEBUTE\ORADATA\PSI\REDO06.LOG' size 50m;
Database altered.

7. Set parameters on primary

SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(psi,psi2)';
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=psi2 async VALID_FOR=(ONLINE_L
OGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=psi2';
SQL> Alter system set standby_file_management=auto;
SQL> Alter system set fal_client =psi;
SQL> Alter system set fal_server=psi2;

8. Take a backup
C:\Windows\system32>rman target psi
RMAN> backup database plus archivelog;

9. Make sure you connect to both SIDs on RMAN
c:\>rman
RMAN> connect target sys/oracle@orcl1
RMAN> connect auxiliary sys/oracle@orclstby
RMAN> @c:\k\dataguard.txt

-------------------
Here is the script
-------------------

run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel stby type disk;
DUPLICATE TARGET DATABASE
FOR STANDBY
DB_FILE_NAME_CONVERT=('\ORCL1\','\ORCLSTBY\')
SPFILE
PARAMETER_VALUE_CONVERT '\ORCL1','\ORCLSTBY'
set db_unique_name='orclstby'
SET LOG_FILE_NAME_CONVERT '\ORCL1\','\ORCLSTBY\'
SET SGA_MAX_SIZE '200M'
SET SGA_TARGET '125M'
set control_files='c:\app\kelebute\oradata\orclstby\orclstby01.ctl'
set log_archive_max_processes='5'
set fal_client='orclstby'
set fal_server='orcl1'
set standby_file_management='AUTO'
SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL1,ORCLSTBY)'
SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL1 NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL1'
NOFILENAMECHECK;
}
-------------------------------------

10. Put standby in recovery mode

sqlplus sys/oracle@psi2 as sysdba
SQL> Alter database recover managed standby database using current logfile disco
nnect from session;
SQL> Alter database recover managed standby database cancel;

Dataguard is configured!


No comments:

Post a Comment