重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5916|回复: 8
打印 上一主题 下一主题

[备份恢复] 关于 recover database 的凝问?

[复制链接]
跳转到指定楼层
楼主
发表于 2015-10-21 10:31:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
oracle 11.2.0.4
RAC
  当用前2天的全备(full database + controlfile + archivelog)作恢复时,用 rman 已完成了restore database ,在作recover 的时候,提示需要337 338 369 370 号归档日志,但是这些归档日志都是有的,而且就在目标库的归档目录下。
脚本如下:
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/undotbs1.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/users01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/xxx_tbs_01.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/undotbs2.dbf';
restore database ;
switch datafile all;
}
rman> recover database ;
--在这里报错,提示需要17 18 25 26 号归档日志。错误信息如下:
RMAN> recover database;
Starting recover at 2015-10-18 23:57:36
using channel ORA_DISK_1
starting media recovery
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 2 needs more recovery to be consistent
ORA-01110: data file 2: '/home/oracle/orabak/oradata/sysaux01.dbf'
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/18/2015 23:57:39
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 2 with sequence 18 and starting SCN of 1366711 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 17 and starting SCN of 1284322 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 26 and starting SCN of 1366703 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 25 and starting SCN of 1285666 found to restore

但是我在sqlplus 里用 sql> recover database using backup controlfile until cancel;
再选择 AUTO
就可以恢复。
我在网上找了一些资料,说:如果是用的以前备份的控制文件来恢复,就要用 ”recover database using backup controlfile until cancel; “,
因为控制文件是旧的,而现在要恢复到控制文件记录的SCN号之后,所以就须用这个命令。那么我得出结论,如果要恢复到控制文件记录的SCN号之后,就必须在sqlplus 里用 "recover databsas using backup XXXX"。
好吧,暂且认为这是正确的,但是用”recover database using backup controlfile until cancel; “这个命令应用了17 18 25 26号日志之后,再应用其之后的归档日志,在rman 里用recover database ;又是可以恢复的。
这又是为什么呢? 照理说这同样是恢复到控制文件记录记录的SCN号之后。为什么在ramn 里直接用 rman> recover database ; 又是可以的?
rman> recover database; 与 sql> recover database using backup controlfile until cancel; 有什么本质的区别?

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

沙发
发表于 2015-10-21 10:50:05 | 只看该作者
你可以试着在同一个session中做restore,recover,
比如:

run{
set newname for datafile 1 to '/u01/app/oracle/oradata/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/undotbs1.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/users01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/xxx_tbs_01.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/undotbs2.dbf';
restore database ;
switch datafile all;
recover database;
}

而不是分成两个session来操作。
回复 支持 反对

使用道具 举报

板凳
发表于 2015-10-21 10:54:26 | 只看该作者
如果recover database using backup controlfile until cancel 都能找到这个 17,18,25,26的日志,那recover database应该也可以 。rac的归档日志是放在什么地方?
回复 支持 反对

使用道具 举报

地板
 楼主| 发表于 2015-10-21 11:00:53 | 只看该作者
好的,我试一下。
RAC 的归档日志就在目标库的归档目录下。
回复 支持 反对

使用道具 举报

5#
发表于 2015-10-21 11:10:48 | 只看该作者
rac的话,数据库应该是存储在共享存储吧,归档在哪里,在共享存储,还是在每个节点上。
试着单独通过rman能否恢复这几个日志出来。看能否成功?
回复 支持 反对

使用道具 举报

6#
 楼主| 发表于 2015-10-21 11:52:38 | 只看该作者
是这样的:
源库是 rac(ASM),其归档日志存了2份,一份在asm 上,一份在本地磁盘(防止存储出问题,这个存储没有多路径) ,目标库是单节点, 我现在是用源库的备份恢复到目标库。
回复 支持 反对

使用道具 举报

7#
 楼主| 发表于 2015-10-21 11:53:35 | 只看该作者
我又测试了一下,restore 和 recover 都在一个 run 里,但是还是不得行!!!
RMAN> run{
2> set  newname for datafile 1 to '/u01/app/oracle/oradata/system01.dbf';
3> set  newname for datafile 2 to '/home/oracle/orabak/oradata/sysaux01.dbf';
4> set  newname for datafile 3 to '/home/oracle/orabak/oradata/undotbs1.dbf';
5> set  newname for datafile 4 to '/home/oracle/orabak/oradata/users01.dbf';
6> set  newname for datafile 5 to '/home/oracle/orabak/oradata/ytp2p_tbs_01.dbf';
7> set  newname for datafile 6 to '/home/oracle/orabak/oradata/undotbs2.dbf';
8> restore database ;
9> switch datafile all;
10> recover database;
11> }

