楼主: it_horse

[精华] 我想问一下:Recovery through resetlogs 的内部机理是什莫?

[复制链接]
论坛徽章:
295
ITPUB元老
日期:2005-07-25 16:09:42授权会员
日期:2005-10-30 17:05:33生肖徽章:牛
日期:2006-09-06 21:17:03生肖徽章2007版:牛
日期:2008-05-06 11:05:47生肖徽章2007版:牛
日期:2008-11-27 11:35:13生肖徽章2007版:牛
日期:2009-02-19 20:40:13生肖徽章2007版:马
日期:2009-02-25 21:19:48生肖徽章2007版:猴
日期:2009-02-27 01:40:13生肖徽章2007版:牛
日期:2009-03-10 21:26:49生肖徽章2007版:牛
日期:2009-03-10 21:33:00
11#
 楼主| 发表于 2003-4-9 10:18 | 只看该作者

B & R 1

Backup & recovery 1!

backup and recovery.part1.rar

1.39 MB, 下载次数: 393

使用道具 举报

回复
论坛徽章:
295
ITPUB元老
日期:2005-07-25 16:09:42授权会员
日期:2005-10-30 17:05:33生肖徽章:牛
日期:2006-09-06 21:17:03生肖徽章2007版:牛
日期:2008-05-06 11:05:47生肖徽章2007版:牛
日期:2008-11-27 11:35:13生肖徽章2007版:牛
日期:2009-02-19 20:40:13生肖徽章2007版:马
日期:2009-02-25 21:19:48生肖徽章2007版:猴
日期:2009-02-27 01:40:13生肖徽章2007版:牛
日期:2009-03-10 21:26:49生肖徽章2007版:牛
日期:2009-03-10 21:33:00
12#
 楼主| 发表于 2003-4-9 10:19 | 只看该作者

B & R 2!

2

backup and recovery.part2.rar

856.36 KB, 下载次数: 375

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-11-10 08:36:21ITPUB元老
日期:2005-11-10 08:36:01会员2006贡献徽章
日期:2006-04-17 13:46:34
13#
发表于 2003-4-9 10:31 | 只看该作者
为什么sansanmei贴的那个文档不能打开

使用道具 举报

回复
论坛徽章:
295
ITPUB元老
日期:2005-07-25 16:09:42授权会员
日期:2005-10-30 17:05:33生肖徽章:牛
日期:2006-09-06 21:17:03生肖徽章2007版:牛
日期:2008-05-06 11:05:47生肖徽章2007版:牛
日期:2008-11-27 11:35:13生肖徽章2007版:牛
日期:2009-02-19 20:40:13生肖徽章2007版:马
日期:2009-02-25 21:19:48生肖徽章2007版:猴
日期:2009-02-27 01:40:13生肖徽章2007版:牛
日期:2009-03-10 21:26:49生肖徽章2007版:牛
日期:2009-03-10 21:33:00
14#
 楼主| 发表于 2003-4-9 10:32 | 只看该作者

如下:

最初由 X_X 发布
[B]为什么sansanmei贴的那个文档不能打开 [/B]


http://www.*****.org/bin/ut/thre ... mp;bpg=1&age=30

把 ***** 换为 c n o u g 五个字符 即可!

使用道具 举报

回复
论坛徽章:
86
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-01-04 11:49:542012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20咸鸭蛋
日期:2012-05-08 10:27:19版主8段
日期:2012-05-15 15:24:112013年新春福章
日期:2013-02-25 14:51:24
15#
发表于 2003-4-9 10:34 | 只看该作者

模拟这个过程有一个很关键的一点

在恢复过程中使用不同    的   归档日志和控制文件


拷贝CP 的全文

1.时间点A,我做了一个全备份,

[ora9i@database rmanarch]$ rman target / nocatalog

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area 353440004 bytes

Fixed Size 450820 bytes
Variable Size 150994944 bytes
Database Buffers 201326592 bytes
Redo Buffers 667648 bytes

