Feb 19, 2018

copiar datafile desde base primaria a standby con ASM


Hace poco me encontré con un datafile en una standby que tenia problemas (standby 12c con ASM). En resumen este era el error que se ve en la standby:

Mon Feb 19 18:21:21 2018
Errors in file /oracle/app/oracle/diag/rdbms/sarchive/SARCHIVE1/trace/SARCHIVE1_pr00_12911036.trc:
ORA-00448: normal completion of background process
Mon Feb 19 18:21:21 2018
Errors in file /oracle/app/oracle/diag/rdbms/sarchive/SARCHIVE1/trace/SARCHIVE1_mrp0_4718782.trc:
ORA-00756: recovery detected a lost write of a data block
ORA-10567: Redo is inconsistent with data block (file# 652, block# 3, file offset is unknown bytes)
ORA-10564: tablespace APPS_TS_TX_IDX
ORA-01110: data file 652: '+ARCHIVE/SARCHIVE/DATAFILE/apps_ts_tx_idx.515.968523631'
ORA-10560: block type '0'
Mon Feb 19 18:21:21 2018

Ahora lo primero que se me ocurria era copia el datafile desde la primaria hacia la standby, pero como esta en ASM ambas bases de datos, hay que hacer un par de pasos adicionales. Estos pasos estan comentados en la siguiente nota:

How to Copy ASM datafile From Primary Database to Standby Database on ASM using RMAN (Doc ID 605234.1)


Bueno en resumen lo que hice fue obtener el nombre del archivo en la primary con el numero de datafile que tiene problemas en la standby (numero de datafile 652). Posteriormente usando rman en la primaria ejecute el siguiente comando:

RMAN> copy datafile '+ARCHIVE/ARCHIVE/DATAFILE/apps_ts_tx_idx.1304.968523459'  to '/gg/gg12c/respaldo/backup_file.dbf' ;

Starting backup at 19-FEB-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2 instance=ARCHIVE2 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00652 name=+ARCHIVE/ARCHIVE/DATAFILE/apps_ts_tx_idx.1304.968523459
output file name=/gg/gg12c/respaldo/backup_file.dbf tag=TAG20180219T183516 RECID=5 STAMP=968524773
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:04:25
Finished backup at 19-FEB-18

Aquello me generó el archivo: /gg/gg12c/respaldo/backup_file.dbf el cual debemos copiarlo a la standby:

scp /gg/gg12c/respaldo/backup_file.dbf t423:/gg/gg12c/respaldo/t423:/gg/gg12c/respaldo/             
oracle@t423's password:
backup_file.dbf                                                                  100%   29GB  24.7MB/s   20:16


Ahora nos ubicamos en la base de datos standby y procederemos a catalogar el nuevo archivo de backup:

rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Feb 19 19:37:30 2018

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

connected to target database: ARCHIVE (DBID=4129028332, not open)

RMAN> Catalog datafilecopy '/gg/gg12c/respaldo/backup_file.dbf' ;

using target database control file instead of recovery catalog
cataloged datafile copy
datafile copy file name=/gg/gg12c/respaldo/backup_file.dbf RECID=8 STAMP=968528258


Ahora restauramos el datafile usando ese backup (sobre la standby):
RMAN> copy datafilecopy '/gg/gg12c/respaldo/backup_file.dbf'  to '+ARCHIVE';

Starting backup at 19-FEB-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input is copy of datafile 00652: /gg/gg12c/respaldo/backup_file.dbf

output file name=+ARCHIVE/SARCHIVE/DATAFILE/apps_ts_tx_idx.1308.968528345 tag=TAG20180219T183516 RECID=9 STAMP=968531536
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:53:15
Finished backup at 19-FEB-18


Ahora desde la base de datos standby via sqlplus (cambiaremos el nombre del archivo ocupando el file_name antiguo:

SQL> Alter system set standby_file_management=manual scope=both sid='*' ;

System altered.

SQL> Alter database rename file '+ARCHIVE/SARCHIVE/DATAFILE/apps_ts_tx_idx.515.968523631' to
'+ARCHIVE/SARCHIVE/DATAFILE/apps_ts_tx_idx.1308.968528345' ;  2

Database altered.

SQL> Alter system set standby_file_management=auto scope=both sid='*' ;

System altered.


SQL> alter database recover managed standby database disconnect from session ;

Database altered.


Si por algun motivo se nos olvida poner de nuevo standby_file_management en auto la recuperacion de la standby se nos caera si es que desde la primary se crea un nuevo datafile mientras nosotros estabamos arreglando este problema. En el alert log de la base de datos aparecera que no se puede crear el siguiente archivo con un nombre similar a esto: UNNAMED00653

SI esto llegara a pasar hay que crear el archivo desde 0 usando lo siguiente (en ASM y con OMF activo)
alter database create datafile '/oracle/app/oracle/product/12.1.0/db_1/dbs/UNNAMED00653' as new;

Luego de esto dejar activo nuevamente el parametro:
Alter system set standby_file_management=auto scope=both sid='*' ;

Espero haya servido :)
PD: no olvidar eliminar el archivo original de backup tanto en la primaria como en la standby:

RMAN>  delete datafilecopy '/gg/gg12c/respaldo/backup_file.dbf' ;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2 instance=ARCHIVE2 device type=DISK
List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time
------- ---- - --------------- ---------- ---------------
5       652  A 19-FEB-18       51336108383 19-FEB-18
        Name: /gg/gg12c/respaldo/backup_file.dbf
        Tag: TAG20180219T183516


Do you really want to delete the above objects (enter YES or NO)? y
deleted datafile copy
datafile copy file name=/gg/gg12c/respaldo/backup_file.dbf RECID=5 STAMP=968524773
Deleted 1 objects


RMAN>

No comments:

Post a Comment