executing command: SET NEWNAME
released channel: ORA_DISK_1

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2015-10-20 20:43:36
Starting implicit crosscheck backup at 2015-10-20 20:43:36
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
Crosschecked 45 objects
Finished implicit crosscheck backup at 2015-10-20 20:43:37

Starting implicit crosscheck copy at 2015-10-20 20:43:37
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2015-10-20 20:43:38

searching for all files in the recovery area
cataloging files...
no files cataloged

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 00001 to /u01/app/oracle/oradata/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/orabak/oradata/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/orabak/oradata/undotbs1.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/orabak/oradata/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/orabak/oradata/ytp2p_tbs_01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/orabak/oradata/undotbs2.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/orabak/databack/full_20151014_0rqjnkrj_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/orabak/databack/full_20151014_0rqjnkrj_1_1.bak tag=TAG20151014T230003
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:38
Finished restore at 2015-10-20 20:47:17

datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=893623640 file name=/u01/app/oracle/oradata/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=893623640 file name=/home/oracle/orabak/oradata/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=893623640 file name=/home/oracle/orabak/oradata/undotbs1.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=893623640 file name=/home/oracle/orabak/oradata/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=893623640 file name=/home/oracle/orabak/oradata/ytp2p_tbs_01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=893623640 file name=/home/oracle/orabak/oradata/undotbs2.dbf

Starting recover at 2015-10-20 20:47:21
using channel ORA_DISK_1

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 2 needs more recovery to be consistent
ORA-01110: data file 2: '/home/oracle/orabak/oradata/sysaux01.dbf'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/20/2015 20:47:25
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 2 with sequence 18 and starting SCN of 1366711 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 17 and starting SCN of 1284322 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 26 and starting SCN of 1366703 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 25 and starting SCN of 1285666 found to restore
回复 支持 反对

使用道具 举报

8#
发表于 2015-10-21 14:20:06 | 只看该作者
你使用 recover database using backup controlfile until cancel 能找到这个 17,18,25,26的日志吗?
应该是找不到吧
这个 17,18,25,26是否是当前联机文件还没有归档?
回复 支持 反对

使用道具 举报

9#
 楼主| 发表于 2015-10-23 14:57:33 | 只看该作者
用 recover database using backup controlfile until cancel  然后选择 auto 可以找到并应用日志。。
以下是日志记录:
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 1364461 generated at 10/14/2015 23:00:03 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/arch/1_25_892951721.dbf
ORA-00280: change 1364461 for thread 1 is in sequence #25


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1364461 generated at 10/14/2015 11:19:56 needed for thread 2
ORA-00289: suggestion : /u01/app/oracle/arch/2_17_892951721.dbf
ORA-00280: change 1364461 for thread 2 is in sequence #17


ORA-00279: change 1366703 generated at 10/14/2015 23:20:04 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/arch/1_26_892951721.dbf
ORA-00280: change 1366703 for thread 1 is in sequence #26
ORA-00278: log file '/u01/app/oracle/arch/1_25_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1366711 generated at 10/14/2015 23:20:06 needed for thread 2
ORA-00289: suggestion : /u01/app/oracle/arch/2_18_892951721.dbf
ORA-00280: change 1366711 for thread 2 is in sequence #18
ORA-00278: log file '/u01/app/oracle/arch/2_17_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1367048 generated at 10/14/2015 23:20:15 needed for thread 2
ORA-00289: suggestion : /u01/app/oracle/arch/2_19_892951721.dbf
ORA-00280: change 1367048 for thread 2 is in sequence #19
ORA-00278: log file '/u01/app/oracle/arch/2_18_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1367052 generated at 10/14/2015 23:20:17 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/arch/1_27_892951721.dbf
ORA-00280: change 1367052 for thread 1 is in sequence #27
ORA-00278: log file '/u01/app/oracle/arch/1_26_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1450375 generated at 10/15/2015 15:59:54 needed for thread 2
ORA-00289: suggestion : /u01/app/oracle/arch/2_20_892951721.dbf
ORA-00280: change 1450375 for thread 2 is in sequence #20
ORA-00278: log file '/u01/app/oracle/arch/2_19_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1504635 generated at 10/15/2015 23:20:03 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/arch/1_28_892951721.dbf
ORA-00280: change 1504635 for thread 1 is in sequence #28
ORA-00278: log file '/u01/app/oracle/arch/1_27_892951721.dbf' no longer needed
for this recovery


ORA-00279: change 1504639 generated at 10/15/2015 23:20:06 needed for thread 2
ORA-00289: suggestion : /u01/app/oracle/arch/2_21_892951721.dbf
ORA-00280: change 1504639 for thread 2 is in sequence #21
ORA-00278: log file '/u01/app/oracle/arch/2_20_892951721.dbf' no longer needed
for this recovery


ORA-00308: cannot open archived log '/u01/app/oracle/arch/2_21_892951721.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-25 05:49 , Processed in 0.121260 second(s), 24 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表