How to use the Flashback database feature to restore the Dataguard environment after failover?

Source: Internet
Author: User
Tags failover

11g Dataguard standby cut into the main library and restored to the original standby environment after the test is completed


#######################
Overview:
11204 single machine to implement DG, because the local requirements (read-write mode) to open standby, and then the original production environment can not have any impact, still external services;
The idea is that: Standby direct failover to primary db, then the original DG relationship is destroyed, non-impact;


#######################
Summary of Ideas:
1. Confirm that the main library archive log storage space is sufficient? (need to consider archiving retention deletion policy?) ); Turn off log transfers from the main library to the standby library
2. Does the repository confirm that the flashback database is turned on, and that the Flash log storage space is sufficient?
3. Standby failover to primary (before switching to confirm whether the log delay transmission?) Manual registration)
4. Business Testing
5. Restore the Failover Standby library
6. Confirm the DG Environment Recovery is normal (log automatic transfer and application?) )?



#######################
Specific implementation steps:

------Main Library Defer log transfer
alter system set Log_archive_dest_2=defer;

---enable log transfer:
alter system set log_archive_dest_2=enable;

-----Standby (Mount) configuration Flashback database:
STANDBY database:stop Redo Apply, configure flashback retention,
Start Flashback database, open the database and start redo apply (is active DG).

---Check if the repository is enabled Flashback database:
Select flashback_on from V$database;


Note that there is a need to confirm the Repository open mode: Mount? ReadOnly with apply?
The ADG feature can be enabled in a 11g environment the repository log is in real time and the database schema is readonly with apply
In this case, you need to restart the database to mount state to modify flashback DB mode;


If the standby library is in Mount state, you can cancel the log apply and open the Flashback database feature directly;


---to cancel the Repository log app:
ALTER database RECOVER MANAGED STANDBY database CANCEL;


---need to configure two parameters to open the Flashback database feature:
ALTER SYSTEM SET db_recover_file_dest= '/lixora/lixora/lixora/';
ALTER SYSTEM SET db_recover_file_dest_size=100g;

ALTER SYSTEM SET db_flashback_retention_target=240; ---4hours
ALTER DATABASE FLASHBACK on;

--Create a restore point manually (this step has not been tested):
Creating Restore Point in physical Standby:
CREATE RESTORE Point before_damage GUARANTEE FLASHBACK DATABASE


-------standby failover to primary DB emergency switching steps:
(Note: Simulation of the main library due to failure is not normal switchover, need to perform failover, force the library->pridb and take over the business)

1. Prepare the library:
Since it is a failover, understanding the main library is not working properly at this time, only the standby library switches to PRIDB

"Premise Main library is still available: optional" The query does not have an applied log:
SELECT thread#, low_sequence#, high_sequence# from V$archive_gap;

SELECT DISTINCT Thread#,max (sequence#) over (partition by thread#) a from V$archived_log;
This statement gets the maximum number of archived files for each thread in the current database, and if the primary is not the same as the standby maximum sequence number,
You must copy the archived files for the extra ordinal number to the standby server that you want to convert.


CP Come and register
ALTER DATABASE REGISTER physical LOGFILE ' FILESPEC1 '

Stop Applying recovery mode
ALTER DATABASE recover managed standby database finish;
Or
ALTER database RECOVER MANAGED STANDBY database FINISH Force;

Convert Standbydb to Primary db
ALTER DATABASE commit to switchover to primary;


Restart the database to resume normal business
ALTER DATABASE open;


Database role View:
Select Open_mode,database_role from V$database;
Open_mode Database_role
----------      ----------------
OPEN PRIMARY


------Restore the Failover repository:
C. Using Sql*plus
Step 1 Determine the Standby became Primary SCN.
Step 2 Flashback the Failed Primary Database.
Step 3 Convert to physical standby database.
Step 4 Restart Redo Transport.
Step 5 Start Redo Apply.


Step 1 determine the SCN at which the old standby database became the primary database.
Sql> SELECT To_char (STANDBY_BECAME_PRIMARY_SCN) from V$database;


Step 2 Flashback The Failed Primary Database to SCN STANDBY_BECAME_PRIMARY_SCN.
Sql> SHUTDOWN IMMEDIATE;
Sql> Startup Mount
Sql> FLASHBACK DATABASE to SCN <standby_became_primary_scn of step 1>;

Step 3 Convert The database to a physical standby database and Restart database in Mount stage.
Sql> ALTER DATABASE CONVERT to physical STANDBY;
Sql> SHUTDOWN IMMEDIATE;
Sql> STARTUP MOUNT;


Step 4 Restart Redo Transport to the New physical Standby Database.
1. If you had not set the remote archive destination in current primary then set remote archive destination:
Sql>alter SYSTEM SET log_archive_dest_2 = ' Service=lixora valid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME= Lixora ' Scope=both;

2. Enable the destination
Sql>alter SYSTEM SET log_archive_dest_state_2=enable;

3. Perform a log switch to ensure this standby database begins receiving redo data from the new primary database
sql> ALTER SYSTEM SWITCH LOGFILE;
Sql> SELECT dest_id, STATUS, ERROR from V$archive_dest WHERE dest_id=2;


--Confirm that the log is all apply?
Select applied from V$archived_log;

Select Message from V$dataguard_status;


Step 5 Start Redo Apply.
sql> ALTER database RECOVER MANAGED STANDBY database DISCONNECT from SESSION;
Please see also fallowing docu:


TIPS:
Oracle? Data Guard Concepts and administration
11g Release 2 (11.2)
13.2 Converting a Failed Primary into a Standby database Using Flashback Database

How to use the Flashback database feature to restore the Dataguard environment after failover?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.