RMAN> run{allocate channel c3 type disk; backup database format '/backup/oracle/rmanarch/ora9i%t%s.rman';}

allocated channel: c3
channel c3: sid=13 devtype=DISK

Starting backup at 20021130 21:48:59
channel c3: starting full datafile backupset
channel c3: specifying datafile(s) in backupset
including current controlfile in backupset
input datafile fno=00001 name=/backup/oracle/oradata/system.dbf
input datafile fno=00002 name=/backup/oracle/oradata/undo1.dbf
input datafile fno=00003 name=/backup/oracle/oradata/data.dbf
channel c3: starting piece 1 at 20021130 21:49:00
channel c3: finished piece 1 at 20021130 21:49:45
piece handle=/backup/oracle/rmanarch/ora9i4793393402.rman comment=NONE
channel c3: backup set complete, elapsed time: 00:00:45
Finished backup at 20021130 21:49:45
released channel: c3

RMAN> exit

Recovery Manager complete.

由于我没有备份的recovery catalog,我单独备份了这个时候的控制文件,通过OS的拷贝命令。

2。时间点B,我做了一些transaction,
21:50:05 SQL> create table tt tablespace data as select * from dba_objects;

Table created.

Elapsed: 00:00:00.51
21:50:19 SQL> select count(*) from tt;

  COUNT(*)
----------
      5782

Elapsed: 00:00:00.01
21:50:23 SQL> alter system switch logfile;

System altered.

Elapsed: 00:00:00.04
21:50:27 SQL> /

System altered.

Elapsed: 00:00:02.54
21:50:30 SQL> /

System altered.

Elapsed: 00:00:05.13
这个时候磁盘崩溃,数据库崩溃。
21:50:37 SQL> shutdown abort

我restore database,recover database, resetlogs到时间点B之前的B':
[ora9i@database rmanarch]$ rman target / nocatalog

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: ORACLE9I (DBID=3143519835)
using target database controlfile instead of recovery catalog

RMAN> run{allocate channel c3 type disk;restore database;recover database until time '20021130 21:50:05';}

allocated channel: c3
channel c3: sid=14 devtype=DISK

Starting restore at 20021130 21:54:34

channel c3: starting datafile backupset restore
channel c3: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /backup/oracle/oradata/system.dbf
restoring datafile 00002 to /backup/oracle/oradata/undo1.dbf
restoring datafile 00003 to /backup/oracle/oradata/data.dbf
channel c3: restored backup piece 1
piece handle=/backup/oracle/rmanarch/ora9i4793393402.rman tag=TAG20021130T214859 params=NULL
channel c3: restore complete
Finished restore at 20021130 21:55:11

Starting recover at 20021130 21:55:11

starting media recovery

archive log thread 1 sequence 22 is already on disk as file /backup/oracle/product/9.2.0/dbs/arch1_22.dbf
archive log filename=/backup/oracle/product/9.2.0/dbs/arch1_22.dbf thread=1 sequence=22
media recovery complete
Finished recover at 20021130 21:55:12
released channel: c3

RMAN> alter database open resetlogs;

database opened

RMAN> exit

我检查在时间点B的事务:表TT,已经看不到了:
21:53:32 SQL> select status from v$instance;

STATUS
------------------------
OPEN

Elapsed: 00:00:00.04
21:55:41 SQL> select count(*) from tt;
select count(*) from tt
                     *
ERROR at line 1:
ORA-00942: table or view does not exist

Elapsed: 00:00:00.06
21:55:47 SQL> create table ttt tablespace data as select * from dba_objects;

Table created.

Elapsed: 00:00:00.44
21:56:05 SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /backup/oracle/product/9.2.0/dbs/arch
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
我做了一些事务,比如创建表TTT,
这个时候,我还在做online备份没有完成,或者没有做备份,但是磁盘再次崩溃,丢失了一些数据文件:

