suchen
HeimDatenbankMySQL-TutorialOracle 11g Data Guard Role Transitions: Failover

Role TransitionsInvolving Physical Standby Databases A database operates in one of the following mutuallyexclusive roles: primary or standby . Data Guard enables you to change theseroles dynamically by issuing the SQL statements described

Role TransitionsInvolving Physical Standby Databases

 

A database operates in one of the following mutuallyexclusive roles:primary or standby. Data Guard enables you to change theseroles dynamically by issuing the SQL statements described in this chapter, orby using either of the Data Guard broker's interfaces. Oracle Data Guardsupports the following role transitions:

 

  • Switchover
    Allows the primary database to switch roles with one of its standby databases. There is no data loss during a switchover. After a switchover, each database continues to participate in the Data Guard configuration with its new role.

 

  • Failover
    Changes a standby database to the primary role in response to a primary database failure. If the primary database was not operating in either maximum protection mode or maximum availability mode before the failure, some data loss may occur. If Flashback Database is enabled on the primary database, it can be reinstated as a standby for the new primary database once the reason for the failure is corrected.

 

Performing a Failoverto a Physical Standby Database

 

Fault Simulation

 

Original Primary:

SQL>set linesize 200

SQL>  selectOPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,DB_UNIQUE_NAME,SWITCHOVER_STATUS fromv$database;

 

OPEN_MODE            PROTECTION_MODE      DATABASE_ROLE    DB_UNIQUE_NAME                 SWITCHOVER_STATUS

---------------------------------------- ---------------- --------------------------------------------------

READWRITE           MAXIMUM AVAILABILITYPRIMARY          prod                           TO STANDBY

 

SQL>exit

Disconnectedfrom Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

Withthe Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@prod~]$ ps -ef | grep smon

oracle    3915    1  0 16:20 ?        00:00:01 ora_smon_prod

oracle    4584 3323  0 16:57 pts/1    00:00:00 grep --color=auto smon

[oracle@prod~]$ kill -9 3915

 

Step1   Flush any unsent redo from the primary database to thetarget standby database.

 

If the primary database can be mounted, it may be possible to flush any unsent archived andcurrent redo from the primary database to the standby database. If thisoperation is successful, a zero data loss failover is possible even if theprimary database is not in a zero data loss data protection mode.

 

Ensure that Redo Apply is active at the targetstandby database.

Standby:

SQL>select OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,DB_UNIQUE_NAME,SWITCHOVER_STATUSfrom v$database;

 

OPEN_MODE            PROTECTION_MODE      DATABASE_ROLE    DB_UNIQUE_NAME                 SWITCHOVER_STATUS

---------------------------------------- ---------------- --------------------------------------------------

READ ONLY WITH APPLY MAXIMUM AVAILABILITY PHYSICALSTANDBY standby                        TOPRIMARY

 

Primary:

Mount, but do not open the primarydatabase. If the primary database cannot be mounted, go toStep2.

Issue the following SQL statement at the primarydatabase:

SQL>startup mount;

ORACLEinstance started.

TotalSystem Global Area  263639040 bytes

FixedSize                  1344312 bytes

VariableSize             230689992 bytes

DatabaseBuffers           25165824 bytes

RedoBuffers                6438912 bytes

Databasemounted.

SQL>alter system flush redo to 'standby';

Systemaltered.

 

 ALTER SYSTEMFLUSH REDO TO target_db_name .

For target_db_name, specify the DB_UNIQUE_NAME of thestandby database that is to receive the redo flushed from the primary database.

This statement flushes any unsent redo from theprimary database to the standby database, and waits for that redo to be appliedto the standby database.

If this statement completes without anyerrors, go toStep5. If the statement completes with any error,or if it must be stopped because you cannot wait any longer for the statementto complete, continue with Step2.

 

Step2   Verify that the standby database has the most recentlyarchived redo log file for each primary database redo thread.

