Data Recovery Advisor (DRA)

11g Release 1-д нэмэгдсэн шинэ боломжийг ашиглан хэрхэн сэргээх талаар сонирхоё.

SQL> desc a;
 Name					   Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID						    NUMBER

SQL> select * from a;
select * from a
              *
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time
ORA-01110: data file 4: '/u01/app/oracle/oradata/DB11G/users01.dbf'

SQL>

Дээрхээс харахад хүснэгтний мэдээлэл гарах хэдий ч уг хүснэгтнээс мэдээллийг татаж харуулахад алдаа зааж байна. Алдаанд дата агуулагдах файл-ийг уншиж чадсангүй гэсэн байна. Уг файл байгаа эсэхийг шалгая.

[oracle@node214 DB11G]$ pwd
/u01/app/oracle/oradata/DB11G
[oracle@node214 DB11G]$ ls -la
total 3559068
drwxr-x--- 2 oracle oinstall      4096 Feb  2 01:08 .
drwxr-x--- 5 oracle oinstall      4096 Jan 23 10:17 ..
-rw-r----- 1 oracle oinstall   9748480 Feb  2 01:10 control01.ctl
-rw-r----- 1 oracle oinstall 209723392 Feb  1 22:07 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:02 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:02 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:06 redo03.log
-rw-r----- 1 oracle oinstall 692068352 Feb  2 01:09 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 Feb  2 01:09 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Feb  2 01:00 temp01.dbf
-rw-r----- 1 oracle oinstall 104865792 Feb  2 01:09 undotbs01.dbf
[oracle@node214 DB11G]$

Файл байхгүй учир RMAN -р нэвтэрч шинэ боломжийг ашиглая.

[oracle@node214 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Feb 2 01:07:24 2017

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

connected to target database: DB11G (DBID=403682774)

RMAN>

Дараах коммандаар ямар алдаанууд байгааг харна.

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
8          HIGH     OPEN      01-FEB-17     One or more non-system datafiles need media recovery
322        HIGH     OPEN      01-FEB-17     One or more non-system datafiles are missing

Уг алдаануудыг хэрхэн засварлах талаар харахын тулд дараах коммандыг ашиглана.

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
8          HIGH     OPEN      01-FEB-17     One or more non-system datafiles need media recovery
322        HIGH     OPEN      01-FEB-17     One or more non-system datafiles are missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If you restored the wrong version of data file /u01/app/oracle/oradata/DB11G/users01.dbf, then replace it with the correct one
2. If file /u01/app/oracle/oradata/DB11G/users01.dbf was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Restore and recover datafile 4
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/db11g/DB11G/hm/reco_159771188.hm

Дээрх үр дүнд гар аргаар хэрхэн засах, эсвэл автоматаар хэрхэн засварлах талаар харуулсан байна. Аль боломжтой хувилбаруудыг харуулна. Бид автоматаар засварлах аргыг сонгож дараах коммандыг ашиглана. Уг коммандыг ажиллуулахад баталгаажуулалт асуух бөгөөд ард нь ямар коммандууд ажиллах байгааг харах боломжтой.

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/db11g/DB11G/hm/reco_159771188.hm

contents of repair script:
   # restore and recover datafile
   sql 'alter database datafile 4 offline';
   restore datafile 4;
   recover datafile 4;
   sql 'alter database datafile 4 online';

Do you really want to execute the above repair (enter YES or NO)? Yes
executing repair script

sql statement: alter database datafile 4 offline

Starting restore at 02-FEB-17
using channel ORA_DISK_1

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 00004 to /u01/app/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_01/o1_mf_nnndf_TAG20170201T044347_d91xr4km_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/DB11G/backupset/2017_02_01/o1_mf_nnndf_TAG20170201T044347_d91xr4km_.bkp tag=TAG20170201T044347
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:16
Finished restore at 02-FEB-17

Starting recover at 02-FEB-17
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 02-FEB-17

sql statement: alter database datafile 4 online
repair failure complete

RMAN>

Файлыг шалгая

[oracle@node214 DB11G]$ ls -la
total 3559068
drwxr-x--- 2 oracle oinstall      4096 Feb  2 01:08 .
drwxr-x--- 5 oracle oinstall      4096 Jan 23 10:17 ..
-rw-r----- 1 oracle oinstall   9748480 Feb  2 01:10 control01.ctl
-rw-r----- 1 oracle oinstall 209723392 Feb  1 22:07 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:02 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:02 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Jan 29 07:06 redo03.log
-rw-r----- 1 oracle oinstall 692068352 Feb  2 01:09 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 Feb  2 01:09 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Feb  2 01:00 temp01.dbf
-rw-r----- 1 oracle oinstall 104865792 Feb  2 01:09 undotbs01.dbf
-rw-r----- 1 oracle oinstall 360456192 Feb  2 01:10 users01.dbf
[oracle@node214 DB11G]$

Хүснэгтнээг мэдээллийг татаж шалгая.

SQL> select * from a;

	ID
----------
	 1

SQL>