Sie sind auf Seite 1von 13

10g Dataguard With Broker & Fast Start Fail Over Using RMAN

by

Faizan Momin
[Type text]

Mudassir Khan
Page 0

10g Dataguard With Broker & Fast Start Fail Over

This document makes the following assumptions: Primary Server is up and running. Database is up and running in archive mode and started from spfile on Primary Server. Secondary Server is up and running. Oracle Software (same version/patchset as that of primary) is installed on Secondary Server. Network is configured between primary and secondary servers. RMAN is used to duplicate Primary database on secondary

Overview
Type Hostname IP Address Oracle SID DB_UNIQUE_NAME TNS Service Name SERVICE_NAMES Primary Server(INDIA) india.oracle.com 192.168.246.171 india india INDIA india.oracle.com Standby Server(JAPAN) japan.oracle.com 192.168.246.172 india japan JAPAN japan.oracle.com
Remember The SID has to be same on both sides but DB_UNIQUE_NAME must be different

File Entries for /etc/hosts on both sides.

[oracle@india ~]$ vi /etc/hosts # Do not remove the following line, or various programs # that require network function ality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.246.171 india.oracle.com india 192.168.246.172 japan.oracle.com japan

By FaizanMomin & Mudassir Khan

Page 1

10g Dataguard With Broker & Fast Start Fail Over

Steps on Primary Server


1. Connect to SQLPLUS [oracle@india ~]$ sqlplus "/ as sysdba" 2. Check if DB is in archive log mode
SQL> ARCHIVE LOG LIST Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/app/oracle/archive Oldest online log sequence 10 Next log sequence to archive 12 Current log sequence 12 SQL> SELECT NAME, LOG_MODE FROM V$DATABASE; NAME LOG_MODE --------- -----------INDIA ARCHIVELOG SQL> sho parameter log_archive_dest_1 NAME TYPE VALUE ------------------------------------ ----------- ----------------------------log_archive_dest_1 string LOCATION=/u01/app/oracle/archi ve/india log_archive_dest_state_10 string enable

3. Enable Force Logging on the database, so that there are no problems with no logging in future.
SQL> ALTER DATABASE FORCE LOGGING; Database altered. Force Logging enables bulk redo log entries

By FaizanMomin & Mudassir Khan

Page 2

10g Dataguard With Broker & Fast Start Fail Over


4. Create STANDBY REDO LOGFILES on Primary Database
SQL> SELECT COUNT(GROUP#)+1 AS "NO OF STANDBY REQUIRED" FROM V$LOG; NO OF STANDBY REQUIRED ---------------------4 SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/india/stndby_redo01.log' size 50M; Database altered. SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/india/stndby_redo02.log' size 50M; Database altered. SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/india/stndby_redo03.log' size 50M; Database altered. SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/india/stndby_redo04.log' size 50M; Database altered.

You need to add (REDO_LOG_GROUP + 1) number of Standby files.

5. Set Standby file management to AUTO and ARCHIVE_LAG_TARGET=900


SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO' SCOPE=BOTH; System altered. SQL> ALTER SYSTEM SET ARCHIVE_LAG_TARGET=900 SCOPE=BOTH; System altered.

6. Create pfile from spfile


SQL> CREATE PFILE='/home/oracle/initindia.ora' FROM SPFILE; File created.

By FaizanMomin & Mudassir Khan

Page 3

10g Dataguard With Broker & Fast Start Fail Over


7. Add/Edit pfile to reflect parameters (Marked in BOLD/ITALICS) as shown below:
[oracle@india ~]$ vi /home/oracle/initindia.ora india.__db_cache_size=427819008 india.__java_pool_size=4194304 india.__large_pool_size=4194304 india.__shared_pool_size=163577856 india.__streams_pool_size=0 *.archive_lag_target=900 *.audit_file_dest='/u01/app/oracle/admin/india/adump' *.background_dump_dest='/u01/app/oracle/admin/india/bdump' *.compatible='10.2.0.1.0' *.control_files='/u01/app/oracle/oradata/india/control01.ctl','/u01/app/oracle/oradata/ india/control02.ctl','/u01/app/oracle/oradata/india/control03.ctl' *.core_dump_dest='/u01/app/oracle/admin/india/cdump' *.db_block_size=8192 *.db_domain='oracle.com' *.db_file_multiblock_read_count=16 *.db_name='india' *.db_unique_name='india' *.dispatchers='(PROTOCOL=TCP) (SERVICE=indiaXDB)' *.FAL_CLIENT='INDIA' ### TNSNAME OF PRIMARY *.FAL_SERVER='JAPAN' ### TNSNAME OF SECONDARY *.job_queue_processes=10 *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(india,japan)' *.log_archive_dest_1='LOCATION=/u01/app/oracle/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=india' *.LOG_ARCHIVE_DEST_2='SERVICE=JAPAN LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=japan' *.LOG_ARCHIVE_DEST_STATE_1='ENABLE' *.LOG_ARCHIVE_DEST_STATE_2='ENABLE' *.log_archive_format='%t_%s_%r.dbf' *.LOG_ARCHIVE_MAX_PROCESSES=3 *.open_cursors=300 *.pga_aggregate_target=201326592 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=605028352 *.standby_file_management='AUTO' *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' *.user_dump_dest='/u01/app/oracle/admin/india/udump' [oracle@india ~]$ cp /home/oracle/initindia.ora $ORACLE_HOME/dbs/

By FaizanMomin & Mudassir Khan

Page 4

10g Dataguard With Broker & Fast Start Fail Over


8. Start Primary Database using the pfile, create new spfile from pfile and start database with spfile
SQL> startup pfile='?/dbs/initindia.ora' ORACLE instance started. Total System Global Area 608174080 bytes Fixed Size 1220820 bytes Variable Size 167776044 bytes Database Buffers 432013312 bytes Redo Buffers 7163904 bytes Database mounted. Database opened. SQL> CREATE SPFILE FROM PFILE; File created. SQL> SHU IMMEDIATE Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 608174080 bytes Fixed Size 1220820 bytes Variable Size 167776044 bytes Database Buffers 432013312 bytes Redo Buffers 7163904 bytes Database mounted. Database opened.

9. Create pfile for STANDBY Database from Primary Database


SQL> create pfile='/home/oracle/initindia_stby.ora' from spfile; File created.

By FaizanMomin & Mudassir Khan

Page 5

10g Dataguard With Broker & Fast Start Fail Over


10. Configure Listener.ora & TNSNAMES.ora for Primary Database
[oracle@india admin]$ cat $ORACLE_HOME/network/admin/listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1) (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = india.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) ) [oracle@india admin]$ cat $ORACLE_HOME/network/admin/tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. INDIA = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = india.oracle.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = india.oracle.com) ) ) JAPAN = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = japan.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = japan.oracle.com) ) )

