丢失全部数据文件,控制文件,redo log file(9201)——处理方法三

丢失全部数据文件,控制文件,redo log file9201

 

 

 

 

作者:张大鹏(Lunar

                           Email:  moonlunar@163.com

                            MSN:  lunar52@hotmail.com

 

 

 

 

 

 

使用备份的控制文件(冷备)恢复

做冷备份前的测试数据

C:/>sqlplus "/ as sysdba"

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 23:20:52 2002

 

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

 

 

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

SQL>  archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            e:/oracle/oradata/test/archive

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

SQL> conn lunar/lunar

Connected.

SQL>  select * from test;

 

no rows selected

 

SQL>

 

冷备数据库

SQL> conn / as sysdba

Connected.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            e:/oracle/oradata/test/archive

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

SQL> exit

Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

 

单开一个窗口做冷备

C:/>d:

 

D:/>cd D:/clonedb

 

D:/clonedb>cold_backup.bat > cold_backup.log

 

D:/clonedb>

 

查看冷备日志

 

 

D:/clonedb>echo Begin Cold_Backup Database...

Begin Cold_Backup Database...

 

D:/clonedb>date /t

2002-02-05 星期二

 

D:/clonedb>time /t

23:22

 

D:/clonedb>sqlplus "/ as sysdba" @shutdown.sql

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 23:22:24 2002

 

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

 

 

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

Connected.

Database closed.

Database dismounted.

ORACLE instance shut down.

ORACLE instance started.

 

Total System Global Area  135338868 bytes

Fixed Size                   453492 bytes

Variable Size             109051904 bytes

Database Buffers       25165824 bytes

Redo Buffers              667648 bytes

Database mounted.

Database opened.

Database closed.

Database dismounted.

ORACLE instance shut down.

Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

D:/clonedb>copy E:/oracle/ora92/test/*.* d:/clonedb

E:/oracle/ora92/test/cold_backup.bat

E:/oracle/ora92/test/shutdown.sql

E:/oracle/ora92/test/startup.sql

E:/oracle/ora92/test/cold_backup.log

E:/oracle/ora92/test/CONTROL03.CTL

E:/oracle/ora92/test/REDO01.LOG

E:/oracle/ora92/test/REDO02.LOG

E:/oracle/ora92/test/REDO03.LOG

E:/oracle/ora92/test/REDO04A.LOG

E:/oracle/ora92/test/REDO04B.LOG

E:/oracle/ora92/test/SYSTEM01.DBF

E:/oracle/ora92/test/UNDOTBS01.DBF

E:/oracle/ora92/test/DRSYS01.DBF

E:/oracle/ora92/test/INDX01.DBF

E:/oracle/ora92/test/TOOLS01.DBF

E:/oracle/ora92/test/USERS01.DBF

E:/oracle/ora92/test/XDB01.DBF

E:/oracle/ora92/test/RMAN01.DBF

E:/oracle/ora92/test/CONTROL02.CTL

E:/oracle/ora92/test/test_ora_1024.trc

E:/oracle/ora92/test/TEMP01.DBF

E:/oracle/ora92/test/PWDtest.ORA

E:/oracle/ora92/test/test_ora_1800.trc

已复制        22 个文件。

 

D:/clonedb>copy E:/oracle/ora92/database/PWDtest.ORA d:/clonedb

已复制         1 个文件。

 

D:/clonedb>copy E:/oracle/oradata/test/archive d:/clonedb/archive

E:/oracle/oradata/test/archive/*

已复制         0 个文件。

 

D:/clonedb>sqlplus "/ as sysdba" @startup.sql

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 23:26:37 2002

 

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

 

Connected to an idle instance.

 

Connected to an idle instance.

ORACLE instance started.

 

Total System Global Area  135338868 bytes

Fixed Size                   453492 bytes

Variable Size            109051904 bytes

Database Buffers       25165824 bytes

Redo Buffers              667648 bytes

Database mounted.

Database opened.

 

System altered.

 

 

Database altered.

 

 

System altered.

 

Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

D:/clonedb>date /t

2002-02-05 星期二

 

D:/clonedb>time /t

23:26

 

D:/clonedb>echo The Cold Backup Database Successed. 

The Cold Backup Database Successed.

 

制作冷备份后的测试数据

提交部分测试数据(备份后增加的)

SQL> conn lunar/lunar

Connected.

SQL> select * from test;

 

no rows selected

 

SQL>  insert into test values(25);

 

1 row created.

 

SQL> insert into test values(26);

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> insert into test values(27);

 

1 row created.

 

SQL> select * from test;

        25

        26

        27

 

3 rows selected.

 

SQL>

 

 

再开一个窗口,产生检查点

Microsoft Windows 2000 [Version 5.00.2195]

(C) 版权所有 1985-2000 Microsoft Corp.

 

C:/>set nls_lang=AMERICAN_AMERICA.US7ASCII

 

C:/>sqlplus "/ as sysdba"

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 21:28:47 2002

 

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

 

 

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

 

SQL> alter system checkpoint;

 

System altered.

 

SQL>

 

回到原来的窗口,继续添加数据

SQL> insert into test values(28);

 

1 row created.

 

SQL>

 

 

回到as sysdba的窗口,switch logfile

SQL> alter system switch logfile;

 

System altered.

 

SQL>  archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            e:/oracle/oradata/test/archive

Oldest online log sequence     1

Next log sequence to archive   2

Current log sequence           2

SQL>

 

 

回到原来的窗口,commit后,继续添加数据

SQL> commit;

 

Commit complete.

 

SQL> insert into test values(29);

 

1 row created.

 

SQL>

 

回到as sysdba的窗口,产生检查点

SQL>  alter system checkpoint;

 

System altered.

 

SQL>

 

 

 

回到原来的窗口,不commit继续添加数据

 

SQL> insert into test values(30);

 

1 row created.

 

SQL> select * from test;

        25           (new datas after cold backup)

        26          

( commit )

        27   

(checkpoint )

        28

                            ( switch logfile )

                            (commit )

        29

                            (checkpoint )

        30

                            ( shutdown abort)

8 rows selected.

 

SQL>

只能恢复到switch logfile前全部commit的数据,即:26

 

回到as sysdba的窗口,模拟数据库crash

SQL> shutdown abort

ORACLE instance shut down.

SQL>

 

 

删除所有数据库文件(数据文件,控制文件,redo log file

SQL> host

Microsoft Windows 2000 [Version 5.00.2195]

(C) 版权所有 1985-2000 Microsoft Corp.

 

C:/>del E:/oracle/ora92/test/*.*

E:/oracle/ora92/test/*.*, 是否确认 (Y/N) ? y

 

C:/>dir E:/oracle/ora92/test

 驱动器 E 中的卷是 ORACLE

 卷的序列号是 707A-C50C

 

 E:/oracle/ora92/test 的目录

 

2002-01-13  21:59       <DIR>          .

2002-01-13  21:59       <DIR>          ..

               0 个文件              0 字节

               2 个目录  2,802,413,568 可用字节

 

C:/>sqlplus "/ as sysdba"

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 22:55:33 2002

 

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

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  135338868 bytes

Fixed Size                   453492 bytes

Variable Size             109051904 bytes

Database Buffers           25165824 bytes

Redo Buffers                 667648 bytes

ORA-00205: error in identifying controlfile, check alert log for more info

 

 

SQL>

 

SQL> shutdown abort

ORACLE instance shut down.

SQL>

 

 

恢复数据库

将最近的冷备拷贝过来

 

SQL> host

Microsoft Windows 2000 [Version 5.00.2195]

(C) 版权所有 1985-2000 Microsoft Corp.

 

C:/>copy D:/clonedb/*.* E:/oracle/ora92/test

D:/clonedb/cold_backup.bat

D:/clonedb/shutdown.sql

D:/clonedb/startup.sql

D:/clonedb/cold_backup.log

D:/clonedb/CONTROL03.CTL

D:/clonedb/REDO01.LOG

D:/clonedb/REDO02.LOG

D:/clonedb/REDO03.LOG

D:/clonedb/REDO04A.LOG

D:/clonedb/REDO04B.LOG

D:/clonedb/SYSTEM01.DBF

D:/clonedb/UNDOTBS01.DBF

D:/clonedb/DRSYS01.DBF

D:/clonedb/INDX01.DBF

D:/clonedb/TOOLS01.DBF

D:/clonedb/USERS01.DBF

D:/clonedb/XDB01.DBF

D:/clonedb/RMAN01.DBF

D:/clonedb/CONTROL02.CTL

D:/clonedb/test_ora_1024.trc

D:/clonedb/TEMP01.DBF

D:/clonedb/PWDtest.ORA

D:/clonedb/test_ora_1800.trc

已复制        23 个文件。

 

C:/>del E:/oracle/ora92/test/REDO0*.*

 

C:/>dir E:/oracle/ora92/test/

 驱动器 E 中的卷是 ORACLE

 卷的序列号是 707A-C50C

 

 E:/oracle/ora92/test 的目录

 

2002-01-13  21:59       <DIR>          .

2002-01-13  21:59       <DIR>          ..

2002-02-05  22:41                  340 cold_backup.bat

2002-02-05  11:28                   72 shutdown.sql

2002-02-05  12:19                  281 startup.sql

2002-02-05  22:49                2,949 cold_backup.log

2002-02-05  22:45            1,875,968 CONTROL03.CTL

2002-02-05  22:45          367,009,792 SYSTEM01.DBF

2002-02-05  22:45           52,436,992 UNDOTBS01.DBF

2002-02-05  22:45          104,865,792 DRSYS01.DBF

2002-02-05  22:45           31,465,472 INDX01.DBF

2002-02-05  22:45           31,465,472 TOOLS01.DBF

2002-02-05  22:45           31,465,472 USERS01.DBF

2002-02-05  22:45           52,436,992 XDB01.DBF

2002-02-05  22:45           52,436,992 RMAN01.DBF

2002-02-05  22:45            1,875,968 CONTROL02.CTL

2002-02-05  22:07                4,905 test_ora_1024.trc

2002-02-05  22:27           20,979,712 TEMP01.DBF

2002-02-05  21:49                3,072 PWDtest.ORA

2002-02-05  22:49                5,416 test_ora_1800.trc

              18 个文件    748,331,659 字节

               2 个目录  2,054,361,088 可用字节

 

C:/>

 

 

装载但不打开数据库

Microsoft Windows 2000 [Version 5.00.2195]

(C) 版权所有 1985-2000 Microsoft Corp.

 

C:/>set nls_lang=AMERICAN_AMERICA.US7ASCII

 

C:/>sqlplus "/ as sysdba"

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Feb 5 20:58:25 2002

 

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

 

Connected to an idle instance.

 

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  135338868 bytes

Fixed Size                   453492 bytes

Variable Size             109051904 bytes

Database Buffers           25165824 bytes

Redo Buffers                 667648 bytes

SQL> alter database mount;

 

Database altered.

 

SQL>

 

 

使用using backup controlfile恢复数据库

SQL> recover database;

ORA-00283: recovery session canceled due to errors

ORA-00264: no recovery required

SQL>

 

注意

?         如果此时把冷备的redo log file也拷贝回来,则可以打开数据库(alter database open;),但是冷备后的数据全部都丢失了,即,数据库打开后,test表为空。操作过程如下:

SQL> alter database open;

 

Database altered.

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            e:/oracle/oradata/test/archive

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

SQL> conn lunar/lunar

Connected.

SQL> select * from test;

 

no rows selected

 

SQL>

 

?         如果此时不使用using backup controlfile恢复数据库。不能直接open,因为没有redo log file(此时没有把冷备的redo log file 拷贝回来)。操作过程如下:

 

SQL> recover database using backup controlfile;

ORA-00279: change 1089259 generated at 02/05/2002 22:45:48 needed for thread 1

ORA-00289: suggestion : E:/ORACLE/ORADATA/TEST/ARCHIVE/1_1.ARC

ORA-00280: change 1089259 for thread 1 is in sequence #1

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 1089438 generated at 02/05/2002 22:52:46 needed for thread 1

ORA-00289: suggestion : E:/ORACLE/ORADATA/TEST/ARCHIVE/1_2.ARC

ORA-00280: change 1089438 for thread 1 is in sequence #2

ORA-00278: log file 'E:/ORACLE/ORADATA/TEST/ARCHIVE/1_1.ARC' no longer needed

for this recovery

 

 

ORA-00328: archived log ends at change 1088611, need later change 1089438

ORA-00334: archived log: 'E:/ORACLE/ORADATA/TEST/ARCHIVE/1_2.ARC'

 

 

SQL>

 

 

使用until cancel using backup controlfile再次恢复

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01113: file 1 needs media recovery

ORA-01110: data file 1: 'E:/ORACLE/ORA92/TEST/SYSTEM01.DBF'

 

 

SQL> recover database until cancel using backup controlfile;

ORA-00279: change 1089438 generated at 02/05/2002 22:52:46 needed for thread 1

ORA-00289: suggestion : E:/ORACLE/ORADATA/TEST/ARCHIVE/1_2.ARC

ORA-00280: change 1089438 for thread 1 is in sequence #2

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

SQL>

 

请注意此时的数据库文件的更新时间等状态:

SQL> host dir E:/oracle/ora92/test

 驱动器 E 中的卷是 ORACLE

 卷的序列号是 707A-C50C

 

 E:/oracle/ora92/test 的目录

 

2002-01-13  21:59       <DIR>          .

2002-01-13  21:59       <DIR>          ..

2002-02-05  22:41                  340 cold_backup.bat

2002-02-05  11:28                   72 shutdown.sql

2002-02-05  12:19                  281 startup.sql

2002-02-05  22:49                2,949 cold_backup.log

2002-02-05  22:45            1,875,968 CONTROL03.CTL

2002-02-05  23:04          367,009,792 SYSTEM01.DBF

2002-02-05  23:04           52,436,992 UNDOTBS01.DBF

2002-02-05  23:04          104,865,792 DRSYS01.DBF

2002-02-05  23:04           31,465,472 INDX01.DBF

2002-02-05  23:04           31,465,472 TOOLS01.DBF

2002-02-05  23:04           31,465,472 USERS01.DBF

2002-02-05  23:04           52,436,992 XDB01.DBF

2002-02-05  23:04           52,436,992 RMAN01.DBF

2002-02-05  22:45            1,875,968 CONTROL02.CTL

2002-02-05  22:07                4,905 test_ora_1024.trc

2002-02-05  22:27           20,979,712 TEMP01.DBF

2002-02-05  21:49                3,072 PWDtest.ORA

2002-02-05  22:49                5,416 test_ora_1800.trc

              18 个文件    748,331,659 字节

               2 个目录  2,054,344,704 可用字节

 

SQL>

 

使用resetlogs打开数据库

SQL>  alter database open resetlogs;

 

Database altered.

 

SQL>

 

请注意此时的数据库文件的更新时间等状态:

SQL> host dir E:/oracle/ora92/test

 驱动器 E 中的卷是 ORACLE

 卷的序列号是 707A-C50C

 

 E:/oracle/ora92/test 的目录

 

2002-01-13  21:59       <DIR>          .

2002-01-13  21:59       <DIR>          ..

2002-02-05  22:41                  340 cold_backup.bat

2002-02-05  11:28                   72 shutdown.sql

2002-02-05  12:19                  281 startup.sql

2002-02-05  22:49                2,949 cold_backup.log

2002-02-05  22:45            1,875,968 CONTROL03.CTL

2002-02-05  23:06           31,457,792 REDO01.LOG

2002-02-05  23:06           31,457,792 REDO02.LOG

2002-02-05  23:06           31,457,792 REDO03.LOG

2002-02-05  23:06            1,049,088 REDO04A.LOG

2002-02-05  23:06            1,049,088 REDO04B.LOG

2002-02-05  23:06          367,009,792 SYSTEM01.DBF

2002-02-05  23:06           52,436,992 UNDOTBS01.DBF

2002-02-05  23:06          104,865,792 DRSYS01.DBF

2002-02-05  23:06           31,465,472 INDX01.DBF

2002-02-05  23:06           31,465,472 TOOLS01.DBF

2002-02-05  23:06           31,465,472 USERS01.DBF

2002-02-05  23:06           52,436,992 XDB01.DBF

2002-02-05  23:06           52,436,992 RMAN01.DBF

2002-02-05  22:45            1,875,968 CONTROL02.CTL

2002-02-05  22:07                4,905 test_ora_1024.trc

2002-02-05  22:27           20,979,712 TEMP01.DBF

2002-02-05  21:49                3,072 PWDtest.ORA

2002-02-05  22:49                5,416 test_ora_1800.trc

              23 个文件    844,803,211 字节

               2 个目录  1,957,855,232 可用字节

 

SQL>

 

 

验证恢复

SQL>  archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            e:/oracle/oradata/test/archive

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

SQL> conn lunar/lunar

Connected.

SQL> select * from test;

 

         F

----------

        25

        26

 

SQL>

丢失了部分数据commit的数据,因为那些数据是在redo中的,还没有被归档

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值