Performing Recovery with a Backup Control File

控制文件所有副本出现问题时需要使用备份控制文件来恢复,但这不是唯一场景,在执行数据库的时间点恢复时通常也需要使用相应备份的控制文件来恢复,而不能使用当前控制文件

If all copies of the current control file are lost or damaged, then you must restore and mount a backup control file.

如果只是控制文件某些副本损坏,可以通过手动复制未损坏副本方式恢复,过程见《User-Managed Backup and Recovery》部分

  1. RESTORE CONTROL FILE

默认会RESTORE到CONTROL_FILES参数设置位置

When you are restoring the control file, the default destination is all of the locations defined in the CONTROL_FILES initialization parameter. One way to restore the control file to one or more new locations is to change the CONTROL_FILES initialization parameter, and then use the RESTORE CONTROLFILE command with no arguments to restore the control file to the default locations.

RESTROE CONTROLFILE TO只是还原到其它位置,但是否使用还是看CONTROL_FILES,这个命令可以在NOMOUNT/MOUNT/OPEN下使用

RESTORE CONTROLFILE TO '/tmp/my_controlfile';

You can perform this operation with the database in NOMOUNT, MOUNT, or OPEN states, because you are not overwriting any of the control files currently in use. Any existing file named 'filename' is overwritten. After restoring the control file to a new location, you can then update the CONTROL_FILES initialization parameter to include the new location.

  1. RMAN Recovery

不论是否RESTORE了数据文件还原控制文件后均需要RECOVER

RECOVER不论是否应用了日志都要以OPEN RESETLOGS打开数据库

You must then run the RECOVER command, even if no data files have been restored, and open the database with the RESETLOGS option. The option OPEN RESETLOGS is always required after recovery with a backup control file, regardless of whether logs are available.

RECOVER时RMAN自动从RMAN repository及相关数据库参数路径中寻找相应归档日志

During recovery, RMAN automatically searches for online and archived logs that are not recorded in the RMAN repository and catalogs any that it finds. Similarly, RMAN attempts to find the online redo logs by using the file names listed in the control file.

RMAN attempts to find a valid archived redo log in any current archiving destination with the current log format. The current format is specified in the initialization parameter file used to start the instance (or all instances in an Oracle RAC configuration).

是否使用CATALOG的区别:

  1. 不使用CATALOG时旧控制文件中不会记录之后的备份信息,可能找不到相应归档日志,这时需要使用catalog加到旧控制文件中

Because you are not connected to a recovery catalog, the RMAN repository contains only information about available backups at the time of the control file backup. If you know the location of other usable backup sets or image copies, then add them to the control file RMAN repository with the CATALOG command.

  1. 不使用CATALOG基本只能使用autobackup还原控制文件,而catalog可以使用备份还原

If you are not using a recovery catalog, then you must restore your control file from an autobackup. To restore the control file from autobackup, the database must be in a NOMOUNT state.

If you know the backup piece name that contains the control file (for example, from the media manager or because the piece is on disk), then you can specify the piece name using the RESTORE CONTROLFILE FROM 'filename' command.

  1. Performing Recovery with a Backup Control File and No Recovery Catalog

在控制文件不可用时可通过alert log查看自动备份位置

The database records the location of every autobackup in the alert log.

To recover the database with a control file autobackup in NOCATALOG mode:

  1. Start RMAN and connect to a target database.
  2. Start the target database instance without mounting the database:

STARTUP NOMOUNT;

  1. Set the database identifier for the target database with the SET DBID command.

SET DBID 676549873;

  1. Write an RMAN command file to restore the autobackup control file and perform recovery.

The command file contains the following steps:

  1. Optionally, specify the most recent backup time stamp that RMAN can use when searching for a control file autobackup to restore.
  2. If you know that a different control file autobackup format was in effect when the control file autobackup was created, then specify a nondefault format for the restore of the control file.

Example:  

SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'autobackup_format';

  1. If an SBT channel created the control file autobackup, then allocate one or more SBT channels. Because no recovery catalog is available, you cannot use preconfigured channels.
  2. Restore the autobackup of the control file, optionally setting the maximum number of days backward that RMAN can search and the initial sequence number that it uses in its search for the first day.
  3. This step depends on whether the online redo logs are available. If the online redo logs are usable, then RMAN can find and apply these logs. Perform a complete restore and recovery.

If the online redo logs are unusable, then perform DBPITR. An UNTIL clause is required to specify a target time, SCN, or log sequence number for the recovery before the first SCN of the online redo logs (otherwise, RMAN issues the RMAN-6054 error).

Note: When specifying log sequences, if the last created archived redo log has sequence n, then specify UNTIL SEQUENCE n+1 so that RMAN applies n and then stops.

使用备份控制文件进行完全或不完全恢复,可以先以READ ONLY打开查看恢复状态

Note: When you perform DBPITR with a backup control file, before opening the database with RESETLOGS, you can open the database read-only using SQL*Plus and run queries as needed to verify that the effects of the logical corruption have been reversed. If you are satisfied with the results, then you can open the database with RESETLOGS.

RUN

{

  # Optionally, set upper limit for eligible time stamps of control file

  # backups

  # SET UNTIL TIME '09/10/2013 13:45:00';

  # Specify a nondefault autobackup format only if required

  # SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK

  #   TO '?/oradata/%F.bck';

  ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...'; # allocate manually

  RESTORE CONTROLFILE FROM AUTOBACKUP

    MAXSEQ 100           # start at sequence 100 and count down

    MAXDAYS 180;         # start at UNTIL TIME and search back 6 months

  ALTER DATABASE MOUNT;

}

# Now use automatic channels configured in restored control file

RESTORE DATABASE UNTIL SEQUENCE 13244;

RECOVER DATABASE UNTIL SEQUENCE 13244;

  1. If recovery was successful, then open the database and reset the online logs:

ALTER DATABASE OPEN RESETLOGS;

如果知道哪个备份包含当前数据库的控制文件备份可以不指定DBID直接还原:

RMAN> restore spfile from '/autobackup/2018_09_18/o1_mf_s_987197833_ft3b29ff_.bkp';

  1. Performing Database Point-in-Time Recovery with a Backup Control File

在执行数据库的时间点恢复时要注意以下场景:

  1. 恢复到当前INCARNATION,恢复点至当前时间未出现DROP TABLESPACE操作,则使用当前控制文件即可恢复
  2. 恢复到当前INCARNATION,恢复点至当前时间出现DROP TABLESPACE操作,则需要使用DROP TABLESPACE前的备份控制文件恢复
  3. 恢复到非当前INCARNATION需要相应INCARNATION的备份控制文件恢复

详细操作见《Database Point-in-Time Recovery》

NOTE: 使用SET UNTIL还原备份的SPFILE或CONTROLFILE(RESTORE CONTROLFILE/SPFILE FROM AUTOBACK)时只能使用SET UNTIL TIME不能使用SET UNTIL SCN或SEQUENCE

  1. Performing Recovery with a Manual Backup Control File

详见《User-Managed Backup and Recovery》部分说明

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值