楼主: text1978

[FAQ] 冷备份还原数据库是不是不能前滚恢复?

[复制链接]
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
31#
发表于 2004-5-11 13:40 | 只看该作者
测试一也说明了恢复的时候,并不需要冷备下来的在线日志
仔细看了一遍zalbb的测试,发现我前面看漏了,他确实是指定了灾难时刻的在线日志

使用道具 举报

回复
论坛徽章:
16
ITPUB元老
日期:2006-12-29 17:11:00秀才
日期:2015-12-25 15:31:102015年新春福章
日期:2015-03-06 11:57:31沸羊羊
日期:2015-03-04 14:43:432012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412010新春纪念徽章
日期:2010-03-01 11:21:02祖国60周年纪念徽章
日期:2009-10-09 08:28:002009新春纪念徽章
日期:2009-01-04 14:52:28生肖徽章2007版:鼠
日期:2008-01-02 17:35:53
32#
发表于 2004-5-11 13:46 | 只看该作者
[QUOTE]最初由 shangym 发布
[B]测试一:
冷备份前test用户有表AA ,冷备份后删除表AA
做恢复时,仅恢复了所有的数据文件,未覆盖当前的控制文件和在线日志文件
恢复命令:recover database until cancel
恢复中指定了当前的在线日志,apply完成后用open resetlogs打开数据库
打开后表AA不存在,结果正确

这个恢复和用热备数据文件的恢复操作基本类似


你的这个恢复是建立在控制文件没有丢的情况下,如果控制文件也丢了呢?我想是否可有以下两种情况来恢复?
1、在数据库关闭状态下,restore所有的冷备份时候的文件,当然包括冷备控制文件,然后使用recover database using backup controlfile untill cancel恢复,resetlog方式打开数据库。
2、在数据库关闭的状态下,restore冷备份时候的文件,控制文件除外,然后重建控制文件,使用recover database untill cancel恢复,最后在使用resetlog方式打开数据库。

使用道具 举报

回复
论坛徽章:
314
行业板块每日发贴之星
日期:2012-07-12 18:47:29双黄蛋
日期:2011-08-12 17:31:04咸鸭蛋
日期:2011-08-18 15:13:51迷宫蛋
日期:2011-08-18 16:58:25紫蛋头
日期:2011-08-31 10:57:28ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47蜘蛛蛋
日期:2011-10-20 15:51:25迷宫蛋
日期:2011-10-29 11:12:59ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41鲜花蛋
日期:2011-11-09 20:33:30
33#
发表于 2004-5-11 13:52 | 只看该作者
2、在数据库关闭的状态下,restore冷备份时候的文件,控制文件除外,然后重建控制文件,使用recover database untill cancel恢复,最后在使用resetlog方式打开数据库。

---对于这种情况,谁能测试一下,是否还可以使用备份的归档日志恢复?

使用道具 举报

回复
论坛徽章:
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
34#
发表于 2004-5-11 13:55 | 只看该作者
重新创建控制文件是没有问题的

比使用旧的还方便,自动恢复模式下直接recover database再打开就可以了

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
35#
发表于 2004-5-11 14:00 | 只看该作者
我继续测重建控制文件情况下的恢复,稍等

使用道具 举报

回复
论坛徽章:
16
ITPUB元老
日期:2006-12-29 17:11:00秀才
日期:2015-12-25 15:31:102015年新春福章
日期:2015-03-06 11:57:31沸羊羊
日期:2015-03-04 14:43:432012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412010新春纪念徽章
日期:2010-03-01 11:21:02祖国60周年纪念徽章
日期:2009-10-09 08:28:002009新春纪念徽章
日期:2009-01-04 14:52:28生肖徽章2007版:鼠
日期:2008-01-02 17:35:53
36#
发表于 2004-5-11 14:10 | 只看该作者
最初由 biti_rainy 发布
[B]重新创建控制文件是没有问题的

比使用旧的还方便,自动恢复模式下直接recover database再打开就可以了 [/B]

