Switchover pianificato

Un database Oracle opera in uno dei due ruoli: primario o in standby. Data Guard consente di modificare il ruolo di un database utilizzando uno switchover o un failover:

  • Uno switchover è uno storno di ruolo tra il database primario e uno dei relativi database in standby. Uno switchover non garantisce alcuna perdita di dati ed è in genere fatto per la manutenzione pianificata del sistema primario. Durante uno switchover, le transizioni del database primario a un ruolo in standby e le transizioni del database in standby al ruolo primario.
  • Viene eseguito un failover quando il database primario (tutte le istanze di un database primario Oracle RAC) non riesce o è diventato irraggiungibile e uno dei database in standby viene transitato per assumere il ruolo primario. Failover può o non può causare perdita di dati a seconda della modalità di protezione in vigore al momento del failover.

Cambia database primario da locale a OCI

Quando si dispone di un'attività pianificata, ad esempio la manutenzione, è possibile rendere il database in Oracle Cloud Infrastructure (OCI) il database primario senza perdita di dati. Uno switchover è un evento pianificato avviato sul database in locale e completato sull'istanza di database nel cloud.

  1. Eseguire il login a una sessione DGMGRL nel database in locale con nome utente e password sys.
    DGMRGL> connect
  2. Nel database in locale, verificare che il database in standby sia pronto per lo switchover e il failover.
    In questo esempio, il database primario è db1 e il database in standby (StandbyDatabaseOCIInstance) è DB1_phx3g7.
    DGMGRL> validate database DB1_phx3g7
    L'output sarà simile a quanto segue:
    Database Role:     Physical standby database
      Primary Database:  db1
    
      Ready for Switchover:  Yes
      Ready for Failover:    Yes (Primary Running)
    
      Managed by Clusterware:
        db1       :  YES             
        db1_phx3g7:  YES   
              
    Standby Apply-Related Information:
        Apply State:      Running
        Apply Lag:        17 minutes 6 seconds (computed 42 seconds ago)
        Apply Delay:      0 minutes
      Current Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1)                   (db1_phx3g7)                         
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1_phx3g7
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1_phx3g7
      Future Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1_phx3g7)            (db1)                                
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1
  3. Convalidare il database primario.
    DGMGRL> validate database 'DB1';
    L'output sarà simile a quanto segue:
    Database Role:    Primary database
      Ready for Switchover:  Yes
      Managed by Clusterware:
        db1:  YES    
  4. Convalidare il database in standby.
    DGMGRL> validate database 'DB1_phx3g7';
    L'output sarà simile a quanto segue:
    
    Database Role:     Physical standby database  
    Primary Database:  db1  
    Ready for Switchover:  Yes  
    Ready for Failover:    Yes (Primary Running)  
    Managed by Clusterware:
        db1       :  YES                
        db1_phx3g7:  YES              
    Standby Apply-Related Information:
        Apply State:      Running
        Apply Lag:        32 minutes 12 seconds (computed 40 seconds ago)
        Apply Delay:      0 minutes  
    Current Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
                  (db1)                   (db1_phx3g7)
         1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1_phx3g7
        2         2                       0                       Insufficient SRLs     
        Warning: standby redo logs not configured for thread 2 on db1_phx3g7
    
    Future Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1_phx3g7)            (db1)                                
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1
  5. Nel database in locale (primario), eseguire il comando per passare al database in standby.
    DGMGRL> switchover to db1_phx3g7;
    L'output sarà simile a quanto segue:
    Performing switchover NOW, please wait...
    Operation requires a connection to database "db1_phx3g7"
    Connecting ...
    Connected to "DB1_phx3g7"
    Connected as SYSDBA.
    New primary database "db1_phx3g7" is opening...
    Oracle Clusterware is restarting database "db1" ...
    Connected to "db1"
    Connected to "db1"
    Switchover succeeded, new primary is "db1_phx3g7"
  6. Nel database in locale, visualizzare lo stato di configurazione.
    DGMGRL> show configuration
    L'output sarà simile a quanto segue:
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
      db1_phx3g7 - Primary database
          db1        - Physical standby database 
    
    Warning: ORA-16809: multiple warnings detected for the memberFast-Start
            Failover:  Disabled
    Configuration Status:
    WARNING   (status updated 35 seconds ago)
  7. Nella Oracle Exadata Database Machine locale principale selezionare la modalità di apertura.
    SQL> select open_mode from v$database;
    L'output sarà simile a quanto segue:
    OPEN_MODE
    -------------------- 
    MOUNTED
  8. Nel database Oracle Database Exadata Cloud Service nel cloud confermare che il database è READ WRITE.
    SQL> select open_mode from v$database;
    L'output sarà simile a quanto segue:
    OPEN_MODE
    -------------------- 
    READ WRITE
Il database su Oracle Database Exadata Cloud Service nel cloud è il database primario.

Cambia il database primario da OCI a On-Premises

Dopo aver reso l'istanza di database in Oracle Cloud Infrastructure (OCI) il database primario, utilizzare l'interfaccia della riga di comando Oracle Data Guard (DGMGRL) sull'istanza di database OCI inOracle Database Exadata Cloud Service per tornare indietro e rendere di nuovo il database primario in locale.

  1. Passaggio dall'istanza di database in OCI al database in locale.
    DGMGRL> switchover to db1;
    L'output sarà simile a quanto riportato di seguito.
    Performing switchover NOW, please wait...
    Operation requires a connection to database "db1"
    New primary database "db1" is opening...
    Oracle Clusterware is restarting database "db1_phx3g7" ...
    Connected to "DB1_phx3g7"
    Connected to "DB1_phx3g7"
    Switchover succeeded, new primary is "db1"
  2. In Oracle Exadata Database Machine in locale, connettersi e rivedere la configurazione.
    DGMGRL> show configuration;
    L'output sarà simile a quanto riportato di seguito.
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
      db1        - Primary database
      Warning: ORA-16809: multiple warnings detected for the member
        db1_phx3g7 - Physical standby database 
          Error: ORA-12650: No common encryption or data integrity algorithm
    Fast-Start Failover:  Disabled
    Configuration Status:
    ERROR   (status updated 899 seconds ago)
  3. Nel database Oracle Database Exadata Cloud Service nel cloud, creare una tabella di ripristino dei disastri di test.
    SQL> create table testdr (a number , b number);
    Table created.
    SQL> desc testdr;
     Name                                        Null?    Type
     ----------------------------------------- -------- ----------------------------
     A                                          NUMBER
     B                                          NUMBER
  4. Esci da SQL.
    SQL> exit
  5. In Oracle Exadata Database Machine primario in locale, eseguire il login come sysdba e visualizzare la tabella testdr.
    $ sqlplus / as sysdba
    SQL> desc testdr;
    
     Name                                        Null?    Type
     ----------------------------------------- -------- ----------------------------
     A                                          NUMBER
     B                                          NUMBER
  6. In Oracle Exadata Database Machine primario in locale, visualizzare e rivedere la configurazione.
    DGMGRL> show configuration;
    L'output sarà simile a quanto riportato di seguito.
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
    db1        - Primary database
        db1_phx3g7 - Physical standby database 
          Warning: ORA-16809: multiple warnings detected for the member
    Fast-Start Failover:  Disabled
    Configuration Status:
    WARNING   (status updated 36 seconds ago)

È possibile cambiare il database primario avanti e indietro tra il database in locale e l'istanza di database OCI (Oracle Database Exadata Cloud Service).