Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Convalida il deployment di Data Guard
Dopo aver configurato il broker Data Guard,
devi verificare che il riassorbimento sia stato copiato dal database principale e applicato al
database di standby. La procedura riportata di seguito può essere utilizzata per controllare lo stato di Data Guard dai database principali e di standby.
I seguenti esempi vengono utilizzati in tutta la guida:
Nome univoco del database
Nomi host del server
Nomi delle istanze RAC
Ruolo
DBDG_SITE1
site1db1, site1db2
DBDG_SITE11, DBDG_SITE12
Principale
DBDG_SITE2
site2db1, site2db2
DBDG_SITE21, DBDG_SITE22
Standby
Convalida il deployment di Data Guard
Accedi al primo server Bare Metal Solution che ospita il database principale, quindi imposta la variabile di ambiente ORACLE_SID in modo da poterti connettere al database principale:
sourceoraenv <<< "DBDG_SITE11"
Avvia SQL*Plus, quindi determina l'ultimo numero di sequenza per i log di redo archiviati:
Registra i risultati da confrontare con il database di riserva. I numeri di sequenza sul database di standby dovrebbero corrispondere a quelli del database principale.
Accedi al primo server Bare Metal Solution che ospita il database di riserva, quindi imposta la variabile di ambiente ORACLE_SID in modo da poterti connettere al database di riserva:
sourceoraenv <<< "DBDG_SITE21"
Avvia SQL*Plus, quindi verifica che l'ultimo numero di sequenza ricevuto e applicato per i log di reimpostazione archiviati corrisponda all'ultimo numero di sequenza nel database principale:
L'output seguente non mostra alcun ritardo nel database di standby:
NAME VALUE
-------------------- ------------------------------
transport lag +00 00:00:00
apply lag +00 00:00:00
In caso di ritardo, consulta la documentazione per la risoluzione dei problemi di Data Guard di Oracle.
Passaggio di un database utilizzando il broker Data Guard
Uno switchover è un'inversione di ruolo in cui il database principale diventa un database di standby e viceversa. Durante la procedura di passaggio, i client di database vengono disconnessi dal database principale. A seconda di come l'applicazione si connette al database, il passaggio può interrompere il traffico dell'applicazione. Oracle offre opzioni per mantenere la continuità dell'applicazione durante le transizioni dei ruoli. Puoi verificare la tua idoneità al ripristino di emergenza eseguendo un passaggio al database seguendo le istruzioni riportate di seguito:
Accedi al server Bare Metal Solution che ospita il database principale.
Avvia l'interfaccia a riga di comando di Data Guard e connettiti al database di standby:
dgmgrl
CONNECTSYS@DBDG_SITE2
Quando ti viene richiesta una password, inserisci la password di accesso remoto SYS per il database.
Verifica che il database sia pronto per il passaggio.
VALIDATE DATABASE DBDG_SITE2;
Un risultato positivo indica che il database è pronto per il passaggio.
Se l'operazione ha esito positivo, esegui il comando di passaggio:
SWITCHOVER TO DBDG_SITE2;
Se il comando va a buon fine, riceverai un messaggio che indica che DBDG_SITE2
è il nuovo database principale nella configurazione.
Esegui il seguente comando per verificare che i ruoli del database siano scambiati:
SHOW CONFIGURATION;
Esegui il seguente comando per tornare alla configurazione originale:
SWITCHOVER TO DBDG_SITE1;
Failover del database utilizzando il broker Data Guard
Un failover è una transizione di ruolo in cui uno dei database di standby passa al ruolo principale a causa di un'interruzione completa del sito. L'operazione di ripristino non verrà inviata al database standby finché questo non sarà stato reintegrato.
Esegui il failover
Accedi al primo server Bare Metal Solution che ospita il database di standby.
Connettiti all'interfaccia a riga di comando di Data Guard, quindi esegui il failover del database primario al database di standby:
dgmgrl
CONNECTSYS@DBDG_SITE2
Quando ti viene richiesta una password, inserisci la password di accesso remoto SYS per il database.
Avvia il failover:
FAILOVER TO DBDG_SITE2
Esegui show configuration; per verificare che DBDG_SITE2
ora sia il database principale e che DBDG_SITE1
debba essere reintegrato.
Reintegra il database principale
Puoi reintegrare il database principale dopo un failover solo se è attivata l'opzione
flashback database. Per reintegrare il database principale non riuscito:
Accedi al primo server Bare Metal Solution che ospita il database principale.
Connettiti all'interfaccia a riga di comando di Data Guard, accedi ai database principali e reintegra il database con errore:
dgmgrl
CONNECTSYS@DBDG_SITE2
Quando ti viene richiesta una password, inserisci la password di accesso remoto SYS per il database.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis document provides instructions on how to validate a Data Guard deployment by checking redo log sequence numbers and process status between primary and standby databases.\u003c/p\u003e\n"],["\u003cp\u003eThe process for performing a database switchover, which reverses the roles of the primary and standby databases, is detailed, including steps to validate and execute the switchover.\u003c/p\u003e\n"],["\u003cp\u003eSteps to perform a database failover, where a standby database becomes the new primary due to a site outage, are outlined, as well as a warning about potential data loss during this process.\u003c/p\u003e\n"],["\u003cp\u003eThe document explains how to reinstate a failed primary database after a failover, requiring that the flashback database feature is enabled.\u003c/p\u003e\n"]]],[],null,["# Validate the Data Guard deployment\n==================================\n\nAfter you've [set up the Data Guard broker](/bare-metal/docs/solutions/oracle/data-guard-setup/broker),\nyou need to verify that redo was copied from the primary database and applied on\nthe standby database. The following procedure can be used to check the Data\nGuard status from within the primary and standby databases.\n\nThe following examples are used throughout this guide:\n\nValidate the Data Guard deployment\n----------------------------------\n\n1. Log in to the first Bare Metal Solution server that hosts the primary database,\n then set the `ORACLE_SID` environment variable so you can connect to the\n primary database:\n\n source oraenv \u003c\u003c\u003c \"\u003cvar translate=\"no\"\u003eDBDG_SITE11\u003c/var\u003e\"\n\n2. Start SQL\\*Plus, then determine the latest sequence number for archived redo\n logs:\n\n sqlplus / as sysdba\n\n SELECT THREAD#, max(SEQUENCE#) \"Last Primary Seq Archived\"\n FROM V$ARCHIVED_LOG VAL, V$DATABASE VDB WHERE VAL.RESETLOGS_CHANGE# =\n VDB.RESETLOGS_CHANGE# GROUP BY THREAD# ORDER BY 1;\n\n The following output has maximum sequence number of 40 for thread 1 and a\n maximum sequence number of 33 for thread 2: \n\n THREAD# Last Primary Seq Archived\n ---------- -------------------------\n 1 40\n 2 33\n\n Record the results to compare with the standby database. Sequence numbers on\n the standby database are expected to match the primary database.\n3. Log in to the first Bare Metal Solution server that hosts the standby database, then\n set the `ORACLE_SID` environment variable so you can connect to the standby\n database:\n\n source oraenv \u003c\u003c\u003c \"\u003cvar translate=\"no\"\u003eDBDG_SITE21\u003c/var\u003e\"\n\n4. Start SQL\\*Plus, then validate that the latest sequence number received and\n applied for archived redo logs matches the latest sequence number on the\n primary database:\n\n sqlplus / as sysdba\n\n SELECT THREAD#, max(SEQUENCE#) \"Last Standby Seq Received\"\n FROM V$ARCHIVED_LOG VAL, V$DATABASE VDB WHERE VAL.RESETLOGS_CHANGE# =\n VDB.RESETLOGS_CHANGE# GROUP BY THREAD# ORDER BY 1;\n\n SELECT THREAD#, max(SEQUENCE#) \"Last Standby Seq Applied\"\n FROM V$ARCHIVED_LOG VAL, V$DATABASE VDB WHERE VAL.RESETLOGS_CHANGE# =\n VDB.RESETLOGS_CHANGE# AND VAL.APPLIED IN ('YES','IN-MEMORY') GROUP BY\n THREAD# ORDER BY 1;\n\n The following output has sequence numbers that match the prior query run\n against the standby database: \n\n THREAD# Last Standby Seq Received\n ---------- -------------------------\n 1 40\n 2 33\n\n THREAD# Last Standby Seq Applied\n ---------- ------------------------\n 1 40\n 2 33\n\n5. Check that the status of the managed recovery process is `APPLYING_LOG`:\n\n SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY WHERE PROCESS LIKE '%MRP%';\n\n The following example shows a single managed recovery process named `MRP0`\n with status of `APPLYING_LOG`: \n\n PROCESS STATUS\n --------- ------------\n MRP0 APPLYING_LOG\n\n6. Check for any transport or apply lag on the standby database:\n\n COLUMN NAME FORMAT a20\n COLUMN VALUE FORMAT a30\n SELECT NAME, VALUE FROM V$DATAGUARD_STATS WHERE NAME LIKE '%lag%';\n\n The following output shows no lag on the standby database: \n\n NAME VALUE\n -------------------- ------------------------------\n transport lag +00 00:00:00\n apply lag +00 00:00:00\n\n If there is lag, consult Oracle's Data Guard troubleshooting [documentation](https://docs.oracle.com/en/database/oracle/oracle-database/19/haovw/tune-and-troubleshoot-oracle-data-guard.html#GUID-E8C27979-9D37-4899-9306-A5AE2B5CF6C0).\n\nDatabase switchover using the Data Guard broker\n-----------------------------------------------\n\nA switchover is a role reversal in which the primary database becomes a standby\ndatabase, and vice versa. During the switchover process, database clients are\ndisconnected from the primary database. Depending on how your application\nconnects to the database, a switchover can disrupt application traffic. Oracle\noffers [options to maintain application continuity](https://docs.oracle.com/en/database/oracle/oracle-database/19/racad/ensuring-application-continuity.html)\nduring role transitions. You can test your disaster recovery readiness by\nperforming a database switchover with the following instructions:\n\n1. Log in to the Bare Metal Solution server that hosts the primary database.\n\n2. Launch the Data Guard command line interface, and connect to the standby\n database:\n\n dgmgrl\n\n CONNECT SYS@\u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n\n3. When prompted for a password, enter your SYS remote login password for the\n database.\n\n4. Validate that the database is ready for a switchover.\n\n VALIDATE DATABASE \u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e;\n\n A successful result will report that the database is ready for switchover.\n5. If successful, perform the switchover command:\n\n SWITCHOVER TO \u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e;\n\n If the command succeeds, you'll receive a message that \u003cvar scope=\"DBDG_SITE2\" translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n is the new primary database in the configuration.\n6. Run the following command to confirm that the database roles are swapped:\n\n SHOW CONFIGURATION;\n\n7. Run the following command to return to the original configuration:\n\n SWITCHOVER TO \u003cvar translate=\"no\"\u003eDBDG_SITE1\u003c/var\u003e;\n\n| **Note:** Running the switchover command while connected to the primary database might result in the connection being dropped. This is due to the primary database being restarted during the switchover process.\n\nDatabase failover using Data Guard broker\n-----------------------------------------\n\nA failover is a role transition in which one of the standby databases moves to\nthe primary role due to a complete site outage. Redo will not be shipped to the\nstandby database until the standby database has been reinstated.\n| **Warning:** A failover typically involves data loss.\n\n### Perform the failover\n\n1. Log in to the first Bare Metal Solution server that hosts the standby database.\n\n2. Connect to the Data Guard command line interface, then failover the primary\n to the standby database:\n\n dgmgrl\n\n CONNECT SYS@\u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n\n3. When prompted for a password, enter your SYS remote login password for the\n database.\n\n4. Initiate the failover:\n\n FAILOVER TO \u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n\n Run `show configuration;` to verify that \u003cvar scope=\"DBDG_SITE2\" translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n is now the primary database, and \u003cvar scope=\"DBDG_SITE1\" translate=\"no\"\u003eDBDG_SITE1\u003c/var\u003e\n needs to be reinstated.\n\n### Reinstate the primary database\n\nYou can only reinstate the primary database after a failover if\n[`flashback database`](https://docs.oracle.com/en/database/oracle/oracle-database/19/sbydb/examples-of-using-oracle-data-guard.html#GUID-1163448F-6B18-4A44-AA8D-7CDF0D1360FB)\nis enabled. To reinstate the failed primary database:\n\n1. Log in to the first Bare Metal Solution server that hosts the primary database.\n\n2. Connect to the Data Guard command line interface, log in to the primary\n databases, then reinstate the failed database:\n\n dgmgrl\n\n CONNECT SYS@\u003cvar translate=\"no\"\u003eDBDG_SITE2\u003c/var\u003e\n\n When prompted for a password, enter your SYS remote login password for the\n database.\n3. Reinstate the database:\n\n REINSTATE DATABASE \u003cvar translate=\"no\"\u003eDBDG_SITE1\u003c/var\u003e;\n EXIT;\n\nNext steps\n----------\n\nNext, [set up a Data Guard observer on Compute Engine](/bare-metal/docs/solutions/oracle/data-guard-setup/observer)."]]