Query the V$ARCHIVED_LOG view on the target standbydatabase to obtain the highest log sequence number for each redo thread.

 

Primary and Standby

SQL>SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) ASLAST from V$ARCHIVED_LOG;

 

    THREAD      LAST

--------------------

         1         98

standby

If possible, copy the most recently archived redo logfile for each primary database redo thread to the standby database if it doesnot exist there, and register it. This must be done for each redo thread.

 

ALTERDATABASE REGISTER PHYSICAL LOGFILE 'redo_logfile';

 

Step3   Identify and resolve any archived redo log gaps.

 

Query the V$ARCHIVE_GAP view on the target standbydatabase to determine if there are any redo gaps on the target standbydatabase.

SQL>SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

norows selected

 

THREAD#   LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
         1            90             92

In this example the gap comprises archived redo logfiles with sequence numbers 90, 91, and 92 for thread 1.

If possible, copy any missing archived redo log filesto the target standby database from the primary database and register them atthe target standby database. This must be done for each redo thread.

 

SQL>ALTER DATABASE REGISTER PHYSICAL LOGFILE 'redo_logfile';

 

 

Step4   Repeat Step 3 until all gaps are resolved.

The query executed inStep3 displays information for the highest gaponly. After resolving a gap, you must repeat the query until no more rows arereturned.

If, after performingStep2 throughStep4, you are not able to resolve all gaps in thearchived redo log files (for example, because you do not have access to thesystem that hosted the failed primary database), some data loss will occurduring the failover.

 

Step5   Stop Redo Apply.

Issue the following SQL statement on the targetstandby database:

 

SQL>alter database recover managed standby database cancel;

Databasealtered.

 

Step6   Finish applying all received redo data.

Issue the following SQL statement on the targetstandby database:

 

SQL>alter database recover managed standby database finish;

Databasealtered.

 

If this statement completes without anyerrors, proceed toStep7.

If an error occurs, some received redo data was notapplied. Try to resolve the cause of the error and re-issue the statementbefore proceeding to the next step.

Note that if there is a redo gap thatwas not resolved inStep3 andStep4, you will receive an error stating that thereis a redo gap.

If the error condition cannot be resolved, a failovercan still be performed (with some data loss) by issuing the following SQLstatement on the target standby database:

 

SQL>alter database activate physical standby database;

Databasealtered.

SQL>select OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,DB_UNIQUE_NAME,SWITCHOVER_STATUSfrom v$database;

 

OPEN_MODE            PROTECTION_MODE      DATABASE_ROLE    DB_UNIQUE_NAME                 SWITCHOVER_STATUS

---------------------------------------- ---------------- --------------------------------------------------

MOUNTED              MAXIMUM AVAILABILITY PRIMARY          standby                        NOT ALLOWED

 

Proceed toStep9 when the ACTIVATE statement completes.

 

Step7   Verify that the target standby database is ready to become aprimary database.

Query the SWITCHOVER_STATUS column of the V$DATABASEview on the target standby database.

SQL>SELECT SWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

NOTALLOWED

 

A value of either TO PRIMARY or SESSIONS ACTIVEindicates that the standby database is ready to be switched to the primaryrole. If neither of these values is returned, verify that Redo Apply is activeand continue to query this view until either TO PRIMARY or SESSIONS ACTIVE isreturned.

 

Step8   Switch the physical standby database to the primary role.

Issue the following SQL statement on the targetstandby database:

SQL>alter database commit to switchover to primary with session shutdown;

 

Note:

The WITH SESSION SHUTDOWN clause can be omitted fromthe switchover statement if the query of the SWITCHOVER_STATUS column performedin the previous step returned a value of TO PRIMARY.

 

Step9   Open the new primary database.

SQL>alter database open;

Databasealtered.

SQL>select OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE,DB_UNIQUE_NAME,SWITCHOVER_STATUSfrom v$database;

 

OPEN_MODE            PROTECTION_MODE      DATABASE_ROLE    DB_UNIQUE_NAME                 SWITCHOVER_STATUS