老大:重新创建控制文件这种情况是否还需要最后的重作日至才能完全恢复?另外如果恢复到cancel,没有最后的重做日至,这样的话肯定要丢失部分数据。这样理解是否准确?

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
37#
发表于 2004-5-11 14:10 | 只看该作者
here,测试二
[php]
SQL> connect test/test
Connected.
SQL> create table aa (id number);

Table created.

SQL> insert into aa values(1);

1 row created.

SQL> commit;

Commit complete.

SQL> connect / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
$ ls
1_23.dbf       control02.ctl  drsys01.dbf    indx01.dbf     redo02.log     system01.dbf   tools01.dbf    user01.dbf
control01.ctl  control03.ctl  example01.dbf  redo01.log     redo03.log     temp01.dbf     undotbs01.dbf  xdb01.dbf
$ pwd
/oracle/oradata/sdb
$ cp * ../bak/
$ sqlplus '/ as sysdba'

SQL*Plus: Release 9.2.0.4.0 - Production on Tue May 11 13:54:18 2004

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  739740648 bytes
Fixed Size                   732136 bytes
Variable Size             301989888 bytes
Database Buffers          436207616 bytes
Redo Buffers                 811008 bytes
Database mounted.
Database opened.
SQL> connect test/test
Connected.
SQL> drop table aa;

Table dropped.

SQL> connect / as sysdba
Connected.
SQL> alter database backup controlfile to trace;

Database altered.

SQL> shutdown abort;
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
$ cd $ORACLE_BASE/admin/sdb/udump
$ ls
sdb_ora_15399.trc  sdb_ora_23065.trc  sdb_ora_4342.trc   sdb_ora_4496.trc
sdb_ora_22897.trc  sdb_ora_23294.trc  sdb_ora_4493.trc
$ ls -l
total 508
-rw-r-----   1 oracle   dba         1381 Apr 26 09:42 sdb_ora_15399.trc
-rw-r-----   1 oracle   dba         1573 May 11 12:46 sdb_ora_22897.trc
-rw-r-----   1 oracle   dba          741 May 11 13:01 sdb_ora_23065.trc
-rw-r-----   1 oracle   dba         4994 May 11 13:55 sdb_ora_23294.trc
-rw-r-----   1 oracle   dba       210163 Feb 26 14:22 sdb_ora_4342.trc
-rw-r-----   1 oracle   dba        15768 Feb 26 14:35 sdb_ora_4493.trc
-rw-r-----   1 oracle   dba        11703 Feb 26 14:37 sdb_ora_4496.trc
$ vi sdb_ora_23294.trc
"sdb_ora_23294.trc" 136 lines, 4994 characters
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "SDB" NORESETLOGS  ARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 113
LOGFILE
  GROUP 1 '/oracle/oradata/sdb/redo01.log'  SIZE 100M,
  GROUP 2 '/oracle/oradata/sdb/redo02.log'  SIZE 100M,
  GROUP 3 '/oracle/oradata/sdb/redo03.log'  SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oracle/oradata/sdb/system01.dbf',
  '/oracle/oradata/sdb/undotbs01.dbf',
  '/oracle/oradata/sdb/drsys01.dbf',
  '/oracle/oradata/sdb/example01.dbf',
  '/oracle/oradata/sdb/indx01.dbf',
  '/oracle/oradata/sdb/tools01.dbf',
  '/oracle/oradata/sdb/user01.dbf',
  '/oracle/oradata/sdb/xdb01.dbf'
CHARACTER SET UTF8
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/oradata/sdb/temp01.dbf'
     SIZE 41943040  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 16383M;
:q
$ cd
$ cd /oracle/oradata/sdb
$ ls
1_23.dbf       control02.ctl  drsys01.dbf    indx01.dbf     redo02.log     system01.dbf   tools01.dbf    user01.dbf
control01.ctl  control03.ctl  example01.dbf  redo01.log     redo03.log     temp01.dbf     undotbs01.dbf  xdb01.dbf
$ vi control.sql
"control.sql" [New file]
CREATE CONTROLFILE REUSE DATABASE "SDB" NORESETLOGS  ARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 113
LOGFILE
  GROUP 1 '/oracle/oradata/sdb/redo01.log'  SIZE 100M,
  GROUP 2 '/oracle/oradata/sdb/redo02.log'  SIZE 100M,
  GROUP 3 '/oracle/oradata/sdb/redo03.log'  SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oracle/oradata/sdb/system01.dbf',
  '/oracle/oradata/sdb/undotbs01.dbf',
  '/oracle/oradata/sdb/drsys01.dbf',
  '/oracle/oradata/sdb/example01.dbf',
  '/oracle/oradata/sdb/indx01.dbf',
  '/oracle/oradata/sdb/tools01.dbf',
  '/oracle/oradata/sdb/user01.dbf',
  '/oracle/oradata/sdb/xdb01.dbf'
