oracle 11G RMAN的List Failure, Advise Failure and Repair Failure

测试一下这几个命令的使用

 

1.测试环境如下:

 

RMAN> report schema;

Report of database schema for database with db_unique_name ORCL

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    710      SYSTEM               ***     /u01/oradata/orcl/system01.dbf
2    610      SYSAUX               ***     /u01/oradata/orcl/sysaux01.dbf
3    30       UNDOTBS1             ***     /u01/oradata/orcl/undotbs01.dbf
4    5        USERS                ***     /u01/oradata/orcl/users01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /u01/oradata/orcl/temp01.dbf

2.做一个全备

RMAN> backup database format '/u02/RMAN/full_%U';

Starting backup at 07-APR-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/u01/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/u01/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-APR-20
channel ORA_DISK_1: finished piece 1 at 07-APR-20
piece handle=/u02/RMAN/full_03ut2amm_1_1 tag=TAG20200407T162246 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 07-APR-20

Starting Control File and SPFILE Autobackup at 07-APR-20
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2020_04_07/o1_mf_s_1037118231_h8rg4r5s_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-APR-20

RMAN> backup archivelog all format '/u02/RMAN/archive_%U';

Starting backup at 07-APR-20
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=1 STAMP=1037118278
channel ORA_DISK_1: starting piece 1 at 07-APR-20
channel ORA_DISK_1: finished piece 1 at 07-APR-20
piece handle=/u02/RMAN/archive_05ut2aq7_1_1 tag=TAG20200407T162439 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-APR-20

Starting Control File and SPFILE Autobackup at 07-APR-20
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2020_04_07/o1_mf_s_1037118280_h8rg68dj_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-APR-20

3.关闭数据库,删除一个数据文件:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@qht131 /]$ mv /u01/oradata/orcl/users01.dbf /u01/oradata/orcl/users01.dbf_orig

4.启动数据库

SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             134218008 bytes
Database Buffers          171966464 bytes
Redo Buffers                4747264 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/oradata/orcl/users01.dbf'


SQL> select open_mode from v$database ;

OPEN_MODE
--------------------
MOUNTED

5. LIST FAILURE查看状态

RMAN> list failure;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
162        HIGH     OPEN      07-APR-20     One or more non-system datafiles are missing

RMAN> list failure detail;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
162        HIGH     OPEN      07-APR-20     One or more non-system datafiles are missing
  Impact: See impact for individual child failures
  List of child failures for parent failure ID 162
  Failure ID Priority Status    Time Detected Summary
  ---------- -------- --------- ------------- -------
  165        HIGH     OPEN      07-APR-20     Datafile 4: '/u01/oradata/orcl/users01.dbf' is missing
    Impact: Some objects in tablespace USERS might be unavailable

RMAN> list failure 165;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
165        HIGH     OPEN      07-APR-20     Datafile 4: '/u01/oradata/orcl/users01.dbf' is missing
  Impact: Some objects in tablespace USERS might be unavailable

6.ADVISE FAILURE查看建议

RMAN> advise failure;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
165        HIGH     OPEN      07-APR-20     Datafile 4: '/u01/oradata/orcl/users       01.dbf' is missing
  Impact: Some objects in tablespace USERS might be unavailable

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

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

Optional Manual Actions
=======================
1. If file /u01/oradata/orcl/users01.dbf was unintentionally renamed or moved, r       estore 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/orcl/orcl/hm/reco_502490704.hm

根据建议,reco_502490704.hm为恢复的脚本,内容如下:

[oracle@qht131 /]$ cat /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_502490704.hm
   # restore and recover datafile
   restore datafile 4;
   recover datafile 4;
   sql 'alter database datafile 4 online';

7.根据建议自动恢复

由于上面退出rman了,重新进rman获取advise建议时,需要重新List failure。

RMAN> list failure;
RMAN>  advise failure;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
162        HIGH     OPEN      07-APR-20     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=1 device type=DISK
analyzing automatic repair options complete

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

Optional Manual Actions
=======================
1. If file /u01/oradata/orcl/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/orcl/orcl/hm/reco_2853868618.hm

#生成一个新的建议脚本文件

RMAN> Repair Failure preview;

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

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

开始恢复

RMAN> repair failure;

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

contents of repair script:
   # restore and recover datafile
   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)? y
executing repair script

Starting restore at 07-APR-20
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/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /u02/RMAN/full_03ut2amm_1_1
channel ORA_DISK_1: piece handle=/u02/RMAN/full_03ut2amm_1_1 tag=TAG20200407T162246
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 07-APR-20

Starting recover at 07-APR-20
using channel ORA_DISK_1

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

Finished recover at 07-APR-20

sql statement: alter database datafile 4 online
repair failure complete

Do you want to open the database (enter YES or NO)? y
database opened

8.恢复成功

SQL> select open_mode from v$database ;

OPEN_MODE
--------------------
READ WRITE

 

你可能感兴趣的:(ORACLE,11G)