---------------------------------------- ---------------- --------------------------------------------------

READWRITE           MAXIMUM AVAILABILITYPRIMARY          standby                        FAILED DESTINATION

 

Step10   Back up the new primary database.

Oracle recommends that a full backup be taken of thenew primary database.

 

Step11   Restart Redo Apply if it has stopped at any of the otherphysical standby databases in your Data Guard configuration.

SQL>alter database recover managed standby database using current logfiledisconnect from session;

 

Step12   Optionally, restore the failed primary database.

After a failover, the original primary database canbe converted into a physical standby database of the new primary database usingthe method

As following:


Flashing Back a FailedPrimary Database into a Physical Standby Database



作者:xiangsir

QQ:444367417

MSN:xiangsir@hotmail.com


 

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
MySQL: Wesentliche Fähigkeiten für Anfänger zu meisternMySQL: Wesentliche Fähigkeiten für Anfänger zu meisternApr 18, 2025 am 12:24 AM

MySQL ist für Anfänger geeignet, um Datenbankfähigkeiten zu erlernen. 1. Installieren Sie MySQL Server- und Client -Tools. 2. Verstehen Sie grundlegende SQL -Abfragen, wie z. B. SELECT. 3.. Stammdatenoperationen: Daten erstellen, Daten einfügen, aktualisieren und löschen. 4. Lernen Sie fortgeschrittene Fähigkeiten: Unterabfragen und Fensterfunktionen. 5. Debugging und Optimierung: Überprüfen Sie die Syntax, verwenden Sie Indizes, vermeiden Sie die Auswahl*und verwenden Sie die Grenze.

MySQL: Strukturierte Daten und relationale DatenbankenMySQL: Strukturierte Daten und relationale DatenbankenApr 18, 2025 am 12:22 AM

MySQL verwaltet strukturierte Daten effizient durch Tabellenstruktur und SQL-Abfrage und implementiert Inter-Tisch-Beziehungen durch Fremdschlüssel. 1. Definieren Sie beim Erstellen einer Tabelle das Datenformat und das Typ. 2. Verwenden Sie fremde Schlüssel, um Beziehungen zwischen Tabellen aufzubauen. 3.. Verbessern Sie die Leistung durch Indexierung und Abfrageoptimierung. 4. regelmäßig Sicherung und Überwachung von Datenbanken, um die Datensicherheit und die Leistungsoptimierung der Daten zu gewährleisten.

MySQL: Schlüsselmerkmale und Funktionen erklärtMySQL: Schlüsselmerkmale und Funktionen erklärtApr 18, 2025 am 12:17 AM

MySQL ist ein Open Source Relational Database Management -System, das in der Webentwicklung häufig verwendet wird. Zu den wichtigsten Funktionen gehören: 1. unterstützt mehrere Speichermotoren wie InnoDB und MyISAM, geeignet für verschiedene Szenarien; 2. Bietet Master-Slave-Replikationsfunktionen, um Lastausgleich und Datensicherung zu erleichtern. 3.. Verbessern Sie die Abfrageeffizienz durch Abfrageoptimierung und Index.

Der Zweck von SQL: Interaktion mit MySQL -DatenbankenDer Zweck von SQL: Interaktion mit MySQL -DatenbankenApr 18, 2025 am 12:12 AM

SQL wird verwendet, um mit der MySQL -Datenbank zu interagieren, um die Datenzusatz, Löschung, Änderung, Inspektion und Datenbankdesign zu realisieren. 1) SQL führt Datenoperationen über SELECT, INSERT, INTERATE, UPDATE, Löschen von Anweisungen durch. 2) Verwenden Sie Anweisungen für Datenbankdesign und -verwaltung create, ändern, fallen. 3) Komplexe Abfragen und Datenanalysen werden über SQL implementiert, um die Effizienz der Geschäftsentscheidungen zu verbessern.

