Skip to content

Synchroniser une Physical standby database

PhilippeLeroux edited this page May 22, 2017 · 1 revision

Synchroniser une Physical Standby Database via le réseau en 12c

Description des actions.
  • La doc Oracle Rolling Forward a Physical Standby Database Using the RECOVER Command

  • Testé sur

    • 12.2 sur ASM
    • 12.2 sur FS
    • 12.1 sur FS
    • 12.1 sur ASM
  • Le script plescripts/db/stby/rolling_forward_physical.sh automatise l'ensemble des actions.

    Le script db/crash/desynchronize_physical_stby.sh permet de désynchroniser une standby.

  • Création de l'incident

    • Stopper la Standby (plutard)

    • Sur la Primary (plutot)

      • Sur un PDB

         drop table my_objects;
         create table my_objects as select * from dba_objects;
         insert into my_objects select * from my_objects;
         commit;
        
      • Sur le CDB$ROOT

         alter system switch logfile;
         alter system switch logfile;
         alter system switch logfile;
         alter system switch logfile;
         alter system switch logfile;
        

        Et faire un rm -f * dans le répertoire des archivelogs.

    • Démarrer la Standby

  • Sur la standby : préparer les commandes qui vont permettre de mettre à jour les ORLs et SRLs

     select
     	'alter database clear logfile group '||group#||';'
     from
     	( select distinct group# from v$logfile order by group# )
     /
    
     alter database clear logfile group 1;
     alter database clear logfile group 2;
     alter database clear logfile group 3;
     alter database clear logfile group 4;
     alter database clear logfile group 5;
     alter database clear logfile group 6;
     alter database clear logfile group 7;
    
  • Stopper la synchro

     dgmgrl sys/Oracle12
     edit database plutard set state='APPLY-OFF';
    
  • Récupérer le SCN de la Standby (Permet de savoir si des fichiers ont été ajoutées sur la Primary alors que la synchro était HS)

     select current_scn from v$database;
     3,460,007
    
  • Démarrer en nomount la Standby

     SQL> shu immediate
     SQL> startup nomount
    
  • Restaurer le standby controlfile depuis la Primary puis démarrer en mount

     rman target sys/Oracle12
     RMAN> restore standby controlfile from service plutot;
     RMAN> alter database mount;
    
  • Cataloger la FRA

    • Avec un catalog : RECOVER DATABASE NOREDO;
    • Sans catalog (/u03/recovery/ est ma FRA)
       RMAN> catalog start with '/u03/recovery/';
       RMAN> switch database to copy;
      
  • Rafraîchir la Standby

     RMAN> recover database from service plutot  noredo using compressed backupset;
    
  • Tester le SCN pour vérifier si des datafiles ont été ajoutés.

     select
     	file#
     from
     	v$datafile
     where
     	creation_change# >= 3460007	-- SCN lu plus haut.
     ;
    

    Si des datafiles ont été ajoutés, voir la doc section 12.

  • Mise à jour des ORLs et SRLs

    Pour une base en 12.1 sur FS il est nécessaire de renommer les logfiles 'online', la commande clear ne le faisant pas.

     SQL> alter system set standby_file_management='manual';
     SQL> alter database rename file '/u02/database/PLUTOT/redo03.log' to '/u02/database/PLUTARD/redo03.log';                        
     SQL> alter database rename file '/u02/database/PLUTOT/redo02.log' to '/u02/database/PLUTARD/redo02.log';                        
     SQL> alter database rename file '/u02/database/PLUTOT/redo01.log' to '/u02/database/PLUTARD/redo01.log';                        
     SQL> alter system set standby_file_management='auto';
    

    Mise à jour des logfiles :

     SQL> alter database clear logfile group 1;
     SQL> alter database clear logfile group 2;
     SQL> alter database clear logfile group 3;
     SQL> alter database clear logfile group 4;
     SQL> alter database clear logfile group 5;
     SQL> alter database clear logfile group 6;
     SQL> alter database clear logfile group 7;
    
  • Sur la Primary archiver le redolog courant

     SQL> alter system archive log current;
    
  • Sur la Standby : recover redo data et ouvir la base

    J'ai ajouté le flashback, car il n'est plus actif, la doc ne le précise pas :(

    Si la commande recover hang, faire un alter system switch log current; sur la Primary Database.

     RMAN> alter database recover managed standby database until consistent;
     RMAN> alter database flashback on;
     RMAN> alter database open read only;
    
  • On démarre la synchro

     dgmgrl sys/Oracle12
     edit database plutard set state='APPLY-ON';
    
  • Important faire un crosscheck sur la standby.

  • J'ai testé un switchover dans les 2 sens et pas de problème.

Log du script plescripts/db/stby/rolling_forward_physical.sh
# Database version 12.2
# Primary database : plutot

# Physical    : PLUTARD
# Role        : physical
# Current scn : 3421203
# FRA         : +FRA

# ===============================================================================
# Create script to clear all redologs
08h40> sqlplus -s sys/Oracle12 as sysdba<<-EOSQL
08h40> cat /tmp/sql_clear_all_redos.3329

alter database clear logfile group 1;                                                                                   
alter database clear logfile group 2;                                                                                   
alter database clear logfile group 3;                                                                                   
alter database clear logfile group 4;                                                                                   
alter database clear logfile group 5;                                                                                   
alter database clear logfile group 6;                                                                                   
alter database clear logfile group 7;                                                                                   
exit

# ===============================================================================
# PLUTARD : stop redo apply
08h40> dgmgrl -silent -echo sys/Oracle12 "edit database PLUTARD set state=APPLY-OFF"
Connected to "PLUTARD"
edit database PLUTARD set state=APPLY-OFF

# ===============================================================================
# Start PLUTARD to nomount
08h40> sqlplus -s sys/Oracle12 as sysdba

SQL> shutdown immediate
Base de donnees fermee.
Base de donnees demontee.
Instance ORACLE arretee.

SQL> startup nomount
Instance ORACLE lancee.

Total System Global Area  692,060,160 bytes                                                                             
Fixed Size                  8,796,624 bytes                                                                             
Variable Size             314,574,384 bytes                                                                             
Database Buffers          360,710,144 bytes                                                                             
Redo Buffers                7,979,008 bytes                                                                             

# ===============================================================================
# Restore controlfile and start database to mount state.
# Create rman script
08h41> cat /tmp/rman_restore_ctl.3329
restore standby controlfile from service plutot;
alter database mount;

# Execute rman script
08h41> rman target sys/Oracle12 @/tmp/rman_restore_ctl.3329

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 28 08:41:14 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PLUTOT (not mounted)

RMAN> restore standby controlfile from service plutot;
2> alter database mount;
3> 
Starting restore at 28-APR-2017 08:41:14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=258 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service plutot
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:06
output file name=+DATA/PLUTARD/CONTROLFILE/current.257.942331845
output file name=+FRA/PLUTARD/CONTROLFILE/current.256.942331845
Finished restore at 28-APR-2017 08:41:23

Statement processed
released channel: ORA_DISK_1

Recovery Manager complete.

# ===============================================================================
# Catalog +FRA & switch database to copy
# Create script
08h41> cat /tmp/rman_catalog_switch.3329
catalog start with '+FRA/';
switch database to copy;

# Execute script
08h41> rman target sys/Oracle12 @/tmp/rman_catalog_switch.3329

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 28 08:41:29 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PLUTOT (DBID=2935203947, not open)

RMAN> catalog start with '+FRA/';
2> switch database to copy;
3> 
Starting implicit crosscheck backup at 28-APR-2017 08:41:31
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=264 device type=DISK
Crosschecked 39 objects
Finished implicit crosscheck backup at 28-APR-2017 08:41:34

Starting implicit crosscheck copy at 28-APR-2017 08:41:34
using channel ORA_DISK_1
Crosschecked 16 objects
Finished implicit crosscheck copy at 28-APR-2017 08:41:35

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: +FRA/PLUTARD/BACKUPSET/2017_04_27/nnndn1_incr_for_img_copy_0.313.942437729
File Name: +FRA/PLUTARD/BACKUPSET/2017_04_27/annnf0_backup_archlog_0.304.942437797
File Name: +FRA/PLUTARD/BACKUPSET/2017_04_27/nnndn1_incr_for_img_copy_0.312.942438669
File Name: +FRA/PLUTARD/BACKUPSET/2017_04_27/annnf0_backup_archlog_0.263.942438749
File Name: +FRA/PLUTARD/BACKUPSET/2017_04_26/annnf0_backup_archlog_0.281.942343211
File Name: +FRA/PLUTARD/ARCHIVELOG/2017_04_27/thread_1_seq_119.329.942439267
File Name: +FRA/PLUTARD/ARCHIVELOG/2017_04_28/thread_1_seq_120.330.942481643
File Name: +FRA/PLUTARD/ARCHIVELOG/2017_04_28/thread_1_seq_121.331.942481649
File Name: +FRA/PLUTARD/ARCHIVELOG/2017_04_28/thread_1_seq_127.275.942482273
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_27/s_942437517.262.942437781
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_27/s_942437656.267.942437801
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_27/s_942438421.274.942438723
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_27/s_942438470.268.942438753
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_26/s_942342400.269.942343195
File Name: +FRA/PLUTARD/AUTOBACKUP/2017_04_26/s_942342728.276.942343213
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/sysaux.300.942343119
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/system.265.942343151
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/undotbs1.280.942343165
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/sysaux.311.942336635
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/system.289.942336675
File Name: +FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/undotbs1.285.942336691
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/BACKUPSET/2017_04_27/nnndn1_incr_for_img_copy_0.264.942437765
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/BACKUPSET/2017_04_27/nnndn1_incr_for_img_copy_0.310.942438705
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/sysaux.302.942332379
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/system.272.942332455
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/undotbs1.308.942332479
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/sysaux.298.942343095
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/system.282.942343135
File Name: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/undotbs1.292.942343173
File Name: +FRA/PLUTARD/DATAFILE/system.301.942332307
File Name: +FRA/PLUTARD/DATAFILE/sysaux.294.942332343
File Name: +FRA/PLUTARD/DATAFILE/undotbs1.307.942332491
File Name: +FRA/PLUTARD/DATAFILE/users.279.942332501
File Name: +FRA/PLUTARD/DATAFILE/system.305.942343025
File Name: +FRA/PLUTARD/DATAFILE/sysaux.322.942343069
File Name: +FRA/PLUTARD/DATAFILE/undotbs1.291.942343187
File Name: +FRA/PLUTARD/DATAFILE/users.287.942343191

searching for all files that match the pattern +FRA/

List of Files Unknown to the Database
=====================================
File Name: +FRA/PLUTARD/dr2db_plutot.dat
File Name: +FRA/PLUTARD/ONLINELOG/group_1.261.942331987
File Name: +FRA/PLUTARD/ONLINELOG/group_2.260.942331989
File Name: +FRA/PLUTARD/ONLINELOG/group_3.259.942331995
File Name: +FRA/PLUTARD/ONLINELOG/group_4.286.942331997
File Name: +FRA/PLUTARD/ONLINELOG/group_5.277.942331999
File Name: +FRA/PLUTARD/ONLINELOG/group_6.273.942332001
File Name: +FRA/PLUTARD/ONLINELOG/group_7.278.942332003
File Name: +FRA/PLUTARD/ONLINELOG/group_1.293.942333423
File Name: +FRA/PLUTARD/ONLINELOG/group_2.271.942333425
File Name: +FRA/PLUTARD/ONLINELOG/group_3.299.942333427
File Name: +FRA/PLUTARD/ONLINELOG/group_4.296.942333429
File Name: +FRA/PLUTARD/ONLINELOG/group_5.288.942333431
File Name: +FRA/PLUTARD/ONLINELOG/group_6.297.942333433
File Name: +FRA/PLUTARD/ONLINELOG/group_7.295.942333437
File Name: +FRA/PLUTARD/ONLINELOG/group_1.303.942340817
File Name: +FRA/PLUTARD/ONLINELOG/group_2.316.942340819
File Name: +FRA/PLUTARD/ONLINELOG/group_3.283.942340823
File Name: +FRA/PLUTARD/ONLINELOG/group_4.266.942340827
File Name: +FRA/PLUTARD/ONLINELOG/group_5.317.942340831
File Name: +FRA/PLUTARD/ONLINELOG/group_6.318.942340835
File Name: +FRA/PLUTARD/ONLINELOG/group_7.319.942340841
File Name: +FRA/PLUTARD/ONLINELOG/group_1.321.942342551
File Name: +FRA/PLUTARD/ONLINELOG/group_2.320.942342555
File Name: +FRA/PLUTARD/ONLINELOG/group_3.306.942342557
File Name: +FRA/PLUTARD/ONLINELOG/group_4.284.942342559
File Name: +FRA/PLUTARD/ONLINELOG/group_5.314.942342561
File Name: +FRA/PLUTARD/ONLINELOG/group_6.309.942342569
File Name: +FRA/PLUTARD/ONLINELOG/group_7.270.942342573
File Name: +FRA/PLUTARD/ONLINELOG/group_1.290.942438439
File Name: +FRA/PLUTARD/ONLINELOG/group_2.323.942438443
File Name: +FRA/PLUTARD/ONLINELOG/group_3.324.942438449
File Name: +FRA/PLUTARD/ONLINELOG/group_4.325.942438453
File Name: +FRA/PLUTARD/ONLINELOG/group_5.326.942438457
File Name: +FRA/PLUTARD/ONLINELOG/group_6.327.942438461
File Name: +FRA/PLUTARD/ONLINELOG/group_7.328.942438467
File Name: +FRA/PLUTARD/ONLINELOG/group_1.332.942439325
File Name: +FRA/PLUTARD/ONLINELOG/group_2.333.942439331
File Name: +FRA/PLUTARD/ONLINELOG/group_3.334.942439335
File Name: +FRA/PLUTARD/ONLINELOG/group_4.335.942439341
File Name: +FRA/PLUTARD/ONLINELOG/group_5.336.942439345
File Name: +FRA/PLUTARD/ONLINELOG/group_6.337.942439347
File Name: +FRA/PLUTARD/ONLINELOG/group_7.338.942439351
File Name: +FRA/PLUTARD/CONTROLFILE/current.258.942331843
File Name: +FRA/PLUTARD/CONTROLFILE/current.257.942331843
cataloging files...
no files cataloged

List of Files Which Were Not Cataloged
=======================================
File Name: +FRA/PLUTARD/dr2db_plutot.dat
  RMAN-07518: Reason: Foreign database file DBID: 0  Database Name: 
File Name: +FRA/PLUTARD/ONLINELOG/group_1.261.942331987
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.260.942331989
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.259.942331995
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.286.942331997
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.277.942331999
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.273.942332001
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.278.942332003
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_1.293.942333423
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.271.942333425
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.299.942333427
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.296.942333429
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.288.942333431
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.297.942333433
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.295.942333437
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_1.303.942340817
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.316.942340819
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.283.942340823
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.266.942340827
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.317.942340831
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.318.942340835
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.319.942340841
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_1.321.942342551
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.320.942342555
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.306.942342557
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.284.942342559
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.314.942342561
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.309.942342569
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.270.942342573
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_1.290.942438439
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.323.942438443
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.324.942438449
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.325.942438453
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.326.942438457
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.327.942438461
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.328.942438467
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_1.332.942439325
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_2.333.942439331
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_3.334.942439335
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_4.335.942439341
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_5.336.942439345
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_6.337.942439347
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/ONLINELOG/group_7.338.942439351
  RMAN-07529: Reason: catalog is not supported for this file type
File Name: +FRA/PLUTARD/CONTROLFILE/current.258.942331843
  RMAN-07517: Reason: The file header is corrupted
File Name: +FRA/PLUTARD/CONTROLFILE/current.257.942331843
  RMAN-07517: Reason: The file header is corrupted

datafile 1 switched to datafile copy "+FRA/PLUTARD/DATAFILE/system.301.942332307"
datafile 3 switched to datafile copy "+FRA/PLUTARD/DATAFILE/sysaux.294.942332343"
datafile 4 switched to datafile copy "+FRA/PLUTARD/DATAFILE/undotbs1.307.942332491"
datafile 5 switched to datafile copy "+FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/system.265.942343151"
datafile 6 switched to datafile copy "+FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/sysaux.300.942343119"
datafile 7 switched to datafile copy "+FRA/PLUTARD/DATAFILE/users.279.942332501"
datafile 8 switched to datafile copy "+FRA/PLUTARD/4D22A06371FA606CE0536BF0FAC0DEFA/DATAFILE/undotbs1.285.942336691"
datafile 36 switched to datafile copy "+FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/system.272.942332455"
datafile 37 switched to datafile copy "+FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/sysaux.302.942332379"
datafile 38 switched to datafile copy "+FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/undotbs1.308.942332479"

Recovery Manager complete.

# ===============================================================================
# Recover database PLUTARD from plutot
# Create script
08h41> echo 'recover database from service plutot noredo using compressed backupset;'>/tmp/rman_refresh_stby.3329

# Execute script
08h42> rman target sys/Oracle12 @/tmp/rman_refresh_stby.3329

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 28 08:42:00 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PLUTOT (DBID=2935203947, not open)

RMAN> recover database from service plutot noredo using compressed backupset;
2> 
Starting recover at 28-APR-2017 08:42:01
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
skipping datafile 5; already restored to SCN 1440789
skipping datafile 6; already restored to SCN 1440789
skipping datafile 8; already restored to SCN 1440789
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00001: +FRA/PLUTARD/DATAFILE/system.301.942332307
channel ORA_DISK_1: restore complete, elapsed time: 00:00:17
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00003: +FRA/PLUTARD/DATAFILE/sysaux.294.942332343
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00004: +FRA/PLUTARD/DATAFILE/undotbs1.307.942332491
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00007: +FRA/PLUTARD/DATAFILE/users.279.942332501
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00036: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/system.272.942332455
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00037: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/sysaux.302.942332379
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service plutot
destination for restore of datafile 00038: +FRA/PLUTARD/4E1231F70B35486FE0536BF0FAC0AD58/DATAFILE/undotbs1.308.942332479
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07

Finished recover at 28-APR-2017 08:43:08

Recovery Manager complete.
08h43< rman running time : 1mn08s

# ===============================================================================
# Pas de datafiles ajoutés sur la standby [ok]

# Attente VM/Desktop : 10/10s
# ===============================================================================
# Clearing all redos.
# Execute script /tmp/sql_clear_all_redos.3329
08h43> sqlplus -s sys/Oracle12 as sysdba @/tmp/sql_clear_all_redos.3329

Base de donnees modifiee.


Base de donnees modifiee.


Base de donnees modifiee.


Base de donnees modifiee.


Base de donnees modifiee.


Base de donnees modifiee.


Base de donnees modifiee.


# ===============================================================================
# Switch archive log sur la Primary plutot
08h43> sqlplus -s sys/Oracle12@plutot as sysdba

SQL> whenever sqlerror exit 1;

SQL> alter system archive log current;

Systeme modifie.

Ecoule : 00 :00 :00.58

# Attente VM/Desktop : 10/10s
# ===============================================================================
# Recover database
# Create script
08h43> echo 'alter database recover managed standby database until consistent;'>/tmp/recover_stby.3329
# Execute script
08h43> rman target sys/Oracle12 @/tmp/recover_stby.3329

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 28 08:43:56 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PLUTOT (DBID=2935203947, not open)

RMAN> alter database recover managed standby database until consistent;
2> 
using target database control file instead of recovery catalog
Statement processed

Recovery Manager complete.

# Enable flashback & open database RO
08h44> sqlplus -s sys/Oracle12 as sysdba

SQL> alter database flashback on;

Base de donnees modifiee.

Ecoule : 00 :00 :01.87

SQL> alter database open read only;

Base de donnees modifiee.

Ecoule : 00 :00 :23.08

# ===============================================================================
# PLUTARD : start redo apply
08h44> dgmgrl -silent -echo sys/Oracle12 "edit database PLUTARD set state=APPLY-ON"
Connected to "PLUTARD"
edit database PLUTARD set state=APPLY-ON

# ===============================================================================
# Crosscheck FRA
08h44> rman target sys/Oracle12 @$HOME/plescripts/db/rman/crosscheck.rman

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 28 08:44:35 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PLUTOT (DBID=2935203947)

RMAN> crosscheck backup;
2> delete noprompt expired backup;
3> crosscheck copy of database;
4> delete noprompt expired copy of database;
5> delete noprompt archivelog all;
6> 
[ output skipped ]
Recovery Manager complete.

# ===============================================================================
08h45> dgmgrl -silent -echo sys/Oracle12 'show configuration'
Connected to "PLUTARD"
show configuration

Configuration - DGCONF

  Protection Mode: MaxPerformance
  Members:
  plutot  - Primary database
    plutard - Physical standby database 
      Warning: ORA-16854: apply lag could not be determined

Fast-Start Failover: DISABLED

Configuration Status:
WARNING   (status updated 36 seconds ago)

08h45> dgmgrl -silent -echo sys/Oracle12 'show database PLUTARD'
Connected to "PLUTARD"
show database PLUTARD

Database - plutard

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          0 seconds (computed 1 second ago)
  Average Apply Rate: 2.00 KByte/s
  Real Time Query:    ON
  Instance(s):
    PLUTARD

Database Status:
SUCCESS


# script rolling_forward_physical.sh running time : 5mn00s
# Remove temporaries scripts
08h45> rm -rf /tmp/recover_stby.3329 /tmp/rman_catalog_switch.3329 /tmp/rman_refresh_stby.3329 /tmp/rman_restore_ctl.3329 /tmp/sql_clear_all_redos.3329
Clone this wiki locally