Archivelog сэргээх

Хэрэв бидний archivelog файлууд устсан бол бид мөн сэргээх боломжтой. Мэдээж нөөцлөлтийг байнга авсан байх шаардлагатай.

RMAN> backup database plus archivelog;
коммандаар нөөцлөлт авсан байх шаардлагатай.

Archivelog-ийн мэдээллийг харцгаая.

SQL>
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  217157632 bytes
Fixed Size		    2211928 bytes
Variable Size		  159387560 bytes
Database Buffers	   50331648 bytes
Redo Buffers		    5226496 bytes
Database mounted.
SQL> 
SQL> SELECT
  THREAD#,
  RESETLOGS_CHANGE#,
  ARCHIVED,
  SEQUENCE#,
  COMPLETION_TIME
FROM
  V$ARCHIVED_LOG
WHERE
  ARCHIVED='YES'
  AND COMPLETION_TIME = (SELECT MAX(COMPLETION_TIME)
                         FROM V$ARCHIVED_LOG
                         WHERE ARCHIVED='YES');  2    3    4    5    6    7    8    9   10   11   12   13

   THREAD# RESETLOGS_CHANGE# ARC  SEQUENCE# COMPLETIO
---------- ----------------- --- ---------- ---------
	 1	      945184 YES	 40 02-FEB-17

SQL>

Дээрх коммандаас харахад squence=40, thread=1 байна. Тиймээс дараагийн коммандад sequence 41 хүртэл гэж өгнө.

[[email protected] ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Feb 2 03:01:58 2017

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

connected to target database: DB11G (DBID=403682774, not open)

RMAN> restore database;

Starting restore at 02-FEB-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/DB11G/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/DB11G/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/DB11G/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/DB11G/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/DB11G/test_assm01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/DB11G/test_mssm01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /stripe/d1/system02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_02/o1_mf_nnndf_TAG20170202T025338_d94conkk_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_02/o1_mf_nnndf_TAG20170202T025338_d94conkk_.bkp tag=TAG20170202T025338
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:25
Finished restore at 02-FEB-17

RMAN> RECOVER DATABASE UNTIL SEQUENCE 41 thread 1;

Starting recover at 02-FEB-17
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=40
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_02/o1_mf_annnn_TAG20170202T025544_d94csjgz_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_02/o1_mf_annnn_TAG20170202T025544_d94csjgz_.bkp tag=TAG20170202T025544
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/flash_recovery_area/DB11G/archivelog/2017_02_02/o1_mf_1_40_d94f1nn9_.arc thread=1 sequence=40
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/DB11G/archivelog/2017_02_02/o1_mf_1_40_d94f1nn9_.arc RECID=33 STAMP=934859828
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-FEB-17

RMAN> sql 'ALTER DATABASE OPEN RESETLOGS';

sql statement: ALTER DATABASE OPEN RESETLOGS

RMAN> backup database plus archivelog;

Шалгах

[[email protected] archivelog]$ ls
2017_02_02  
[[email protected] archivelog]$ pwd
/u01/app/oracle/flash_recovery_area/DB11G/archivelog
[[email protected] archivelog]$
[[email protected] archivelog]$ ls -la 2017_02_02/
total 644
drwxr-x--- 2 oracle oinstall   4096 Feb  2 03:21 .
drwxr-x--- 4 oracle oinstall   4096 Feb  2 03:17 ..
-rw-r----- 1 oracle oinstall  74240 Feb  2 03:18 o1_mf_1_1_d94f3c9c_.arc
-rw-r----- 1 oracle oinstall   1024 Feb  2 03:18 o1_mf_1_2_d94f40d6_.arc
-rw-r----- 1 oracle oinstall 131584 Feb  2 03:21 o1_mf_1_3_d94f9dg9_.arc
-rw-r----- 1 oracle oinstall 396800 Feb  2 03:17 o1_mf_1_41_d94f29hp_.arc
[[email protected] archivelog]$

Archivelog файлыг үүсгэсэн байна.