我修改initsid.ora文件,把controlfile重新指到A时间点的时候备份的控制文件。
然后我restore database, recover database到B'时间点(就是上次B崩溃的时候,我恢复到的时间点)

RMAN> run{allocate channel c3 type disk;restore database;recover database until time '20021130 21:50:05';}

allocated channel: c3
channel c3: sid=13 devtype=DISK

Starting restore at 20021130 21:57:38

channel c3: starting datafile backupset restore
channel c3: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /backup/oracle/oradata/system.dbf
restoring datafile 00002 to /backup/oracle/oradata/undo1.dbf
restoring datafile 00003 to /backup/oracle/oradata/data.dbf
channel c3: restored backup piece 1
piece handle=/backup/oracle/rmanarch/ora9i4793393402.rman tag=TAG20021130T214859 params=NULL
channel c3: restore complete
Finished restore at 20021130 21:58:15

Starting recover at 20021130 21:58:15

starting media recovery

archive log thread 1 sequence 22 is already on disk as file /backup/oracle/product/9.2.0/dbs/arch1_22.dbf
archive log filename=/backup/oracle/product/9.2.0/dbs/arch1_22.dbf thread=1 sequence=22
media recovery complete
Finished recover at 20021130 21:58:16
released channel: c3

RMAN> shutdown

database dismounted
Oracle instance shut down
这个时候,我再次修改initsid.ora文件里面的controlfile,重新指回到C时间点的控制文件,
我企图打开数据库:
[ora9i@database oradata]$ sql

SQL*Plus: Release 9.2.0.1.0 - Production on Sat Nov 30 21:58:58 2002

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.

21:58:58 SQL> startup
ORACLE instance started.

Total System Global Area 353440004 bytes
Fixed Size 450820 bytes
Variable Size 150994944 bytes
Database Buffers 201326592 bytes
Redo Buffers 667648 bytes
Database mounted.
ORA-01190: controlfile or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/backup/oracle/oradata/system.dbf'

但是报错。
我恢复数据库:

21:59:17 SQL> recover database;
Media recovery complete.
22:00:42 SQL> alter database open;

Database altered.

OK,数据库打开。我检查我在时间点C的做的事务:

Elapsed: 00:00:01.64

22:00:52 SQL> select count(*) from ttt;

  COUNT(*)
----------
      5782

Elapsed: 00:00:00.03
我们可以看到,C时间点我创建的表TTT现在还在。

recover through resetlogs 的关键,在于把数据库先恢复到B'的时间点的状态,然后再根据当前的控制文件的状态来进行恢复。

虽然这样还是再某些条件下可以恢复数据库,但是我们一般都建议,再做了resetlogs之后,马上对数据库做一个全备份。因为recover through resetlogs
还是需要一定的条件和技巧的。不是推荐的标准的备份恢复手段。

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-11-10 08:36:21ITPUB元老
日期:2005-11-10 08:36:01会员2006贡献徽章
日期:2006-04-17 13:46:34
16#
发表于 2003-4-9 10:56 | 只看该作者

Re: 模拟这个过程有一个很关键的一点

最初由 biti_rainy 发布
[B]

我修改initsid.ora文件,把controlfile重新指到A时间点的时候备份的控制文件。
然后我restore database, recover database到B'时间点(就是上次B崩溃的时候,我恢复到的时间点)

[/B]

这个时间的恢复是否是用的原来的archive log,也就是说resetlogs后archive log不能删除,是吗

使用道具 举报

回复
论坛徽章:
16
2010数据库技术大会纪念徽章
日期:2010-05-13 10:04:27ITPUB技术丛书作者
日期:2010-09-26 15:24:562011新春纪念徽章
日期:2011-01-25 15:41:01管理团队成员
日期:2011-05-07 01:45:082012新春纪念徽章
日期:2012-02-13 15:11:18马自达
日期:2014-01-27 11:47:11
17#
发表于 2003-4-9 11:00 | 只看该作者

Re: Re: 模拟这个过程有一个很关键的一点

