oracle 10g r2新功能可以跨越resetlogs恢复

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1613

http://blog.itpub.net/7199859/viewspace-332603/]oracle 10g r2新功能可以跨越resetlogs 恢复

10g 新版本可以跨越resetlogs 用先前的备份来恢复 ,虽然有这个特性,但还是建议resetlogs 马上进行全库备份
10g 以前版本是不行的
[size=6]先测试下9i
RMAN> recover database;
Starting recover at 05-JUN-08
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=22
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\3AJI5OME_1_1 tag=TAG20080605T121510 params=NULL
channel ORA_DISK_1: restore complete
archive log filename=D:\ARCHPAUL\PUBTEST_1_22.DBF thread=1 sequence=22
unable to find archive log
archive log thread=1 sequence=23
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/05/2008 14:42:21
RMAN-06054: media recovery requesting unknown log: thread 1 scn 769229
RMAN> alter database open resetlogs;
database opened
RMAN> exit

Recovery Manager complete.
C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.8.0 - Production on Thu Jun 5 14:46:46 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> select count(*) from test;
COUNT(*)
----------
64
SQL> insert into test select * from test;
64 rows created.
SQL> /
128 rows created.
SQL> commit;
Commit complete.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination d:\archpaul
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL> alter system switch logfile;
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination d:\archpaul
Oldest online log sequence 1
Next log sequence to archive 2
Current log sequence 2
SQL> select count(*) from test;
COUNT(*)
----------
256
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
C:\Documents and Settings\Paul Yi>rman target /
Recovery Manager: Release 9.2.0.8.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 101785012 bytes
Fixed Size 454068 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
RMAN> restore controlfile from 'd:\backup\C-799229701-20080605-01';
Starting restore at 05-JUN-08
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=11 devtype=DISK
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=D:\ORACLE\ORADATA\PUBTEST\CONTROL01.CTL
output filename=D:\ORACLE\ORADATA\PUBTEST\CONTROL02.CTL
output filename=D:\ORACLE\ORADATA\PUBTEST\CONTROL03.CTL
Finished restore at 05-JUN-08
RMAN> alter database mount;
database mounted
RMAN> restore database;
Starting restore at 05-JUN-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\ORACLE\ORADATA\PUBTEST\SYSTEM01.DBF
restoring datafile 00002 to D:\ORACLE\ORADATA\PUBTEST\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORACLE\ORADATA\PUBTEST\EXAMPLE01.DBF
restoring datafile 00004 to D:\ORACLE\ORADATA\PUBTEST\INDX01.DBF
restoring datafile 00005 to D:\ORACLE\ORADATA\PUBTEST\TOOLS01.DBF
restoring datafile 00006 to D:\ORACLE\ORADATA\PUBTEST\USERS01.DBF
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\39JI5OL0_1_1 tag=TAG20080605T121424 params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 05-JUN-08
RMAN> recover database;
Starting recover at 05-JUN-08
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=22
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\3AJI5OME_1_1 tag=TAG20080605T121510 params=NULL
channel ORA_DISK_1: restore complete
archive log filename=D:\ARCHPAUL\PUBTEST_1_22.DBF thread=1 sequence=22
unable to find archive log
archive log thread=1 sequence=23
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/05/2008 14:52:03
RMAN-06054: media recovery requesting unknown log: thread 1 scn 769229
RMAN> alter database open resetlogs;
database opened

RMAN> exit