CHARACTER SET UTF8
;
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"control.sql" [New file] 24 lines, 737 characters
$ ls
1_23.dbf       control02.ctl  example01.dbf  redo02.log     temp01.dbf     user01.dbf
control.sql    control03.ctl  indx01.dbf     redo03.log     tools01.dbf    xdb01.dbf
control01.ctl  drsys01.dbf    redo01.log     system01.dbf   undotbs01.dbf
$ mv control01.ctl control01.ctl.bak
$ rm control02.ctl control03.ctl
$ ls
1_23.dbf           drsys01.dbf        redo01.log         system01.dbf       undotbs01.dbf
control.sql        example01.dbf      redo02.log         temp01.dbf         user01.dbf
control01.ctl.bak  indx01.dbf         redo03.log         tools01.dbf        xdb01.dbf
[/php]

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
38#
发表于 2004-5-11 14:23 | 只看该作者
$ cp ../bak/*.dbf ./
$ sqlplus '/ as sysdba'

SQL*Plus: Release 9.2.0.4.0 - Production on Tue May 11 13:58:21 2004

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

Connected to an idle instance.

SQL> @control
ORACLE instance started.

Total System Global Area  739740648 bytes
Fixed Size                   732136 bytes
Variable Size             301989888 bytes
Database Buffers          436207616 bytes
Redo Buffers                 811008 bytes

Control file created.

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 19678954 generated at 05/11/2004 13:26:00 needed for thread 1
ORA-00289: suggestion : /oracle/oradata/bak/1_1.dbf
ORA-00280: change 19678954 for thread 1 is in sequence #1


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/oracle/oradata/bak/1_1.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/oracle/oradata/bak/1_1.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ---------------
         1          1          0  104857600          1 YES UNUSED
            0

         2          1          0  104857600          1 YES UNUSED
            0

         3          1          1  104857600          1 NO  INVALIDATED
     19677729 11-MAY-04


SQL> recover database using backup controlfile until cancel;
ORA-00279: change 19678954 generated at 05/11/2004 13:26:00 needed for thread 1
ORA-00289: suggestion : /oracle/oradata/bak/1_1.dbf
ORA-00280: change 19678954 for thread 1 is in sequence #1


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oracle/oradata/sdb/redo03.log
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;

Database altered.

SQL> connect test/test
Connected.
SQL> select * from aa;
select * from aa
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL>

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
39#
发表于 2004-5-11 14:27 | 只看该作者
测试二的说明
冷备份前test用户有表AA,冷备后重启数据库,删除表AA
shutdown abort之后,重建了控制文件,并用冷备的数据文件和当前的在线日志恢复成功,这里做的时候漏了归档了,所以有归档日志的话,恢复过程中也会应用归档日志

使用道具 举报

回复
论坛徽章:
314
行业板块每日发贴之星
日期:2012-07-12 18:47:29双黄蛋
日期:2011-08-12 17:31:04咸鸭蛋
日期:2011-08-18 15:13:51迷宫蛋
日期:2011-08-18 16:58:25紫蛋头
日期:2011-08-31 10:57:28ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47蜘蛛蛋
日期:2011-10-20 15:51:25迷宫蛋
日期:2011-10-29 11:12:59ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41鲜花蛋
日期:2011-11-09 20:33:30
40#
发表于 2004-5-11 14:27 | 只看该作者
你的结论是,即使是新创建的控制文件,也可以使用来恢复到数据库关闭的最后一刻?

使用道具 举报

回复

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

本版积分规则 发表回复

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