Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

351

积分

0

好友

8

主题
1#
发表于 2012-5-3 16:21:55 | 查看: 3582| 回复: 1
疑问1的帖子:
http://t.askmaclean.com/thread-808-1-1.html

You should only run the SET DBID command in the following specialized circumstances:

  • You are not connected to a recovery catalog and want to restore the control file or server parameter file.
  • You are connected to a recovery catalog and want to restore the control file, but the database name is not unique in the recovery catalog.
  • The server parameter file is lost and you want to restore it.

从上面的描述看出没有使用recovery catalog的时候是需要set dbid才能恢复spfile和controlfile的,但是我的测试却不是这样的:

版本10.2.0.4.0

--丢失spfile的恢复

RMAN> startup nomount

启动失败: ORA-01078: failure in processing system parameters
LRM-00109: ???????????????? 'E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INITOANET.OR
A'
在没有参数文件的情况下启动 Oracle 实例以检索 spfile
Oracle 实例已启动
系统全局区域总计     369098752 字节
Fixed Size                     2213248 字节
Variable Size                110901888 字节
Database Buffers             251658240 字节
Redo Buffers                   4325376 字节

RMAN> show all
2> ;

使用目标数据库控制文件替代恢复目录
RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

RMAN> restore spfile from autobackup db_recovery_file_dest='E:\recover_dest' db_name='oanet';

启动 restore 于 03-5月 -12
使用通道 ORA_DISK_1
恢复区目标: E:\recover_dest
用于搜索的数据库名 (或数据库的唯一名称): OANET
通道 ORA_DISK_1: 在恢复区域中找到自动备份
通道 ORA_DISK_1: 已找到的自动备份: E:\RECOVER_DEST\OANET\AUTOBACKUP\2012_05_02\O
1_MF_S_782262314_7T40ZW2J_.BKP
通道 ORA_DISK_1: 从自动备份复原 SPFILE 已完成
完成 restore 于 03-5月 -12

RMAN>

具体可以看这个帖子:http://t.askmaclean.com/thread-881-1-1.html

--丢时控制文件的恢复
RMAN> startup nomount

已连接到目标数据库 (未启动)
Oracle 实例已启动
系统全局区域总计   10737418240 字节
Fixed Size                     2231048 字节
Variable Size               3063674104 字节
Database Buffers            7667187712 字节
Redo Buffers                   4325376 字节

RMAN> restore controlfile from autobackup;

启动 restore 于 03-5月 -12
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=536 devtype=DISK
恢复区目标: E:\recover_dest
用于搜索的数据库名 (或数据库的唯一名称): OANET
通道 ORA_DISK_1: 在恢复区域中找到自动备份
通道 ORA_DISK_1: 已找到的自动备份: E:\RECOVER_DEST\OANET\AUTOBACKUP\2012_05_02\O
1_MF_S_782262314_7T40ZW2J_.BKP
通道 ORA_DISK_1: 从自动备份复原控制文件已完成
输出文件名=H:\ORADATA\OANET\CONTROL01.CTL
输出文件名=H:\ORADATA\OANET\CONTROL02.CTL
输出文件名=H:\ORADATA\OANET\CONTROL03.CTL
输出文件名=E:\ORACLE\PRODUCT\10.2.0\ORADATA\OANET\CONTROL04.CTL
完成 restore 于 03-5月 -12

RMAN> startup mount

数据库已经启动
数据库已装载
释放的通道: ORA_DISK_1

从上面可以看出,无论是丢失控制文件还是spfile恢复时都不需要set dbid,这是否说明官方文档写错了?
2#
发表于 2012-5-4 22:47:55
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> backup spfile;

Starting backup at 04-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=142 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-MAY-12
channel ORA_DISK_1: finished piece 1 at 04-MAY-12
piece handle=/s01/orabase/fast_recovery_area/G11R23/backupset/2012_05_04/o1_mf_nnsnf_TAG20120504T152207_7t8c321b_.bkp tag=TAG20120504T152207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-MAY-12

Starting Control File and SPFILE Autobackup at 04-MAY-12
piece handle=/s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 04-MAY-12

SQL> select dbid from v$database;

      DBID
----------
2935193447

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /s01/orabase/oradata/G11R23/co
                                                 ntrol01.ctl, /s01/orabase/fast
                                                 _recovery_area/G11R23/control0
                                                 2.ctl
                                                
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


delete controlfiles