By FaizanMomin & Mudassir Khan

Page 6

10g Dataguard With Broker & Fast Start Fail Over


EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )

11. Create RMAN Backup of Primary Database


[oracle@india ~]$ rman target / / is used to connect to local database

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Sep 10 00:32:43 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: INDIA (DBID=2938478455) RMAN> configure controlfile autobackup format for device type disk to '/u01/app/oracle/backup/india/ctl_auto_%F'; Device type used here is disk it can also be tape RMAN> backup database format '/u01/app/oracle/backup/india/full_%d_%I_%T_%u' include current controlfile for standby plus archivelog format '/u01/app/oracle/backup/india/archive_%d_%I_%T_%u'; Format clause in rman sends the backup to the desired location

12. Copy Backup, Standby_Init.ora, Listener.ora, Tnsnames.ora and Password File


[oracle@india ~]$ scp /home/oracle/initindia_stby.ora oracle@192.168.246.172:/u01/app/oracle/product/10.2.0/db_1/dbs/ [oracle@india ~]$ scp $ORACLE_HOME/network/admin/listener.ora oracle@192.168.246.172:/u01/app/oracle/product/10.2.0/db_1/network/admin/ [oracle@india ~]$ scp $ORACLE_HOME/network/admin/tnsnames.ora oracle@192.168.246.172:/u01/app/oracle/product/10.2.0/db_1/network/admin/ [oracle@india ~]$ scp $ORACLE_HOME/dbs/orapwindia oracle@192.168.246.172:/u01/app/oracle/product/10.2.0/db_1/dbs/ [oracle@india ~]$ scp -r $ORACLE_BASE/backup/india oracle@192.168.246.172:/u01/app/oracle/backup By FaizanMomin & Mudassir Khan Remember: Password files is used for remote connectivity

Page 7

10g Dataguard With Broker & Fast Start Fail Over

Steps on Secondary Server


1. Copy Standby_Init.ora to initindia.ora, edit it to reflect as below and create directory structure of Primary:
[oracle@india ~]$ cp $ORACLE_HOME/dbs/initindia_stby.ora $ORACLE_HOME/dbs/initindia.ora [oracle@india ~]$ vi $ORACLE_HOME/dbs/initindia.ora india.__db_cache_size=432013312 india.__java_pool_size=4194304 india.__large_pool_size=4194304 india.__shared_pool_size=159383552 india.__streams_pool_size=0 *.archive_lag_target=900 *.audit_file_dest='/u01/app/oracle/admin/india/adump' *.background_dump_dest='/u01/app/oracle/admin/india/bdump' *.compatible='10.2.0.1.0' *.control_files='/u01/app/oracle/oradata/india/control01.ctl','/u01/app/oracle/oradata/ india/control02.ctl','/u01/app/oracle/oradata/india/control03.ctl' *.core_dump_dest='/u01/app/oracle/admin/india/cdump' *.db_block_size=8192 *.db_domain='oracle.com' *.db_file_multiblock_read_count=16 *.db_name='india' *.db_unique_name='japan' *.dispatchers='(PROTOCOL=TCP) (SERVICE=indiaXDB)' *.FAL_CLIENT='JAPAN' *.FAL_SERVER='INDIA' *.job_queue_processes=10 *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(india,japan)' *.log_archive_dest_1='LOCATION=/u01/app/oracle/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=japan' *.LOG_ARCHIVE_DEST_2='SERVICE=INDIA LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=india' *.LOG_ARCHIVE_DEST_STATE_1='ENABLE' *.LOG_ARCHIVE_DEST_STATE_2='ENABLE' *.log_archive_format='%t_%s_%r.dbf' *.LOG_ARCHIVE_MAX_PROCESSES=3 *.open_cursors=300 *.pga_aggregate_target=201326592 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=605028352 *.standby_file_management='AUTO' *.undo_management='AUTO' By FaizanMomin & Mudassir Khan Page 8

