Physical Standby Database Configuration For User Managed Failover End To End Test
Physical Standby Database Configuration For User Managed Failover End To End Test
Physical Standby Database Configuration For User Managed Failover End To End Test
Index
Index............................................................................................................................ 1 Summary......................................................................................................................2 Important Configuration Tips...................................................................................... 3 Implementation Summary............................................................................................3 backup......................................................................................................................3 Standby Controlfile..................................................................................................3 A copy of the password file generated on the primary database............................. 3 An init.ora parameter file with specific standby database parameters set for both the primary and standby role....................................................................................4 Configure the network to provide connectivity to both primary and standby databases..................................................................................................................6 Configure the local_listener parameter for none standard ports..............................7 Create a set of standby redologs on both the primary and standby databases.........7 Enabling Recovery on the Standby Database..............................................................8 Enabling Dataguard broker on both Databases............................................................9 Create the Broker Configuration................................................................................10 Check the Broker Configuration................................................................................11 Enable the Broker Configuration...............................................................................13 Check the Databases Transport Mode Setting...........................................................14 Test Manual Switchover............................................................................................14 Check after Manual Switchover.................................................................................16 Test Manual Switchover Back to the Original Primary.............................................16 Test Failing over after a Primary Database Failure................................................... 18 Reinstating the Primary Database after a Failure...................................................... 20 Recreate the crashed primary after a failed reinstate.................................................23 Recreate the broker configuration..............................................................................26 Configure Flashback Database on the Standby Database..........................................28 Configure flashback database on the primary database.............................................28 Test switchover back and forth again........................................................................ 29 Test Failing over after a Primary Database Failure (with Flashback Database set). .33 Reinstating the Primary Database after a Failure...................................................... 36 Cleanup of Archived Logs on the Standby Location.................................................46 Script rman_clean_arch.bat ...................................................................................46 Script rman_clean_arch.rmn..................................................................................47 Log File rman_clean_arch.log...............................................................................47 Tnsnames Configuration for the Applications...........................................................48
1/49
Summary
The test described on this document was implemented to demonstrate how to manually manage switchover and emergency failover of a standby database configured in maximum performance lgwr async noaffirm mode. The maximum performance in Async No Affirm provide high level of protection but do not compromise the availability and performance of the primary database. The main purpose of this configuration was defined as Provide a quick way to restore service in case of severe outage on the primary site. It was decided not to use fast start failover but to put on the DBA team the decision of when to fail over to the standby site after assessing the crash situation. Two failover situations were analyzed and are presented on this document: On the first scenario the databases were configured with flashback database enabled with a retention time of 60 minutes. On the second scenario flashback database was not configured. Flashback database makes much easier to reinstate the failed database in case of requiring a failover to the standby. Once the failed server is restarted the old primary only requires to be mounted and the broker will flashback it to a previous SCN and then reinstate, recover and reconfigure it to have the standby role, automatically. That reduces the time where the main database is unprotected to the minimum. When flashback database is not enabled, after failing over to the standby the old primary database will require to be rebuilt from a backup taken from the new primary. That makes the reinstate process more complex and it takes a much longer time. The environment used for this test was based on a Windows 2003 R2 with Oracle RDBMS 10.2.0.4 This document does not contain Dataguard step by step implementation steps but provide a summary of them. For a step by step implementation document please check Dataguard Configuration for FSFO
2/49
Implementation Summary
backup The full backup was made by copying over all database files, while the primary database was shutdown, to the standby server. The primary database may be copied over while backup mode is enabled. Standby Controlfile Was created on the primary database using the command: > alter database create standby controlfile as c:\standby-ctlfile.ctl ; The standby controlfile was copied over to the standby server, and its location set on the parameter file of the standby database. A copy of the password file generated on the primary database The password file needs to be generated on the primary and copied over; it cannot be generated on the standby server
3/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST An init.ora parameter file with specific standby database parameters set for both the primary and standby role First I do prepare the a pfile from the normal primary database spfile, then edit it for the primary and for the standby. This is the version used for the primary database:
AVDB.__db_cache_size=2197815296 AVDB.__java_pool_size=16777216 AVDB.__large_pool_size=16777216 AVDB.__shared_pool_size=268435456 AVDB.__streams_pool_size=117440512 *.audit_file_dest='C:\oracle\product\10.2.0\admin\AVDB\adum p' *.background_dump_dest='E:\ORACLE\ADMIN\AVDB\BDUMP' *.compatible='10.2.0.3' *.control_files='E:\ORACLE\ORADATA\AVDB\CONTROL01.CTL','G:\ ORACLE\ORADATA\AVDB\CONTROL02.CTL','D:\ORACLE\ORADATA\AVDB\ CONTROL03.CTL' *.core_dump_dest='E:\ORACLE\ADMIN\AVDB\CDUMP' *.db_block_size=8192 *.db_domain='' *.db_file_multiblock_read_count=16 *.db_files=2048 *.job_queue_processes=60 *.nls_date_format='DD/MM/YYYY' *.open_cursors=300 *.pga_aggregate_target=314572800 *.processes=1000 *.recovery_parallelism=4 *.REMOTE_LOGIN_PASSWORDFILE='EXCLUSIVE' *.resource_manager_plan='NIGHTTIME' *.session_cached_cursors=50 *.sessions=555 *.sga_max_size=2621440000 *.sga_target=2621440000 *.streams_pool_size=104857600 *.undo_management='AUTO' *.undo_tablespace='UNDOTBS' *.user_dump_dest='E:\ORACLE\ADMIN\AVDB\UDUMP' *.utl_file_dir='F:\ORA_UTL_DIR','E:\ORACLE\admin\AVDB\udump' ## ## Standby relevant parameters ## ## db_file_name_convert and log_file_name_convert state in ## pairs the conversion that ## needs to be applied to the names registered on the \ ## standby controlfile. In this case the files located on
4/49
5/49
Configure the network to provide connectivity to both primary and standby databases The listener and tnsnames need to have this specific configuration when using dataguard: # LISTENER.ORA
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = AVDB_DGMGRL) (SID_NAME = AVDB) (ORACLE_HOME = C:\oracle\product\10.2.0\db_1) ) (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = C:\oracle\product\10.2.0\db_1) (PROGRAM = extproc) ) ) INBOUND_CONNECTION_TIMEOUT_LISTENER = 0 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = SERVER01)(PORT = 2115)) ) )
# TNSNAMES.ORA
AVDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = SERVER01)(PORT = 2115)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = AVDB_DGMGRL) ) ) AVDBSTD = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = SERVER02)(PORT = 2115)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = AVDBSTD_DGMGRL) ) )
6/49
Configure the local_listener parameter for none standard ports The local_listener parameter needs to be configured to the listener registered on the tnsnames.ora in this case on the primary database: > alter system set local_listener=LISTENER_AVDB scope=both; On the standby database: > alter system set local_listener=LISTENER_AVDBSTD scope=both; Check that the listener respond to tnsping:
C:\Documents and Settings\db411>tnsping listener_AVDB TNS Ping Utility for 64-bit Windows: Version 10.2.0.4.0 Production on 19-JUL-2010 11:06:20 Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files: C:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = SERVER01)(PORT = 2115))) OK (20 msec)
Create a set of standby redologs on both the primary and standby databases In order to enable LGWR ASYNC transport mode we need to create standby redologs on both the primary and standby databases: The standby redologs need to be the same size as the online redologs and have the same number of online redo log groups +1 or more. In this case we have 8 online groups so we created 10 standby redologs on each database:
7/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST alter database add standby logfile group 08 'D:\ORACLE\ORADATA\AVDB\REDO08.LOG' SIZE 209715200; alter database add standby logfile group 09 'D:\ORACLE\ORADATA\AVDB\REDO09.LOG' SIZE 209715200; alter database add standby logfile group 10 'D:\ORACLE\ORADATA\AVDB\REDO10.LOG' SIZE 209715200; alter database add standby logfile group 11 'D:\ORACLE\ORADATA\AVDB\REDO11.LOG' SIZE 209715200; alter database add standby logfile group 12 'D:\ORACLE\ORADATA\AVDB\REDO12.LOG' SIZE 209715200; alter database add standby logfile group 13 'D:\ORACLE\ORADATA\AVDB\REDO13.LOG' SIZE 209715200; alter database add standby logfile group 14 'D:\ORACLE\ORADATA\AVDB\REDO14.LOG' SIZE 209715200; alter database add standby logfile group 15 'D:\ORACLE\ORADATA\AVDB\REDO15.LOG' SIZE 209715200; alter database add standby logfile group 16 'D:\ORACLE\ORADATA\AVDB\REDO16.LOG' SIZE 209715200; alter database add standby logfile group 17 'D:\ORACLE\ORADATA\AVDB\REDO17.LOG' SIZE 209715200; alter database add standby logfile group 18 'D:\ORACLE\ORADATA\AVDB\REDO18.LOG' SIZE 209715200;
8/49
The Primary: Database log mode Automatic archival Archive destination L:\ORACLE\oradata\AVDB\archive Oldest online log sequence Next log sequence to archive Current log sequence Archive Mode Enabled 1026 1031 1031
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- ------------------------------ ---------- ---------------AVDB AVDB READ WRITE PRIMARY
9/49
10/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST DGMGRL> add database AVDBSTD as connect identifier is AVDBSTD maintained as physical; Database "AVDBSTD" added
Properties: InitialConnectIdentifier ObserverConnectIdentifier LogXptMode Dependency DelayMins Binding MaxFailure MaxConnections ReopenSecs NetTimeout LogShipping PreferredApplyInstance ApplyInstanceTimeout ApplyParallel StandbyFileManagement ArchiveLagTarget LogArchiveMaxProcesses LogArchiveMinSucceedDest
= = = = = = = = = = = = = = = = = =
'AVDB' '' 'ASYNC' '' '0' 'OPTIONAL' '0' '1' '300' '180' 'ON' '' '0' 'AUTO' 'auto' '0' '4' '1'
11/49
Properties: InitialConnectIdentifier ObserverConnectIdentifier LogXptMode Dependency DelayMins Binding MaxFailure MaxConnections ReopenSecs NetTimeout LogShipping PreferredApplyInstance ApplyInstanceTimeout ApplyParallel StandbyFileManagement ArchiveLagTarget LogArchiveMaxProcesses
= = = = = = = = = = = = = = = = =
'AVDBSTD' '' 'ASYNC' '' '0' 'OPTIONAL' '0' '1' '300' '180' 'ON' '' '0' 'AUTO' 'AUTO' '0' '4'
12/49
13/49
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PHYSICAL STANDBY YES ONLINE
14/49
Execute the switchover: DGMGRL> switchover to AVDBSTD; Performing switchover NOW, please wait... Operation requires shutdown of instance "AVDB" on database "AVDB" Shutting down instance "AVDB"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires shutdown of instance "AVDBSTD" on database "AVDBSTD" Shutting down instance "AVDBSTD"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires startup of instance "AVDB" on database "AVDB" Starting instance "AVDB"... ORACLE instance started. Database mounted. Operation requires startup of instance "AVDBSTD" on database "AVDBSTD" Starting instance "AVDBSTD"... ORACLE instance started. Database mounted. Switchover succeeded, new primary is "AVDBSTD" Check after the switchover succeeded: DGMGRL> show configuration Configuration Name: Enabled: 15/49 dgAVDB YES
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Physical standby database AVDBSTD - Primary database Current status for "dgAVDB": SUCCESS
16/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Shutting down instance "AVDBSTD"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires shutdown of instance "AVDB" on database "AVDB" Shutting down instance "AVDB"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires startup of instance "AVDBSTD" on database "AVDBSTD" Starting instance "AVDBSTD"... ORACLE instance started. Database mounted. Operation requires startup of instance "AVDB" on database "AVDB" Starting instance "AVDB"... ORACLE instance started. Database mounted. Switchover succeeded, new primary is "AVDB" DGMGRL> show configuration; Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Primary database AVDBSTD - Physical standby database Current status for "dgAVDB": SUCCESS DGMGRL> show database AVDB Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PRIMARY YES ONLINE
17/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PHYSICAL STANDBY YES ONLINE
18/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Automatic archival Archive destination L:\ORACLE\oradata\AVDB\archive Oldest online log sequence Next log sequence to archive Current log sequence Enabled 1026 1031 1031
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- ------------------------------ ---------- ---------------AVDB AVDB READ WRITE PRIMARY
Abort the primary database to simulate a failure: SQL> shutdown abort; From alert log: Mon Jul 19 13:24:52 2010 LNS: Standby redo logfile selected for thread 1 sequence 1031 for destination LOG_ARCHIVE_DEST_2 Mon Jul 19 13:25:16 2010 Shutting down instance (abort) License high water mark = 5 Instance terminated by USER, pid = 2204 Mon Jul 19 13:29:39 2010 WARNING: inbound connection timed out (ORA-3136) Connect to DGMGRL and to the standby database: DGMGRL> connect sys/AVDBPW@AVDBSTD Connected. DGMGRL> show configuration Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Primary database AVDBSTD - Physical standby database Current status for "dgAVDB": Error: ORA-16625: cannot reach the database Execute the failover:
19/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST DGMGRL> failover to AVDBSTD; Performing failover NOW, please wait... Failover succeeded, new primary is "AVDBSTD" DGMGRL> show configuration; Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Physical standby database (disabled) AVDBSTD - Primary database Current status for "dgAVDB": SUCCESS Check the new primary Note that the sequence was reset to be #1 Database log mode Archive Mode Automatic archival Enabled Archive destination D:\L\ORACLE\oradata\AVDB\archive Oldest online log sequence 1 Next log sequence to archive 1 Current log sequence 1
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- ------------------------------ ---------- ---------------AVDB AVDBSTD READ WRITE PRIMARY
20/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST DGMGRL> show configuration; Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Physical standby database (disabled) AVDBSTD - Primary database Current status for "dgAVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PRIMARY YES ONLINE
Current status for "AVDBSTD": SUCCESS DGMGRL> show database AVDB Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PHYSICAL STANDBY NO ONLINE
Current status for "AVDB": Error: ORA-16661: the standby database needs to be reinstated The message ORA-16661 means that the broker will be able to reinstate the database; otherwise we will need to recreate the old primary. To reinstate we need to mount the failed database
21/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST C:\Documents and Settings\db411\Desktop\scripts>sqlplus sys/AVDBPW@AVDB as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jul 19 13:39:12 2010 Copyright (c) 1982, 2007, Oracle. Connected to an idle instance. SQL> startup mount; ORACLE instance started. Total System Global Area 2634022912 bytes Fixed Size 2068072 bytes Variable Size 419430808 bytes Database Buffers 2197815296 bytes Redo Buffers 14708736 bytes Database mounted. Then connect to the DGMGRL C:\Documents and Settings\db411>dgmgrl sys/AVDBPW@AVDBSTD DGMGRL for 64-bit Windows: Version 10.2.0.4.0 - 64bit Production Copyright (c) 2000, 2005, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected. DGMGRL> show configuration Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDB - Physical standby database (disabled) AVDBSTD - Primary database Current status for "dgAVDB": SUCCESS DGMGRL> show database AVDB All Rights Reserved.
22/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PHYSICAL STANDBY NO ONLINE
Current status for "AVDB": Error: ORA-16661: the standby database needs to be reinstated DGMGRL> reinstate database AVDB; Reinstating database "AVDB", please wait... Error: ORA-16653: failed to reinstate database Failed. Reinstatement of database "AVDB" failed DGMGRL> show database AVDB Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PHYSICAL STANDBY NO ONLINE
Current status for "AVDB": Error: ORA-16795: database resource guard detects that database re-creation is required
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST C:\Documents and Settings\db411>sqlplus SYS/AVDBPW@AVDB AS SYSDBA Connected to an idle instance. SQL> CREATE SPFILE FROM PFILE='C:\oracle\product\10.2.0\db_1\database\init4standby. ora'; File created. SQL> STARTUP MOUNT; ORACLE instance started. Total System Global Area 2634022912 bytes Fixed Size 2068072 bytes Variable Size 419430808 bytes Database Buffers 2197815296 bytes Redo Buffers 14708736 bytes Database mounted. On the primary database enable destination 2 and check the standby is receiving the changes: SQL> show parameters log_archive_dest_2
NAME TYPE VALUE ------------------------------------ ----------- -----------------------------log_archive_dest_2 string service="(DESCRIPTION=(ADDRESS _LIST=(ADDRESS=(PROTOCOL=TCP)( HOST=SERVER01 )(PORT=2115)))(CONNECT_D ATA=(SERVICE_NAME=AVDB_XPT)(IN STANCE_NAME=AVDB)(SERVER=dedic ated)))", LGWR ASYNC NOAFFI RM delay=0 OPTIONAL max_failur e=0 max_connections=1 reopen =300 db_unique_name="AVDB" reg ister net_timeout=180 valid_f or=(online_logfile,primary_rol e)
24/49
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- ------------------------------ ---------- ---------------AVDB AVDB MOUNTED PHYSICAL STANDBY
After that I need to enable the broker configure the local listener and check that the XPT service was registered with the listener SQL> alter system set dg_broker_start=true scope=both; System altered. SQL> alter system set local_listener='LISTENER_AVDB' scope=both;
C:\Documents and Settings\db411\Desktop\scripts>lsnrctl status LSNRCTL for 64-bit Windows: Version 10.2.0.4.0 - Production on 19-JUL2010 17:34:27 Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SERVER01) (PORT=2115))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for 64-bit Windows: Version 10.2.0.4.0 - Production Start Date 19-JUL-2010 10:25:32 Uptime 0 days 7 hr. 9 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File C:\oracle\product\10.2.0\db_1\network\admin\listener.ora Listener Log File C:\oracle\product\10.2.0\db_1\network\log\listener.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER01)(PORT=2115))) Services Summary... Service "PLSExtProc" has 1 instance(s).
25/49
26/49
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PRIMARY YES ONLINE
27/49
28/49
29/49
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PHYSICAL STANDBY YES ONLINE
Switchover
DGMGRL> switchover to AVDBSTD Performing switchover NOW, please wait... Operation requires shutdown of instance "AVDB" on database "AVDB" Shutting down instance "AVDB"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires shutdown of instance "AVDBSTD" on database "AVDBSTD" Shutting down instance "AVDBSTD"... ORA-01109: database not open Database dismounted. ORACLE instance shut down.
30/49
Switchover back
DGMGRL> show configuration Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDBSTD - Primary database AVDB - Physical standby database Current status for "dgAVDB": SUCCESS DGMGRL> show database AVDB Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PHYSICAL STANDBY YES ONLINE
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PRIMARY YES ONLINE
Current status for "AVDBSTD": SUCCESS DGMGRL> switchover to AVDB Performing switchover NOW, please wait...
31/49
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: AVDBSTD PHYSICAL STANDBY YES
32/49
Test Failing over after a Primary Database Failure (with Flashback Database set)
Databases are in synch
Database log mode Automatic archival Archive destination Oldest online log sequence Next log sequence to archive Current log sequence Archive Mode Enabled L:\ORACLE\oradata\AVDB\archive 56 61 61
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- -------------------- ---------- ---------------AVDB AVDB READ WRITE PRIMARY Database log mode Automatic archival Archive destination Oldest online log sequence Next log sequence to archive Current log sequence Archive Mode Enabled dgsby_AVDBSTD 0 0 61
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- --------------------- ---------- ---------------AVDB AVDBSTD MOUNTED PHYSICAL STANDBY
33/49
Current status for "AVDB": SUCCESS DGMGRL> show database AVDBSTD Database Name: Role: Enabled: Intended State: Instance(s): AVDBSTD AVDBSTD PHYSICAL STANDBY YES ONLINE
34/49
On AVDBSTD
SQL> select name,db_unique_name,flashback_on from v$database; NAME DB_UNIQUE_NAME FLASHBACK_ON --------- ------------------------------ -----------------AVDB AVDBSTD YES select estimated_flashback_size,retention_target, flashback_size from v$flashback_database_log ; ESTIMATED_FLASHBACK_SIZE RETENTION_TARGET FLASHBACK_SIZE ------------------------ ---------------- -------------11328512 60 79708160 select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log ; OLDEST_FLASHBACK_SCN OLDEST_FL -------------------- --------12261282297 25-JUL-10
Connect to DGMGRL and to the standby database: C:\Documents and Settings\db411>dgmgrl sys/AVDBPW@AVDBSTD DGMGRL for 64-bit Windows: Version 10.2.0.4.0 - 64bit Production Copyright (c) 2000, 2005, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected. DGMGRL> show configuration
35/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDBSTD - Physical standby database AVDB - Primary database Current status for "dgAVDB": Error: ORA-16625: cannot reach the database Execute the failover: DGMGRL> failover to AVDBSTD; Performing failover NOW, please wait... Failover succeeded, new primary is "AVDBSTD" DGMGRL> show configuration Configuration Name: dgAVDB Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: AVDBSTD - Primary database AVDB - Physical standby database (disabled) Current status for "dgAVDB": SUCCESS Check the new primary Note that the sequence was reset to be #1
Database log mode Automatic archival Archive destination Oldest online log sequence Next log sequence to archive Current log sequence Archive Mode Enabled D:\L\ORACLE\oradata\AVDB\archive 1 1 1
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE --------- ------------------------------ ---------- ---------------AVDB AVDBSTD READ WRITE PRIMARY
36/49
STANDBY DATABASE CONFIGURATION FOR MANUAL SWITCHOVER END TO END TEST The next step is to reinstate the failed Primary database, here we may find one of two scenarios: 1) the primary can be reinstated, this is most feasible when there were no changes on the new primary yet, or 2) the primary needs to be recreated. We need to check the feedback the broker will provide and act accordingly. To avoid being required to rebuild the primary it is convenient to enable flashback database that will permit to the broker to flashback the database to an SCN prior to the crash and then reinstate it. DGMGRL> show database AVDB Database Name: Role: Enabled: Intended State: Instance(s): AVDB AVDB PHYSICAL STANDBY NO ONLINE
Current status for "AVDB": Error: ORA-16661: the standby database needs to be reinstated The message ORA-16661 means that the broker will be able to reinstate the database; otherwise we will need to recreate the old primary. To reinstate we need to mount the failed database
C:\Documents and Settings\db411\Desktop\scripts>sqlplus sys/AVDBPW@AVDB as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jul 25 09:32:24 2010 Copyright (c) 1982, 2007, Oracle. Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 2634022912 bytes Fixed Size 2068072 bytes Variable Size 436208024 bytes Database Buffers 2181038080 bytes Redo Buffers 14708736 bytes All Rights Reserved.
37/49
From within DGMGRL reinstate the failed database DGMGRL> reinstate database AVDB; Reinstating database "AVDB", please wait... Operation requires shutdown of instance "AVDB" on database "AVDB" Shutting down instance "AVDB"... ORA-01109: database not open Database dismounted. ORACLE instance shut down. Operation requires startup of instance "AVDB" on database "AVDB" Starting instance "AVDB"... ORACLE instance started. Database mounted. Continuing to reinstate database "AVDB" ... Reinstatement of database "AVDB" succeeded Check the reinstated database alert log All the stages of the reinstate can be followed on the alert log of the reinstated database: 1) database is mounted
Database mounted in Exclusive Mode Completed: ALTER DATABASE MOUNT Sun Jul 25 09:32:41 2010
38/49
4) database is flashed back to an SCN so that it can be resynchronized with the new primary
FLASHBACK DATABASE TO SCN 12261313471 Flashback Restore Start Sun Jul 25 09:35:11 2010 Flashback Restore Complete Flashback Media Recovery Start parallel recovery started with 7 processes Sun Jul 25 09:35:19 2010 Recovery of Online Redo Log: Thread 1 Group 3 Seq 58 0 Mem# 0: D:\ORACLE\ORADATA\AVDB\REDO3.LOG Sun Jul 25 09:35:19 2010 Recovery of Online Redo Log: Thread 1 Group 4 Seq 59 0 Mem# 0: D:\ORACLE\ORADATA\AVDB\REDO4.LOG Sun Jul 25 09:35:20 2010 Recovery of Online Redo Log: Thread 1 Group 5 Seq 60 0 Mem# 0: D:\ORACLE\ORADATA\AVDB\REDO5.LOG Sun Jul 25 09:35:20 2010 Recovery of Online Redo Log: Thread 1 Group 6 Seq 61 0 Mem# 0: D:\ORACLE\ORADATA\AVDB\REDO6.LOG Sun Jul 25 09:35:21 2010 Incomplete Recovery applied until change 12261313472 Flashback Media Recovery Complete Completed: FLASHBACK DATABASE TO SCN 12261313471
Reading mem
Reading mem
Reading mem
Reading mem
39/49
40/49
41/49
42/49
43/49
44/49
45/49
46/49
Script rman_clean_arch.rmn
# This script remove all archived logs that are older than 2 hours run { allocate channel d1 type disk; delete noprompt force archivelog until time 'sysdate -120/1440'; release channel d1; } Exit # eof rman_clean_arch.rmn
Log File rman_clean_arch.log This is the log file produced by the rman_clean_arch.rmn script:
Recovery Manager: Release 10.2.0.4.0 - Production on Sun Aug 1 16:20:00 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: AVDB (DBID=803764395, not open) RMAN> run { allocate channel d1 type disk; 2> delete noprompt force archivelog until time 'sysdate -120/1440'; 3> release channel d1; 4> } 5> exit using target database control file instead of recovery catalog allocated channel: d1 channel d1: sid=1091 devtype=DISK deleted archive log archive log filename=L:\ORACLE\ORADATA\AVDB\ARCHIVE\AVDB_001_64015_0702125008 .ARC recid=889 stamp=725897700 deleted archive log archive log filename=L:\ORACLE\ORADATA\AVDB\ARCHIVE\AVDB_001_64016_0702125008 .ARC recid=890 stamp=725897709 deleted archive log
47/49
48/49
49/49