Download - 11g Dg Demo Script Imp Print1(1)
Oracle Data Guard 11g
Data Guard Process Architecture
On the primary database, Log Writer Network Server (LNS) process capture redo data being written by Log Writer and synchronously or asynchronously transmit the redo data to the standby database. The LNS process isolates Log Writer from the overhead of transmission and from network disruptions.
Synchronous redo transport (SYNC) requires the Log Writer on the primary database to wait for acknowledgement from LNS that the standby has received the redo data and written it to a standby redo log before it can acknowledge the commit to the client application. This insures all committed transactions are on disk and protected at the standby location.
Asynchronous redo transport (ASYNC) does not require the Log Writer on the primary to wait for acknowledgment from the standby database that redo has been written to disk; commits are acknowledged to the client application asynchronous of redo transport.
Physical Standby
Database
Backup /Reports
Oracle Net
FALPrimaryDatabas
e
Transactions
LGWR
Online Redo Logs
Archived Redo Logs
ARCH
RFS
StandbyRedo Logs
Archived Redo Logs
ARCH
MRPLNS
RealTimeApply
Fetch Archive Log (FAL) provides client-server mechanism for shipping archived logs to standby following a communication loss between the primary and standby, for automatic gap resolution and resynchronization. Archiver (ARCn) processes are always utilized to ship log files that are needed to resolve gaps.
The fal_server and fal_client parameters are used for the gap resolution. When MRP finds that an archive log is missing during media recovery, it sends the fal_client information to the server identified by fal_server and requests fal_server to resend the file again.
Standby database uses one or more Remote File Server (RFS) processes on the standby database to receive redo data and write it to a file called a Standby Redo Log (SRL). The Managed Recovery Process (MRP) is used to coordinate the application of redo data to a physical standby database.
If the Data Guard Broker is enabled, Data Guard also uses the Data Guard Broker Monitor (DMON) and other process to manage and monitor the primary and standby databases as a unified configuration.
Creating physical standby database using new DUPLICATE FROM ACTIVE DATABASE RMAN command
Conventional backup-based standby db1. Create backup on primary2. Move backup to standby site3. Restore backup and recover
Network-based standby – directly creates image copies on standby site
New “FROM ACTIVE DATABASE” clause- Creates image copies of files on the standby site over the network using parallel channels.- No interim storage needed for a copy of the backup file.- Simple steps performed on the Standby server
Do a software-only install on the standby database system.Setup OracleNet.Create a static listener entry for the standby, start the listener.Create Oracle Net connect descriptors for the Standby at the Primary site and for the Primary at the Standby site.Create an init.ora file with only the DBNAME in it.Create a password file with the same SYS password.Create any necessary directories.Startup nomount the standby instance.Execute the new duplicate command
On primary db ORCL
-Spfile
SQL> SHOW PARAMETER SPFILE
If not using SPFILE
SQL>CREATE SPFILE FROM PFILESQL>SHUTDOWN IMMEDIATE;SQL>STARTUP;
-Archivelog mode
SQL>ARCHIVE LOG LIST – if not in archivelog modeSQL>SHUTDOWN IMMEDIATE;SQL>STARTUP MOUNT;SQL>ALTER DATABASE ARCHIVELOG;SQL>ALTER DATABASE OPEN;SQL>ALTER DATABASE FORCE LOGGING;SQL> SELECT LOG_MODE,FORCE_LOGGING,OPEN_MODE,DATABASE_ROLE FROM V$DATABASE;
-Force logging : nologging, append hint are ignored
Create standby redo logfiles – size :must be same as online redo log files– number – one more than the number of online redo log groups– can be multiplexed – created on primary (for role reversal)– RMAN will create on standby db
SQL> SELECT BYTES/1024/1024 FROM V$LOG – 50M
SQL>ALTER DATABASE ADD STANDBY LOGFILE ‘E:\APP\VIJAYEK\ORADATA\ORCL\SRL01.LOG’ SIZE 50M;
SQL>ALTER DATABASE ADD STANDBY LOGFILE ‘E:\APP\VIJAYEK\ORADATA\ORCL\SRL02.LOG’ SIZE 50M;
SQL>ALTER DATABASE ADD STANDBY LOGFILE ‘E:\APP\VIJAYEK\ORADATA\ORCL\SRL03.LOG’ SIZE 50M;
SQL>ALTER DATABASE ADD STANDBY LOGFILE ‘E:\APP\VIJAYEK\ORADATA\ORCL\SRL04.LOG’ SIZE 50M;
SQL> SELECT GROUP#,BYTES/1024/1024 FROM V$STANDBY_LOG;
SQL>SELECT GROUP#,MEMBER FROM V$LOGFILE WHERE TYPE='STANDBY';
TYPE : ONLINE OR STANDBY
SQL>ALTER SYSTEM SET LOG_ARCHIVE_CONFIG=’DG_CONFIG=(ORCL,ORCLSBY)’ SCOPE=BOTH;
Uses the DG_CONFIG attribute to list the DB_UNIQUE_NAME of the primary and standby databases.
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=’SERVICE=ORCLSBY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLSBY’ SCOPE=BOTH;
Valid only for the primary role, this destination transmits redo data to the remote physical standby destination orclsby.
SQL> SHOW PARAMETER LOG_ARCHIVE_DEST_2
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=’ENABLE’ SCOPE=BOTH’; --Default is enable
SQL> SHOW PARAMETER LOG_ARCHIVE_DEST_STATE_2
* select dest_id,dest_name,status, type,destination from v$archive_dest;
When primary is in standby role
SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='\ORCLSBY\','\ORCL\' SCOPE=SPFILE;
SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='\ORCLSBY\','\ORCL\'SCOPE=SPFILE;
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO'SCOPE=BOTH;
When new tablespaces are created or datatfiles are added to primary db, they are automatically created on standby database.
SQL>ALTER SYSTEM SET FAL_SERVER='ORCLSBY' SCOPE=BOTH;
SQL>ALTER SYSTEM SET FAL_CLIENT='ORCL' SCOPE=BOTH;
These are TNS service names
Here ORCLSBY is the service name (TNS entry) to connect to standby db ORCLSBY
Configure TNSNAMES.ora in ORACLE_HOME\NETWORK\ADMIN to connect to standby database
ORACLE_HOME : E:\app\vijayek\product\11.1.0\db_1
ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
ORCLSBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCLSBY) ) )
Statically register the primary db orcl with listener – required incase of failover
Configure LISTENER.ora in ORACLE_HOME\NETWORK\ADMIN
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = ORCL) ) )
LISTENER = (DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) ) )
LSNRCTLLSNRCTL> reloadLSNRCTL> statusLSNRCTL> services
Go to ORACLE_HOLE (E:\app\vijayek\product\11.1.0\db_1) DATABASE folder
Copy PWDorcl.ora to standby site in the same location as PWDorclsby.ora
(On unix go to dbs folder in ORACLE_HOME and copy orpworcl.ora to standby database in the same location as orapworclsby.ora)
OR create password file on standby db using orapwd utility. Password has to be same as that of primary db. The password for the SYS user on every database in a Data Guard configuration must be identical for redo transmission to succeed.
The password file must be re-copied each time the SYSDBA or SYSOPER privilege is granted or revoked and whenever the login password of a user with these privileges is changed. You may need FTP, or some other remote file transfer mechanism, if you are using different servers.
orapwd file=ORACLE_HOME\DATABASE\PWDORCLSBY.ORA password=wipro entries=5 force=y ignorecase=y
On standby database create initorclsby.ora file in ORACLE_HOME\DATABASE folder with only one parameter DB_NAME=orclsby
On standby db for window – create windows service using oradim
oradim –NEW –SID orclsby –STARTMODE manual –PFILE ‘E:\app\vijayek\product\11.1.0\db_1\database\initorclsby.ora’
Statically register the standby db with listener (because initially standby db will be started in nomount stage – dynamic registration happens by PMON when the db is opened)
Configure LISTENER.ora in ORACLE_HOME\NETWORK\ADMIN
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ORCLsby) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = ORCLsby) )
)
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) ) )
LSNRCTLLSNRCTL> reloadLSNRCTL> statusLSNRCTL> services
Configure TNSNAMES.ora in ORACLE_HOME\NETWORK\ADMIN to connect to primary database
ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
ORCLSBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCLSBY) ) )
ORACLE_BASE : E:\app\vijayek
On standby create the following folders1. go to ORACLE_BASE\admin – create folder ORCLSBY2. go to ORACLE_BASE\admin\orclsby – create folder adump : this is the audit
trail destination 3. go to ORACLE_BASE – create folder oradata4. go to ORACLE_BASE\oradata – create folder orclsby5. go to ORACLE_BASE – create folder flash_recover_area6. go to ORACLE_BASE\flash_recovery_area – create folder orclsby7. go to ORACLE_BASE\diag\rdbms – create folder orclsby8. go to ORACLE_BASE\diag\rdbms\orclsby – create folder orclsby
On standby db - ORCLSBY
Set ORACLE_SID=ORCLSBYExport ORACLE_SID – unix only Sqlplus /nolog
SQL>CONN / AS SYSDBASQL>STARTUP NOMOUNT PFILE=’ E:\APP\VIJAYEK\PRODUCT\11.1.0\DB_1\DATABASE\INITORCLSBY.ORA’;SQL>EXIT;
On primary site
Set ORACLE_SID=ORCLExport ORACLE_SIDRMAN
RMAN>connect target sys/wipro
connected to target database: ORCL
RMAN>connect auxiliary sys/wipro@orclsby
connected to auxiliary database: ORCLSBY (not mounted)
RMAN>@create_standby.txt
Create_standby.txt
RUN {ALLOCATE CHANNEL P1 TYPE DISK;ALLOCATE AUXILIARY CHANNEL S1 TYPE DISK;DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASESPFILEPARAMETER_VALUE_CONVERT 'ORCL','ORCLSBY'SET DB_UNIQUE_NAME='ORCLSBY'SET DB_FILE_NAME_CONVERT='\ORCL\','\ORCLSBY\'SET LOG_FILE_NAME_CONVERT='\ORCL\','\ORCLSBY\'SET CONTROL_FILES='E:\APP\VIJAYEK\ORADATA\ORCLSBY\CONTROL01.CTL'SET LOG_ARCHIVE_MAX_PROCESSES='5'SET FAL_CLIENT='ORCLSBY'SET FAL_SERVER='ORCL'SET STANDBY_FILE_MANAGEMENT='AUTO'SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL,ORCLSBY)'SET LOG_ARCHIVE_DEST_STATE_2='ENABLE'SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL LGWR ASYNC VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL';}
Parameter_value_convert – is used to set values of a bunch of directory related init parameters like user_dump_dest, core_ , background_, audit_file_dest – replaces ORCL with ORCLSBY for these parameters – except for data files and log file destinations.
RMAN>EXIT;
On the primary systemSet ORACLe_SID=orclExport ORACLE_SIDSqlplus /nolog
SQL>CONN / AS SYSDBASQL>ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT MAX(SEQUENCE#) FROM V$LOG;
On the standsby system
Set ORACLe_SID=orclsbyExport ORACLE_SIDSqlplus /nolog
SQL>CONN / AS SYSDBA
SQL> SELECT OPEN_MODE,DATABASE_ROLE, PROTECTION_MODE, LOG_MODE,FORCE_LOGGING FROM V$DATABASE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
current logfile – real time apply disconnect – MRP does the recovery in background
SQL> SELECT MESSAGE FROM V$DATAGUARD_STATUS;
SQL> SELECT * FROM V$ARCHIVE_GAP;
SQL> SELECT PROCESS,CLIENT_PROCESS, STATUS, SEQUENCE#, GROUP# FROM V$MANAGED_STANDBY;
SQL> SELECT MAX(SEQUENCE#) FROM V$LOG;
SQL> SELECT SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG;
SQL> SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=2; -- on primary and standby
Converting to snapshot standby :
On Standby DB
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
- stops MRP process
SQL> SELECT FLASHBACK_ON FROM V$DATABASE; - NO
SQL> SELECT * FROM V$RESTORE_POINT; - NO ROWS
SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;
- this enables flashback logging and creates a restore point
SQL> SHUTDOWN IMMEDIATE;
SQL>STARTUP;
SQL> SELECT OPEN_MODE,DATABASE_ROLE, FLASHBACK_ON FROM V$DATABASE;
Setup Test Environments using Snapshot Standbys
Convert Physical Standby to Snapshot Standby and open for writes by the testing applications
ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;
Discard testing writes and catch-up to primary by applying logs
ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
Preserves zero data loss But no real time query or fast
failover
Similar to storage snapshots, but:Provides DR at the same timeSingle copy of storage
Physical Standby Apply Logs
Snapshot Standby Perform Testing
Open Database
Back out Changes
Continuous Redo Shipping
OPEN_MODE DATABASE_ROLE FLASHBACK_ON---------- ---------------- ------------------READ WRITE SNAPSHOT STANDBY RESTORE POINT ONLY
SQL> SELECT * FROM V$RESTORE_POINT; - one row –one restore point
SQL> CREATE TABLE SCOTT.SNAPSHOT_T1 (C VARCHAR(100));
Table created.
SQL> INSERT INTO SCOTT.SNAPSHOT_T1 VALUES ('TABLE CREATED IN SNAP MODE');
1 row created.
SQL> COMMIT;
Commit complete.
On primary database
SQL> CREATE TABLE SCOTT.P_NEW_TABLE (C VARCHAR(100));
Table created.
SQL> INSERT INTO SCOTT.P_NEW_TABLE VALUES ('NEW TABLE CREATED IN PRIMARY WHEN SBY IN SNAPSHOT MODE');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered.
SQL> /
System altered.
Converting back to physical standby on Standby DB
SQL> SELECT * FROM V$LOG;
SQL> SELECT * FROM V$STANDBY_LOG;
SQL> SELECT SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG;
SQL> SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
SQL> SELECT OPEN_MODE,DATABASE_ROLE, FLASHBACK_ON FROM V$DATABASE;
SQL> SELECT * FROM V$RESTORE_POINT; - no rows
SQL> SELECT OPEN_MODE,DATABASE_ROLE, PROTECTION_MODE, LOG_MODE,FORCE_LOGGING FROM V$DATABASE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
current logfile – real time apply disconnect – MRP does the recovery in background
SQL> SELECT MESSAGE FROM V$DATAGUARD_STATUS;
SQL> SELECT * FROM V$ARCHIVE_GAP;
SQL> SELECT PROCESS,CLIENT_PROCESS, STATUS, SEQUENCE#, GROUP# FROM V$MANAGED_STANDBY;
SQL> SELECT MAX(SEQUENCE#) FROM V$LOG;
SQL> SELECT SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG;
ACTIVE DATA GUARD
On standby db
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> ALTER DATABASE OPEN READ ONLY;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.
Perform log switches on Primary and note down max sequence#.
Physical Standby with Real-Time Query
Physical Standby Database
Primary Database
Real-time Queries
Continuous Redo Shipment and Apply
Concurrent Real-Time
Query
Read-only queries on physical standby concurrent with redo apply
RMAN BACKUP/Fast incremental backup on physical standby ( only with Active Data Guard option)
SQL> SELECT MAX(SEQUENCE#) FROM V$LOG;
MAX(SEQUENCE#) -------------- 143
SQL> SELECT OPEN_MODE,DATABASE_ROLE FROM V$DATABASE;
SQL> DESC SCOTT.P_NEW_TABLE Name Null? Type ----------------------------------------- -------- ---------------------------- C VARCHAR2(100)
SQL> SELECT * FROM SCOTT.P_NEW_TABLE;
C --------------------------------------------------------------------------------new table created in primary when sby in snapshot mode
SQL> DESC SCOTT.SNAPSHOT_T1ERROR:ORA-04043: object SCOTT.SNAPSHOT_T1 does not exist
ON PRIMARY DB – INSERT A ROW INTO SCOTT.DEPT and commit ON STANDBY DB – QUERY SCOTT.DEPT TO C THE NEWLY ADDED ROW
Protection Modes:
Maximum ProtectionSynchronized Redo write. Primary database shuts down if a fault occurs at write at the standby.
Maximum AvailabilitySynchronized Redo write. Protection mode temporarily switches over to Maximum performance if write fails at the standby.
Maximum PerformanceAsynchronized Redo write.
Run the following on the Primary DB
Alter system set log_archive_dest_2 = sync affirm
Shutdown immediate;
Startup mount
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE {PROTECTION | AVAILABILITY | PERFORMANCE};
Alter database open;
Minimum Requirements for Data Protection ModesMaximum Protection
Maximum Availability Maximum Performance
Redo archival process
LGWR LGWR LGWR or ARCH
Network transmission mode
SYNC SYNC SYNC or ASYNC when using LGWR process. SYNC if using ARCH process
Disk write option AFFIRM AFFIRM AFFIRM or NOAFFIRM
Standby redo log required?
Yes Yes Optional, but recommended
The AFFIRM attribute is used to specify that redo received from a redo source database is not acknowledged until it has been written to the standby redo log. The NOAFFIRM attribute is used to specify that received redo is acknowledged without waiting for received redo to be written to the standby redo log.
AFFIRM--ensures all disk I/O to the archived redo log files or standby redo log files at the standby destination is performed synchronously and completes successfully before online redo log files on the primary database can be reused. The AFFIRM attribute is required to achieve no data loss.
NOAFFIRM--indicates all disk I/O to archived redo log files and standby redo log files is to be performed asynchronously; online redo log files on the primary database can be reused before the disk I/O on the standby destination completes.
Query the AFFIRM column of the V$ARCHIVE_DEST fixed view to see whether or not the AFFIRM attribute is being used for the associated destination.
SELECT DEST_ID,STATUS,LOG_SEQUENCE,AFFIRM,PROCESS,TRANSMIT_MODE,COMPRESSION
FROM V$ARCHIVE_DESTWHERE DEST_ID=2;
Verify the use of following setting
SQL>ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO' SCOPE=BOTH;
Create new tablespace in Primary DB
SQL> CREATE TABLESPACE NEW_TS DATAFILE 'E:\APP\VIJAYEK\ORADATA\ORCL\NEW_TS_01.DBF' SIZE 1M;
Verify that the new tablespace is automatically created in stand by running the following two in standby db
SQL> SELECT NAME FROM V$DATAFILE;
SQL> SELECT NAME FROM V$TABLESPACE;
Drop the newly created tablespace in Primary DB
SQL> DROP TABLESPACE NEW_TS DATAFILE INCLUDING CONTENTS AND DATAFILES;
Verify that the new tablespace and datafile are automatically droped in stand by running the following two in standby db
SQL> SELECT NAME FROM V$DATAFILE;
SQL> SELECT NAME FROM V$TABLESPACE;
Manual Switchover and Failover using SQL*Plus
1. Log onto the current primary database as SYSDBA and perform the following steps: (in the case of a failover, skip this step)
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
If switchover_status is “Sessions Active” then
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
else
ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
SELECT DATABASE_ROLE,OPEN_MODE FROM V$DATABASE;
2. Log onto the standby database that is about to become primary as SYSDBA and perform the following steps:
For failover only, submit the following: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
For switchover and failover proceed with these steps:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SHUTDOWN IMMEDIATE;
STARTUP;
SELECT DATABASE_ROLE,OPEN_MODE FROM V$DATABASE;
Data Guard Broker Configurtion:
On primary db:SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = ORCL) ) (SID_DESC = (GLOBAL_DBNAME = orcl_DGMGRL) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = orcl) ) )
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) ) )
LSNRCTLLSNRCTL>reload
On standby db:
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orclsby) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = orclsby) ) (SID_DESC = (GLOBAL_DBNAME = orclsby_DGMGRL) (ORACLE_HOME = E:\app\vijayek\product\11.1.0\db_1) (SID_NAME = orclsby) )
)
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = L-4003407)(PORT = 1521)) ) )
LSNRCTLLSNRCTL>reload
On Primary db
SET ORACLE_SID=ORCLDGMGRLDGMGRL> CONNECT SYS/WIPRODGMGRL> CREATE CONFIGURATION ‘DGCONFIG1’ AS PRIMARY DATABASE IS ‘ORCL’ CONNECT IDENTIFIER IS ORCL;
DGMGRL> SHOW CONFIGURATION
DGMGRL> ADD DATABASE ‘ORCLSBY’ AS CONNECT IDENTIFIER IS ORCLSBY;
DGMGRL> SHOW CONFIGURATION
DGMGRK> ENABLE CONFIGURATION
DGMGRL> SHOW CONFIGURATION
DGMGRL> SHOW DATABASE ‘ORCL’
DGMGRL> SHOW DATABASE ‘ORCLSBY’
Here ORCL and ORCLSBY are DB_UNIQUE_NAME’s
Configuration file is created in E:\app\vijayek\product\11.1.0\db_1\database foldershow parameters dg_broker
Converting to Snapshot standby using DG Broker :
On standby db;
SQL> SELECT FLASHBACK_ON FROM V$DATABASE; --- no
SET ORACLE_SID=ORCLSBY
DGMGRL
DGMGRL> CONNECT SYS/SYS
DGMGRL>EDIT DATABASE ‘ORCLSBY’ SET STATE=’APPLY-OFF’;
SQL> SHUTDOWM IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE FLASHBACK ON;
DGMGRL
DGMRGL> CONNECT SYS/SYS
DGMGRL> EDIT DATABASE ‘ORCLSBY’ SET STATE=’APPLY-ON’;
On Primary db
SET ORACLE_SID=ORCL
DGMGRLDGMGRL> CONNECT SYS/SYS
DGMGRL> CONVERT DATABASE ‘ORCLSBY’ TO SNAPSHOT STANDBY;
DGMGRL> SHOW CONFIGURATION
Create new table on both primary and snapshot standby. After snapshot is converted back to physical standby – the newly create table in primary gets applied to physical standby and the newly created table snapshot is removed.
Converting back to physical standby using DG Broker
On primary db
SET ORACLE_SID=ORCLDGMGRLDGMGRL> CONNECT SYS/SYS
DGMGRL> CONVERT DATABASE ‘ORCLSBY’ TO PHYSICAL STANDBY;
DGMGRL> SHOW CONFIGURATION
Active Data Guard using DG Broker :
On standby db:
SET ORACLE_SID=ORCLSBY
DGMGRLDGMGRL>CONNECT SYS/SYS
DGMGRL> EDIT DATABASE ‘ORCLSBY’ SET STATE=’APPLY-OFF’;
SQL> ALTER DATABASE OPEN READ ONLY;
SET ORACLE_SID=ORCLSBY
DGMGRLDGMGRL>CONNECT SYS/SYS
DGMGRL> EDIT DATABASE ‘ORCLSBY’ SET STATE=’APPLY-ON’;
Update the primary db and query the standby to view the changes.
Configure Fast Start Failover :
Put both the database’s in flashback mode, this helps to rewind the database to a state prior to its failure.
On standby database ORCLSBY:
SHUTDOWN IMMEDUATE;
On primary database ORCL:
SHUTDOWN IMMEDIATE;STARTUP MOUNT;ALTER DATABASE FLASHBACK ON;SELECT FLASHBACK_ON FROM V$DATABASE;
On standby database ORCLSBY:
STARTUP MOUNT;ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;ALTER DATABSE FLASHBACK ON;SELECT FLASHBACK_ON FROM V$DATABASE;ALTER DATABASE OPEN READ ONLY;ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
DGMGRLDGMGRL> connect sys/Wipro@orcl
DGMGRL> EDIT DATABASE ‘orcl’ SET PROPERTY FastStartFailoverTarget = 'orclsby';
DGMGRL> SHOW DATABASE VERBOSE ‘orcl’;
DGMGRL> EDIT DATABASE ‘orclsby’ SET PROPERTY FastStartFailoverTarget = 'orcl';
DGMGRL> SHOW DATABASE VERBOSE ‘orclsby’;
DGMGRL> show fast_start failover;
DGMGRL> enable fast_start failover;
DGMGRL> show fast_start failover;
DGMGRL> start observer;
The Observer has started its working. The current session of ‘cmd’ will not be returned to you because it is a foreground process. It will continuously observe PRIMARY site. To check the configuration, open another ‘cmd’ window and check the configuration.
DGMGRLDGMGRL> connect sys/Wipro@orclDGMGRL> SHOW CONFIGURATION verbose;
Open a new cmd window connect to primary db and Shutdown abort – the primary database orcl.
Sqlplus /@orcl as sysdba
SQLPLUS>SHUTDOWN ABORT;
Go back to the observer window and observer the messages
SET ORACLE_SID=ORCLSBYSELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;
DGMGRLDGMGRL> CONNECT SYS/WIPRO@ORCLSBYDGMGRL> SHOW CONFIGURATION VERBOSE;
Open new window :
Sqlplus /@orcl as sysdba
SQLPLUS>STARTUP MOUNT; - goto observer window and observe
SELECT STATUS FROM V$INSTANCE;SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;
The new standby database – orcl – would be in mount stage. Perform the following to put in back in active data guard mode.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;ALTER DATABASE OPEN READ ONLY;ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Again revert back orcl as primary and orclsby as standby database:
Dgmgrl> SWITCHOVER TO ‘ORCL’;
After switchover, the new standby database – orclsby – would be in mount stage. Perform the following to put in back in active data guard mode.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;ALTER DATABASE OPEN READ ONLY;ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Shutting Down Databases In a Fast-Start Failover Environment
Stop the observer and wait for the FS_FAILOVER_OBSERVER_PRESENT column in the V$DATABASE fixed view to contain the value "NO" for both the primary and target standby databases. This ensures that a fast-start failover will not occur while you are shutting down the primary database.Shut down the primary database and the target standby database using either DGMGRL SHUTDOWN command or the SQL*Plus SHUTDOWN statement.
Conversion from Physical to Logical Standby
You can now easily convert a physical standby database to a logical one. Here are the steps:
Unsupported Datatypes :
BFILECollections (including VARRAYS and nested tables)Multimedia data types (including Spatial, Image, and Oracle Text)ROWID, UROWIDUser-defined typesLOBs stored as SecureFilesXMLType stored as Object RelationalBinary XML
Identify unsupported objects :
SELECT DISTINCT OWNER,TABLE_NAME FROM DBA_LOGSTDBY_UNSUPPORTED ORDER BY OWNER,TABLE_NAME;
1. The standby database will need to get the data dictionary information from somewhere. The dictionary information should be put in the redo stream that comes from the primary. So, on the primary database, issue the following to build the LogMiner tables for dictionary:
SQL> begin 2 dbms_logstdby.build; 3 end; 4 / PL/SQL procedure successfully completed.2. On the standby database, stop the managed recovery process:
SQL> alter database recover managed standby database cancel;
Database altered.3. Now, issue the command in standby side to convert it to logical:
SQL> alter database recover to logical standby ORCLSBY; Database altered.
If you didn't execute Step 1, the above command will wait since the dictionary information is not found. Don't worry; just execute the Step 1 at this point. If you have enabled RTA, the information will immediately appear on the standby database.
4. Issue a few log switches on primary to make sure the archived logs are created and sent over to the standby:
SQL> alter system switch logfile; System altered.
5. On the standby side, you can see that the alter database command has completed, after some time. Now the standby is a logical one. You will see the following line in alert log:
RFS[12]: Identified database type as 'logical standby'6. Recycle the database:
SQL> shutdownORA-01507: database not mountedORACLE instance shut down.SQL> startup mountORACLE instance started. Total System Global Area 1071333376 bytes...Database mounted.SQL> alter database open resetlogs; Database altered.7. Now that this is a logical standby database, you should start the SQL Apply
process.
SQL> alter database start logical standby apply immediate;
The logical standby database is now fully operational! Once you convert the physical standby to a logical one, you can't convert it back to a physical one unless you use the special clause ("keep identity"), described in the section below.
The following example allows log transport services up to three consecutive archival attempts, tried every 5 seconds, to the arc_dest destination. If the archival operation fails after the third attempt, the destination is treated as if the NOREOPEN attribute was specified.
LOG_ARCHIVE_DEST_1='LOCATION=/arc_dest REOPEN=5 MAX_FAILURE=3'LOG_ARCHIVE_DEST_STATE_1=ENABLE
The NET_TIMEOUT and NONET_TIMEOUT attributes determine how long the log writer process waits before terminating the network connection:
NET_TIMEOUT--specifies the number of seconds the log writer process on the primary system waits for status from the network server (LNSn) process before terminating the network connection.
NONET_TIMEOUT -- reverses or undoes the timeout value that was previously specified with the NET_TIMEOUT attribute.
If you do not specify the NET_TIMEOUT attribute (or if you specify the NONET_TIMEOUT attribute), the primary database can potentially stall. To avoid this situation, specify a small, nonzero value for the NET_TIMEOUT attribute so the primary database can continue operation after the user-specified timeout interval expires when waiting for status from the network server.
select reopen_secs,max_failure,delay_mins, net_timeout, archiver
from v$archive_dest
where dest_id=2
/
v$fs_failover_stats -view to see when and reason for the last failover occured
References :
http://www.oracle.com/technology/pub/articles/oracle-database-11g-top-features/index.html?msgid=5879171
Oracle Data Guard 11g The Next Era in Data Protection and Availability An Oracle Technical White Paper
10g R2 :http://www.orafaq.com/wiki/Data_Guard_implementation_for_Oracle_10gR2#PRIMARY_SITE:_.28Information.29