用户备份的恢复

1查看那个文件需要恢复

SELECT FILE#, ERROR, ONLINE_STATUS, CHANGE#, TIME 
       FROM V$RECOVER_FILE;
2
SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name, 
       d.STATUS, r.ERROR, r.CHANGE#, r.TIME
FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t
WHERE t.TS# = d.TS#
AND d.FILE# = r.FILE#
;
要是想要完全的恢复而不是基于时间点的恢复,那么可以只恢复需要recovery的数据文件。
 
恢复数据文件
 
 
  1. Determine which datafiles to recover by using the techniques described in "Determining Which Datafiles Require Recovery".

  2. If the database is open, then take the tablespaces containing the inaccessible datafiles offline. For example, enter:

    ALTER TABLESPACE users OFFLINE IMMEDIATE;
    
    
  3. Copy backups of the damaged datafiles to their default location using operating system commands. For example, to restore users01.dbf you might issue:

    % cp /disk2/backup/users01.dbf $ORACLE_HOME/oradata/trgt/users01.dbf
    
    
  4. Recover the affected tablespace. For example, enter:

    RECOVER TABLESPACE users
    
    
  5. Bring the recovered tablespace online. For example, enter:

    ALTER TABLESPACE users ONLINE;
    

恢复归档日志
 
 
  1. To determine which archived redo log files are needed, query V$ARCHIVED_LOG and V$RECOVERY_LOG. V$ARCHIVED_LOG lists filenames for all archived logs. V$RECOVERY_LOG lists only the archived redo logs that the database needs to perform media recovery. It also includes the probable names of the files, using LOG_ARCHIVE_FORMAT.

    Note:

    V$RECOVERY_LOG is only populated when media recovery is required for a datafile. Hence, this view is not useful in the case of a planned recovery, such as recovery from a user error.

    If a datafile requires recovery, but no backup of the datafile exists, then you need all redo generated starting from the time when the datafile was added to the database.

  2. If space is available, then restore the required archived redo log files to the location specified by LOG_ARCHIVE_DEST_1. The database locates the correct log automatically when required during media recovery. For example, enter:

    % cp /disk2/arch/* $ORACLE_HOME/oradata/trgt/arch
    
    
  3. If sufficient space is not available at the location indicated by the archiving destination initialization parameter, restore some or all of the required archived redo log files to an alternate location. Specify the location before or during media recovery using the LOGSOURCE parameter of the SET statement in SQL*Plus or the RECOVER ... FROM parameter of the ALTER DATABASE statement in SQL. For example, enter:

    SET LOGSOURCE /tmp   # set location using SET statement
      DATABASE RECOVER FROM '/tmp';  # set location in RECOVER statement
    
    
  4. After an archived log is applied, and after making sure that a copy of each archived log group still exists in offline storage, delete the restored copy of the archived redo log file to free disk space. For example:

    % rm /tmp/*.dbf
    

控制文件丢失,重建控制文件的情况

Table 18-1 Scenarios When Control Files Are Lost

Status of Online LogsStatus of DatafilesRestore Procedure
AvailableCurrentIf the online logs contain redo necessary for recovery, then restore a backup control file and apply the logs during recovery. You must specify the filename of the online logs containing the changes in order to open the database. After recovery, open RESETLOGS.
UnavailableCurrentIf the online logs contain redo necessary for recovery, then re-create the control file. Because the online redo logs are inaccessible, open RESETLOGS (when the online logs are accessible it is not necessary to OPEN RESETLOGS after recovery with a created control file).
AvailableBackupRestore a backup control file, perform complete recovery, and then open RESETLOGS.
UnavailableBackupRestore a backup control file, perform incomplete recovery, and then open RESETLOGS.

在恢复的时候自动应用日志方法
1在使用recover命令之前,使用set autorecovery on
2在recover命令中使用automatic选项。
 
 
覆盖归档日志文件位置

In some cases, you may want to override the current setting for the archiving destination parameter as a source for redo log files.

To recover archived logs in a nondefault location with SET LOGSOURCE:

  1. Using an operating system utility, copy the archived redo logs to an alternative location. For example, enter:

    % cp $ORACLE_HOME/oradata/trgt/arch/* /tmp
    
    
  2. Specify the alternative location within SQL*Plus for the recovery operation. Use the LOGSOURCE parameter of the SET statement or the RECOVER ... FROM clause of the ALTER DATABASE statement. For example, start SQL*Plus and run:

    SET LOGSOURCE "/tmp"
    
    
  3. Recover the offline tablespace. For example, to recover the offline tablespace users do the following:

    RECOVER AUTOMATIC TABLESPACE users
    
    
  4. Alternatively, you can avoid running SET LOGSOURCE and simply run:

    RECOVER AUTOMATIC TABLESPACE users FROM "/tmp"
    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值