Oracle 11g 数据恢复向导

本文介绍如何使用Oracle恢复向导(RMAN)恢复误删的数据文件,包括一般数据文件(users)及系统数据文件(system、undo),并提供了详细的恢复步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

恢復向导恢复数据文件

一、恢复一般数据文件(users等)
    1.模拟删除users01.dbf数据文件:
        [oracle@testA /]$ rm /home/oracle/app/oracle/oradata/orcl/users01.dbf
        再次查询表的时候会报错:
        SQL> select * from dept;
    ERROR at line 1:
    ORA-01116: error in opening database file 4
    ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
    ORA-27041: unable to open file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3

提示datafile 4 有问题,也就是刚删除users01.dbf文件;

    2.连进rman:rman target /

    3.查看问题列表:
        RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
62         HIGH     OPEN      11-MAY-18     One or more non-system datafiles are missing
    4.查看恢复建议:
        RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
62         HIGH     OPEN      11-MAY-18     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=101 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /home/oracle/app/oracle/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: /home/oracle/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1978000856.hm+

可以看到有找到修复脚本(红色字体)

      5.修复
        RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /home/oracle/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1978000856.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 11-MAY-18
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 /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_11/o1_mf_nnndf_TAG20180511T102914_fh9zzv00_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_11/o1_mf_nnndf_TAG20180511T102914_fh9zzv00_.bkp tag=TAG20180511T102914
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 11-MAY-18
Starting recover at 11-MAY-18
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-MAY-18
sql statement: alter database datafile 4 online
repair failure complete
           至此,数据文件已恢复成功,可以正常访问db(红色部分为恢复时执行的脚本);
        

二、恢复系统数据文件(system、undo)
    恢复系统数据文件时需要在mount状态下执行,其他操作同上。

PS:此种修复向导的方法只能针对恢复数据文件,对controlfil或spfile等无效;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ty_FFTQ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值