[oracle@nas ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri May 4 15:25:06 2012

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

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     939495424 bytes

Fixed Size                     2233960 bytes
Variable Size                708839832 bytes
Database Buffers             222298112 bytes
Redo Buffers                   6123520 bytes




RMAN> alter database mount;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 05/04/2012 15:25:32
ORA-00205: error in identifying control file, check alert log for more info


RMAN>   restore controlfile from autobackup;

Starting restore at 04-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

recovery area destination: /s01/orabase/fast_recovery_area
database name (or database unique name) used for search: G11R23
channel ORA_DISK_1: AUTOBACKUP /s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/s01/orabase/oradata/G11R23/control01.ctl
output file name=/s01/orabase/fast_recovery_area/G11R23/control02.ctl
Finished restore at 04-MAY-12




RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/s01/%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/s01/%F';
new RMAN configuration parameters are successfully stored


RMAN> backup spfile;

Starting backup at 04-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-MAY-12
channel ORA_DISK_1: finished piece 1 at 04-MAY-12
piece handle=/s01/orabase/fast_recovery_area/G11R23/backupset/2012_05_04/o1_mf_nnsnf_TAG20120504T153659_7t8cyw45_.bkp tag=TAG20120504T153659 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-MAY-12

Starting Control File and SPFILE Autobackup at 04-MAY-12
piece handle=/s01/c-2935193447-20120504-02 comment=NONE
Finished Control File and SPFILE Autobackup at 04-MAY-12



SQL> shutdown immediate;


delete controlfiles


RMAN> alter database mount;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 05/04/2012 15:39:08
ORA-00205: error in identifying control file, check alert log for more info            





RMAN> RUN
2> {
3>   SET CONTROLFILE AUTOBACKUP FORMAT
4>     FOR DEVICE TYPE DISK TO '/s01/%F';
5>   RESTORE CONTROLFILE FROM AUTOBACKUP;
6> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 04-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

recovery area destination: /s01/orabase/fast_recovery_area
database name (or database unique name) used for search: G11R23
channel ORA_DISK_1: AUTOBACKUP /s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp found in the recovery area
AUTOBACKUP search with format "/s01/%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/s01/orabase/oradata/G11R23/control01.ctl
output file name=/s01/orabase/fast_recovery_area/G11R23/control02.ctl
Finished restore at 04-MAY-12




[oracle@nas ~]$ rm /s01/orabase/oradata/G11R23/control01.ctl
[oracle@nas ~]$ rm /s01/orabase/fast_recovery_area/G11R23/control02.ctl

[oracle@nas ~]$ rm -rf /s01/orabase/fast_recovery_area/G11R23/autobackup/


RMAN> RUN
2> {
3>   SET CONTROLFILE AUTOBACKUP FORMAT
4>     FOR DEVICE TYPE DISK TO '/s01/%F';
5>   RESTORE CONTROLFILE FROM AUTOBACKUP;
6> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 04-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK

recovery area destination: /s01/orabase/fast_recovery_area
database name (or database unique name) used for search: G11R23
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
AUTOBACKUP search with format "/s01/%F" not attempted because DBID was not set
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/04/2012 15:42:04
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


[oracle@nas ~]$ ls -l /s01/c-2935193447-20120504-02
-rw-r----- 1 oracle oinstall 9863168 May  4 15:37 /s01/c-2935193447-20120504-02

RMAN> set dbid 2935193447

executing command: SET DBID

RMAN> RUN
2> {
3>   SET CONTROLFILE AUTOBACKUP FORMAT
4>     FOR DEVICE TYPE DISK TO '/s01/%F';
5>   RESTORE CONTROLFILE FROM AUTOBACKUP;
6> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 04-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

recovery area destination: /s01/orabase/fast_recovery_area
database name (or database unique name) used for search: G11R23
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120504
channel ORA_DISK_1: AUTOBACKUP found: /s01/c-2935193447-20120504-02
channel ORA_DISK_1: restoring control file from AUTOBACKUP /s01/c-2935193447-20120504-02
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/s01/orabase/oradata/G11R23/control01.ctl
output file name=/s01/orabase/fast_recovery_area/G11R23/control02.ctl
Finished restore at 04-MAY-12






结论 : rman  restore controlfile from autobackup  会优先采用fast_recovery_area中的autobackup 自动备份 ,
当dbid未被设置时 会提示 "AUTOBACKUP search with format "/s01/%F" not attempted because DBID was not set" , 通过 相对 唯一的DB_UNIQUE_NAME 来定位controlfile autoback (database name (or database unique name) used for search: G11R23),若找到则直接使用:
channel ORA_DISK_1: AUTOBACKUP /s01/orabase/fast_recovery_area/G11R23/autobackup/2012_05_04/o1_mf_s_782407330_7t8c32ng_.bkp found in the recovery area


当fast_recovery_area 中没有可用的备份时, rman才考虑CONTROLFILE AUTOBACKUP FORMAT  指定的位置, 若此时没有设置DBID 则会报错 ,  

若此时指定 DBID 则会按照DBID去搜索:

recovery area destination: /s01/orabase/fast_recovery_area
database name (or database unique name) used for search: G11R23
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120504
channel ORA_DISK_1: AUTOBACKUP found: /s01/c-2935193447-20120504-02
channel ORA_DISK_1: restoring control file from AUTOBACKUP /s01/c-2935193447-20120504-02
channel ORA_DISK_1: control file restore from AUTOBACKUP complete

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-11-15 15:54 , Processed in 0.055326 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569