Recovery Manager complete.
C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.8.0 - Production on Thu Jun 5 14:52:30 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> select count(*) from test;
COUNT(*)
----------
64
还是恢复到先前备份的那种状态 后面resetlogs后新增加的数据丢失了 这是因为不能跨越resetlogs的恢复
所以9i 强烈建议 resetlogs必须全备份一次数据库
[size=6]10g R2下的测试:
RMAN> alter database open resetlogs;
数据库已打开
RMAN> exit
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Paul Yi>set oracle_sid=orcl
C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.8.0 - Production on Thu Jun 5 16:25:18 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
[size=6]
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL> select count(*) from test;
COUNT(*)
----------
45028
SQL> insert into test select * from test;
45028 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from test;
COUNT(*)
----------
90056
SQL> shutdown immediate;
用先前的备份恢复:
RMAN> startup nomount;
已连接到目标数据库 (未启动)
Oracle 实例已启动
系统全局区域总计 289406976 字节
Fixed Size 1248576 字节
Variable Size 96469696 字节
Database Buffers 184549376 字节
Redo Buffers 7139328 字节
RMAN> restore controlfile from 'D:\oracle\flash_recovery_area\ORCL\AUTOBACKUP\20
08_06_05\O1_MF_S_656605042_44H17N1V_.BKP';
启动 restore 于 05-6月 -08
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=157 devtype=DISK
通道 ORA_DISK_1: 正在复原控制文件
通道 ORA_DISK_1: 恢复完成, 用时: 00:00:03
输出文件名=D:\ORACLE\ORADATA\ORCL\CONTROL01.CTL
输出文件名=D:\ORACLE\ORADATA\ORCL\CONTROL02.CTL
输出文件名=D:\ORACLE\ORADATA\ORCL\CONTROL03.CTL
完成 restore 于 05-6月 -08
RMAN> alter database mount;
数据库已装载
释放的通道: ORA_DISK_1
RMAN> restore database;
启动 restore 于 05-6月 -08
启动 implicit crosscheck backup 于 05-6月 -08
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=156 devtype=DISK
已交叉检验的 3 对象
完成 implicit crosscheck backup 于 05-6月 -08
启动 implicit crosscheck copy 于 05-6月 -08
使用通道 ORA_DISK_1
完成 implicit crosscheck copy 于 05-6月 -08
搜索恢复区域中的所有文件
正在编制文件目录...
目录编制完毕
已列入目录的文件的列表
=======================
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_18_44H1
Z3FW_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_19_44H1
Z26L_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_1_44H26
3WN_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_1_44H2F
DQC_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_20_44H1
Z2PO_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1_2_44H2F
D3T_.ARC
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566050
42_44H17N1V_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566052
54_44H1G7SD_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566052
62_44H1GJJ3_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566054
19_44H1MDOK_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566058
15_44H1ZSFF_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566062
67_44H2FX5R_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566081
98_44H4B85T_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2008_06_05\O1_MF_S_6566082
49_44H4CTKM_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_06_05\O1_MF_ANNNN_TAG2
0080605T142217_44H1JTVV_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_06_05\O1_MF_ANNNN_TAG2
0080605T142336_44H1M9XC_.BKP
文件名: D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_06_05\O1_MF_NNNDF_TAG2
0080605T142220_44H1JWYS_.BKP
使用通道 ORA_DISK_1
未处理数据文件 4, 因为文件是只读的
未处理数据文件 5, 因为文件是只读的
通道 ORA_DISK_1: 正在开始恢复数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集恢复的数据文件
正将数据文件00001恢复到D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
正将数据文件00002恢复到D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF
正将数据文件00003恢复到D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF
通道 ORA_DISK_1: 正在读取备份段 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\200
8_06_05\O1_MF_NNNDF_TAG20080605T142220_44H1JWYS_.BKP
通道 ORA_DISK_1: 已恢复备份段 1
段句柄 = D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_06_05\O1_MF_NNNDF_TAG
20080605T142220_44H1JWYS_.BKP 标记 = TAG20080605T142220
通道 ORA_DISK_1: 恢复完成, 用时: 00:00:35
完成 restore 于 05-6月 -08
RMAN> recover database;
启动 recover 于 05-6月 -08
使用通道 ORA_DISK_1
未处理数据文件 4, 因为文件是只读的
未处理数据文件 5, 因为文件是只读的
正在开始介质的恢复
存档日志线程 1 序列 18 已作为文件 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\
2008_06_05\O1_MF_1_18_44H1Z3FW_.ARC 存在于磁盘上
存档日志线程 1 序列 19 已作为文件 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\
2008_06_05\O1_MF_1_19_44H1Z26L_.ARC 存在于磁盘上
存档日志线程 1 序列 20 已作为文件 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\
2008_06_05\O1_MF_1_20_44H1Z2PO_.ARC 存在于磁盘上
存档日志线程 1 序列 1 已作为文件 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2
008_06_05\O1_MF_1_1_44H263WN_.ARC 存在于磁盘上
存档日志线程 1 序列 2 已作为文件 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2
008_06_05\O1_MF_1_2_44H2FD3T_.ARC 存在于磁盘上
存档日志线程 1 序列 1 已作为文件 D:\ORACLE\ORADATA\ORCL\REDO01.LOG 存在于磁盘上
通道 ORA_DISK_1: 正在启动到默认目标的存档日志恢复
通道 ORA_DISK_1: 正在恢复存档日志
存档日志线程 =1 序列=16
通道 ORA_DISK_1: 正在恢复存档日志
存档日志线程 =1 序列=17
通道 ORA_DISK_1: 正在读取备份段 D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\200
8_06_05\O1_MF_ANNNN_TAG20080605T142217_44H1JTVV_.BKP
通道 ORA_DISK_1: 已恢复备份段 1
段句柄 = D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_06_05\O1_MF_ANNNN_TAG
20080605T142217_44H1JTVV_.BKP 标记 = TAG20080605T142217
通道 ORA_DISK_1: 恢复完成, 用时: 00:00:02
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_16_44HB9609_.ARC 线程 =1 序列 =16
通道 default: 正在删除存档日志
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_16_44HB9609_.ARC 记录 ID=16 时间戳 =656614310
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_17_44HB9627_.ARC 线程 =1 序列 =17
通道 default: 正在删除存档日志
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_17_44HB9627_.ARC 记录 ID=15 时间戳 =656614310
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_18_44H1Z3FW_.ARC 线程 =1 序列 =18
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_19_44H1Z26L_.ARC 线程 =1 序列 =19
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_20_44H1Z2PO_.ARC 线程 =1 序列 =20
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_1_44H263WN_.ARC 线程 =1 序列 =1
存档日志文件名 =D:\ORACLE\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_05\O1_MF_1
_2_44H2FD3T_.ARC 线程 =1 序列 =2
存档日志文件名 =D:\ORACLE\ORADATA\ORCL\REDO01.LOG 线程 =1 序列 =1
创建数据文件 fno = 6 名称 = D:\UNDO01.DBF
存档日志文件名 =D:\ORACLE\ORADATA\ORCL\REDO01.LOG 线程 =1 序列 =1
介质恢复完成, 用时: 00:00:06
完成 recover 于 05-6月 -08
RMAN> alter database open resetlogs;
数据库已打开
RMAN> exit

恢复管理器完成。
F:\oracle\product\10.2.0\db_1\BIN>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 6月 5 16:53:20 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select count(*) from test;
COUNT(*)
----------
90056
SQL>

resetlogs后新增的数据也增加上了 数据一致

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】