10g Dataguard With Broker & Fast Start Fail Over


*.undo_tablespace='UNDOTBS1' *.user_dump_dest='/u01/app/oracle/admin/india/udump' [oracle@india [oracle@india [oracle@india [oracle@india [oracle@india [oracle@india [oracle@india ~]$ ~]$ ~]$ ~]$ ~]$ ~]$ ~]$ mkdir mkdir mkdir mkdir mkdir mkdir mkdir -p -p -p -p -p -p -p $ORACLE_BASE/admin/india/adump $ORACLE_BASE/admin/india/bdump $ORACLE_BASE/admin/india/cdump $ORACLE_BASE/admin/india/dpdump $ORACLE_BASE/admin/india/udump $ORACLE_BASE/archive/india $ORACLE_BASE/oradata/india

2. Startup nomount Secondary Database


[oracle@japan ~]$ sqlplus "/ as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Sat Sep 10 02:18:56 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> startup nomount

3. Update Listener.ora as shown below


[oracle@japan admin]$ vi $ORACLE_HOME/network/admin/listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1) (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST =

By FaizanMomin & Mudassir Khan

Page 9

10g Dataguard With Broker & Fast Start Fail Over


(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = japan.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) )

4. Perform TNSPING to confirm connectivity


[oracle@japan ~]$ tnsping india TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 10-SEP-2011 02:26:14 Copyright (c) 1997, 2005, Oracle. All rights reserved. Used parameter files: /u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = india.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = india.oracle.com))) OK (40 msec) [oracle@japan ~]$ tnsping japan TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 10-SEP-2011 02:26:17 Copyright (c) 1997, 2005, Oracle. All rights reserved. Used parameter files: /u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = japan.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = japan.oracle.com))) OK (10 msec)

By FaizanMomin & Mudassir Khan

Page 10

10g Dataguard With Broker & Fast Start Fail Over


5. Restore backup of Primary Database to Secondary
[oracle@japan bin]$ ./rman target sys@india auxiliary / Recovery Manager: Release 10.2.0.1.0 - Production on Sat Sep 10 00:37:19 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. target database Password: connected to target database: INDIA (DBID=2938478455) connected to auxiliary database: INDIA (not mounted) RMAN> duplicate target database for standby nofilenamecheck dorecover;

6. Put Secondary Database in Managed Standby Mode


[oracle@japan ~]$ sqlplus "/ as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Sat Sep 10 00:42:00 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> ALTER DATABASE OPEN READ ONLY; Database altered. SQL> SHU IMMEDIATE Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP NOMOUNT; ORACLE instance started. Total System Global Area 608174080 bytes Fixed Size 1220820 bytes Variable Size 167776044 bytes Database Buffers 432013312 bytes Redo Buffers 7163904 bytes SQL> CREATE SPFILE FROM PFILE;

By FaizanMomin & Mudassir Khan

Page 11

10g Dataguard With Broker & Fast Start Fail Over


SQL> SHU IMMEDIATE; SQL> STARTUP NOMOUNT; ORACLE instance started. Total System Global Area 608174080 bytes Fixed Size 1220820 bytes Variable Size 167776044 bytes Database Buffers 432013312 bytes Redo Buffers 7163904 bytes SQL> ALTER DATABASE MOUNT STANDBY DATABASE; Database altered. SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT; Database altered.

7. Check whether Secondary Database is in sync with Primary Database


RUN ON PRIMARY DATABASE:
SQL> SELECT MAX(SEQUENCE#) AS "PRIMARY" FROM V$LOG_HISTORY; PRIMARY ---------16

RUN ON SECONDARY DATABASE:


SQL> SELECT MAX(SEQUENCE#) AS "STANDBY", APPLIED FROM V$ARCHIVED_LOG GROUP BY APPLIED; STANDBY APP ---------- --16 YES

If both the values are the same Congratulation!!!!!! You have successfully configured 10g Dataguard

By FaizanMomin & Mudassir Khan

Page 12

Das könnte Ihnen auch gefallen