MERCADOS FINANCIEROS

viernes, 17 de septiembre de 2021

Restaurando archivelogs

 

Restaurando archivelogs

Hoy vamos a volver a las entradas para dummies .
En esta entrada vamos a ver en una entrada muy rapida algunas maneras de restaurar archivelogs.

Desde numero de secuencia

RUN
{
SET ARCHIVELOG DESTINATION TO '/ruta';
restore archivelog  logseq=8702;
}

Podemos hacerlo tambien con un rango con

restore archivelog from sequence 8619 until sequence 8702;

o tambien con

restore archivelog sequence between 8619 and  8702;

De un dia atras

Esta puede ser muy comoda a la hora de incrementales

RUN
{ 
SET ARCHIVELOG DESTINATION TO '/ruta';
ALLOCATE CHANNEL d1 DEVICE TYPE disk;
 restore ARCHIVELOG FROM TIME 'SYSDATE-1' UNTIL TIME 'SYSDATE';
}

Tambien podriamos indicarlo

restore ARCHIVELOG FROM TIME "to_date('11/04/20 00:00:01','DD/MM/YY HH24:MI:SS')
UNTIL TIME 'SYSDATE';

En RAC

En un rac es igual que en los anteriores, pero deberemos de indicar el numero de thread que nos corresponde

{
SET ARCHIVELOG DESTINATION TO '/ruta'
restore archivelog from logseq=8619 until logseq=8702 thread=2;
}

Specifying Records by SCN: Example This example restores backup archived redo log files from tape that fall within a range of SCNs:

RESTORE ARCHIVELOG SCN BETWEEN 94097 AND 106245;
RMAN> run {
2> ALLOCATE CHANNEL ch1 DEVICE TYPE DISK FORMAT = 'D:\dbawork\na38551\MKS01P_ARCH\';
3> RESTORE ARCHIVELOG FROM SEQUENCE 128458 UNTIL SEQUENCE 128510;
4> RELEASE CHANNEL ch1;
5> }

RMAN DUPLICATE ERROR ORA-19838 RMAN-06054: media recovery requesting unknown archived log

RMAN DUPLICATE ORA-19838 RMAN-06054 || ORA-19838: Cannot use this control file to open database || RMAN-06054: media recovery requesting unknown archived log
******************************************************************************************
RMAN DUPLICATE ORA-19838 RMAN-06054

****  Rman Script
connect catalog '/@';
connect auxiliary / ;

run {
allocate auxiliary channel t1_db device type sbt parms="ENV=(NB_ORA_SERV=, NB_ORA_CLIENT=)";
allocate auxiliary channel t2_db device type sbt parms="ENV=(NB_ORA_SERV=, NB_ORA_CLIENT=)";
allocate auxiliary channel t3_db device type sbt parms="ENV=(NB_ORA_SERV=, NB_ORA_CLIENT=)";
allocate auxiliary channel t4_db device type sbt parms="ENV=(NB_ORA_SERV=, NB_ORA_CLIENT=)";

duplicate database to ;
release channel t1_db;
release channel t2_db;
release channel t3_db;
release channel t4_db;
}
******************************************************************************************


Failed Database Duplication, recovery manager duplication was started after "open resetlogs" on source database and the last full backup was done with previous incarnation.
This is RMAN log file ->

archived log file name=/oradb1/archivelog//_285521_695915219.arc RECID=285737 STAMP=823973951
archived log file name=/oradb1/archivelog//_285522_695915219.arc thread=1 sequence=285522
channel clone_default: deleting archived log(s)
archived log file name=/oradb1/archivelog//_285522_695915219.arc RECID=285731 STAMP=823973836
unable to find archived log
archived log thread=1 sequence=285523
released channel: t1_db
released channel: t2_db
released channel: t3_db
released channel: t4_db
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/20/2013 17:39:30
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 285523 and starting SCN of 15614356785656

Recovery Manager complete.

******************************************************************************************
*** After Alter database open

alter database open
*
ERROR at line 1:
ORA-19838: Nie mozna uzyc tego pliku sterujacego do otwarcia bazy danych

** So ..

sql> alter database backup controlfile to trace ;

** In controlfile recretion script the database name is the source db_name and the dir names for redo logs are still incorrect
******************************************************************************************
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 11680
LOGFILE
  GROUP 9 '/oradb1//redo09.log'  SIZE 150M BLOCKSIZE 512,
  GROUP 10 '/oradb1//redo10.log'  SIZE 150M BLOCKSIZE 512,
  GROUP 11 '/oradb1//redo11.log'  SIZE 150M BLOCKSIZE 512,
  GROUP 12 '/oradb1//redo012.log'  SIZE 150M BLOCKSIZE 512,
  GROUP 13 '/oradb1//redo013.log'  SIZE 150M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/oradb1//system01.dbf',
  '/oradb1//undotbs01.dbf',
  '/oradb1//sysaux01.dbf',
  '/oradb1//users01.dbf',
  '/oradb1//TBS1_DATA01.dbf',
  '/oradb1//
TBS1_DATA02.dbf',
................
................
  '/oradb1//
TBS1_IDX08.dbf',
  '/oradb1//
TBS1_DATA29.dbf',
  '/oradb1//
TBS1_IDX09.dbf',
  '/oradb1//
TBS1_IDX07.dbf',
  '/oradb1//
TBS1_237318729380334627.dbf'
CHARACTER SET EE8ISO8859P2
;
******************************************************************************************

SQL> alter system set db_name= scope=spfile;

*** or change it in pfile init.ora


SQL> @_ctl_recr.sql
ORACLE instance started.

Total System Global Area 4710043648 bytes
Fixed Size                  2229384 bytes
Variable Size            1962937208 bytes
Database Buffers         2734686208 bytes
Redo Buffers               10190848 bytes

Control file created.

SQL> alter database open resetlogs ;

Database altered.

SQL>

RMAN> recover database until sequence 9923;