MySQL für Anfänger: Erste Schritte mit der DatenbankverwaltungMySQL für Anfänger: Erste Schritte mit der DatenbankverwaltungApr 18, 2025 am 12:10 AM

Zu den grundlegenden Operationen von MySQL gehört das Erstellen von Datenbanken, Tabellen und die Verwendung von SQL zur Durchführung von CRUD -Operationen für Daten. 1. Erstellen Sie eine Datenbank: createdatabasemy_first_db; 2. Erstellen Sie eine Tabelle: CreateTableBooks (IDINGAUTO_INCRECTIONPRIMARYKEY, Titelvarchar (100) Notnull, AuthorVarchar (100) Notnull, veröffentlicht_yearint); 3.. Daten einfügen: InsertIntoBooks (Titel, Autor, veröffentlicht_year) va

MySQLs Rolle: Datenbanken in WebanwendungenMySQLs Rolle: Datenbanken in WebanwendungenApr 17, 2025 am 12:23 AM

Die Hauptaufgabe von MySQL in Webanwendungen besteht darin, Daten zu speichern und zu verwalten. 1.Mysql verarbeitet effizient Benutzerinformationen, Produktkataloge, Transaktionsunterlagen und andere Daten. 2. Durch die SQL -Abfrage können Entwickler Informationen aus der Datenbank extrahieren, um dynamische Inhalte zu generieren. 3.Mysql arbeitet basierend auf dem Client-Server-Modell, um eine akzeptable Abfragegeschwindigkeit sicherzustellen.

MySQL: Erstellen Sie Ihre erste DatenbankMySQL: Erstellen Sie Ihre erste DatenbankApr 17, 2025 am 12:22 AM

Zu den Schritten zum Erstellen einer MySQL -Datenbank gehören: 1. Erstellen einer Datenbank und Tabelle, 2. Daten einfügen, und 3. Durchführen von Abfragen. Verwenden Sie zunächst die Anweisungen für erstellte und creatEtable, um die Datenbank und Tabelle zu erstellen, und verwenden Sie dann die Anweisung InsertInto, um die Daten einzulegen, und verwenden Sie schließlich die Auswahlanweisung, um die Daten abzufragen.

MySQL: Ein anfängerfreundlicher Ansatz zur DatenspeicherungMySQL: Ein anfängerfreundlicher Ansatz zur DatenspeicherungApr 17, 2025 am 12:21 AM

MySQL ist für Anfänger geeignet, da es einfach zu bedienen und leistungsfähig ist. 1.Mysql ist eine relationale Datenbank und verwendet SQL für CRUD -Operationen. 2. Es ist einfach zu installieren und erfordert, dass das Stammbenutzerkennwort konfiguriert wird. 3.. Verwenden Sie Einfügen, Aktualisieren, Löschen und Wählen Sie, um Datenvorgänge auszuführen. 4. OrderBy, wo und Join kann für komplexe Abfragen verwendet werden. 5. Debugging erfordert die Überprüfung der Syntax und verwenden Sie Erklärungen zur Analyse der Abfrage. 6. Die Optimierungsvorschläge umfassen die Verwendung von Indizes, die Auswahl des richtigen Datentyps und der guten Programmiergewohnheiten.

See all articles

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Crossplay haben?
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

PHPStorm Mac-Version

PHPStorm Mac-Version

Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

SAP NetWeaver Server-Adapter für Eclipse

SAP NetWeaver Server-Adapter für Eclipse

Integrieren Sie Eclipse mit dem SAP NetWeaver-Anwendungsserver.

SublimeText3 Englische Version

SublimeText3 Englische Version

Empfohlen: Win-Version, unterstützt Code-Eingabeaufforderungen!

Herunterladen der Mac-Version des Atom-Editors

Herunterladen der Mac-Version des Atom-Editors

Der beliebteste Open-Source-Editor

Dreamweaver Mac

Dreamweaver Mac

Visuelle Webentwicklungstools