最初由 X_X 发布
[B]
这个时间的恢复是否是用的原来的archive log,也就是说resetlogs后archive log不能删除,是吗 [/B]

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2005-11-10 08:36:21ITPUB元老
日期:2005-11-10 08:36:01会员2006贡献徽章
日期:2006-04-17 13:46:34
18#
发表于 2003-4-9 11:07 | 只看该作者
谢谢

使用道具 举报

回复
论坛徽章:
295
ITPUB元老
日期:2005-07-25 16:09:42授权会员
日期:2005-10-30 17:05:33生肖徽章:牛
日期:2006-09-06 21:17:03生肖徽章2007版:牛
日期:2008-05-06 11:05:47生肖徽章2007版:牛
日期:2008-11-27 11:35:13生肖徽章2007版:牛
日期:2009-02-19 20:40:13生肖徽章2007版:马
日期:2009-02-25 21:19:48生肖徽章2007版:猴
日期:2009-02-27 01:40:13生肖徽章2007版:牛
日期:2009-03-10 21:26:49生肖徽章2007版:牛
日期:2009-03-10 21:33:00
19#
 楼主| 发表于 2003-4-9 11:21 | 只看该作者

Oracle 的解释!

Recovering a Pre-RESETLOGS Backup
In pre-Oracle8i releases, DBAs typically backed up online logs when performing cold consistent backups to avoid opening the database with the RESETLOGS option (if they were planning to restore immediately).

A classic example of this technique was disk maintenance, which required the database to be backed up, deleted, the disks reconfigured, and the database restored. DBAs realized that by not restarting in RESETLOGS mode, they would not have to perform a whole database backup immediately after the database was restored. This backup was required since it was impossible to perform recovery using a backup taken before using RESETLOGS--especially if any errors occurred after resetting the logs.

In Oracle version 8 and higher, there is only one situation in which you can use a pre-RESETLOGS backup to roll forward--if you have a consistent backup of the database, taken immediately before you open the database with the RESETLOGS option, and a control file that is valid after you open the database with RESETLOGS. It is then unnecessary to back up or restore online redo logs.

使用道具 举报

回复
论坛徽章:
295
ITPUB元老
日期:2005-07-25 16:09:42授权会员
日期:2005-10-30 17:05:33生肖徽章:牛
日期:2006-09-06 21:17:03生肖徽章2007版:牛
日期:2008-05-06 11:05:47生肖徽章2007版:牛
日期:2008-11-27 11:35:13生肖徽章2007版:牛
日期:2009-02-19 20:40:13生肖徽章2007版:马
日期:2009-02-25 21:19:48生肖徽章2007版:猴
日期:2009-02-27 01:40:13生肖徽章2007版:牛
日期:2009-03-10 21:26:49生肖徽章2007版:牛
日期:2009-03-10 21:33:00
20#
 楼主| 发表于 2003-4-9 11:23 | 只看该作者

续:

Perform Whole Database Backups After Using the RESETLOGS Option
After you have opened a database with the RESETLOGS option, Oracle recommends that you immediately perform a whole database backup. If you do not, and a disaster occurs, then you will lose all work performed since opening the database.

When you open a database with the RESETLOGS option, Oracle automatically:

Creates a new incarnation of the database, putting a new RESETLOGS SCN in the headers of all database files.

Resets the log sequence number to 1.

Reformats the online redo log files if they exist, and otherwise creates them.

Oracle performs these actions so that it can identify which archived redo logs apply to which incarnations of the database.

The resetting of the online redo logs has severe consequences for your backup and recovery strategy. As a rule, you cannot restore pre-RESETLOGS backups, so all your old backups are worthless in the new incarnation. The only exceptions are:

Backups of read-only tablespaces that were not made read-write again before the RESETLOGS.

Backups of offline normal tablespaces that were not brought online again before the RESETLOGS.

Backups of read-write tablespaces made after an incomplete recovery and immediately before the RESETLOGS.

使用道具 举报

回复

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

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表