ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman的恢复测试

rman的恢复测试

原创 Linux操作系统 作者:mugen 时间:2019-03-08 19:00:08 0 删除 编辑

最近完成了在linux下模拟数据文件损坏和误删除表的恢复。


Rman恢复测试

                                                                            

 

针对上周已经对备用平台(皇岗应急平台)数据库的备份,从备份的目的出发,备份是为了恢复的,所有接下来对测试平台数据库进行了恢复的测试

 

 

测试目的:确定使用rman进行全备份的可用性和可恢复性

测试环境:目标数据库

                RMAN 数据库 10.98.33.3

模拟的灾难: 数据文件的损坏;表的误删除

 

测试步骤:

第一步:

将测试平台数据库运行模式从非归档模式修改为归档模式

第二步

在rman上把测试平台数据库注册为目标数据库

第三步

在测试平台数据库上做一个job,让它每天产生一定的记录

第四步

对测试平台数据库进行全备份

第五步

在测试平台数据库上模拟文件损坏,误删除等的恢复

第六步:

将某个测试表故意删除,模拟表误删除的操作。

 

恢复过程:

 

下面为使用rman进行全备份以及模拟文件损坏的恢复过程

 

 

 文件损坏的恢复

 

[oracle@dbtest bin]$ ./rman target system/password@oldhg catalog rman/rman

 

Recovery Manager: Release 9.2.0.1.0 - Production

 

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

 

connected to target database: ITOWN01 (DBID=2824908530)

connected to recovery catalog database

 

RMAN> register database;   ###注册目标数据库到catalog中########

 

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@dbtest bin]$ ./rman target system/manager@hgbak catalog rman/rman

 

Recovery Manager: Release 9.2.0.1.0 - Production

 

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

 

connected to target database: ITOWN01 (DBID=2816967210)

connected to recovery catalog database

 

RMAN> register database; ### 如果注册已经注册了的目标数据库,就会报错

 

 

RMAN-00571: ===========================================================

RMAN-00569: ============ ERROR MESSAGE STACK FOLLOWS

 

RMAN-00571: ===========================================================

RMAN-03009: failure of register command on default channel at 10/26/2004 10:08:38

RMAN-20002: target database already registered in recovery catalog

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@dbtest bin]$ ./rman target system/password@oldhg catalog rman/rman

 

Recovery Manager: Release 9.2.0.1.0 - Production

 

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

 

connected to target database: ITOWN01 (DBID=2824908530)

connected to recovery catalog database

 

RMAN>   #####开始进行全备份##############

Starting backup at 26-OCT-04

starting full resync of recovery catalog

full resync complete

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=25 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current SPFILE in backupset

including current controlfile in backupset

input datafile fno=00001 name=/u01/product/oradata/itown01/system01.dbf

input datafile fno=00002 name=/u01/product/oradata/itown01/undotbs01.dbf

input datafile fno=00006 name=/u01/product/oradata/itown01/EPORT_TAB_L_01.dbf

input datafile fno=00009 name=/u01/product/oradata/itown01/EPORT_TAB_S_01.dbf

input datafile fno=00005 name=/u01/product/oradata/itown01/TEST.dbf

input datafile fno=00010 name=/u01/product/oradata/itown01/xdb01.dbf

input datafile fno=00011 name=/u01/product/oradata/itown01/EPORT_IDX_L_01.dbf

input datafile fno=00003 name=/u01/product/oradata/itown01/cwmlite01.dbf

input datafile fno=00004 name=/u01/product/oradata/itown01/drsys01.dbf

input datafile fno=00007 name=/u01/product/oradata/itown01/odm01.dbf

input datafile fno=00012 name=/u01/product/oradata/itown01/EPORT_IDX_S_01.dbf

input datafile fno=00008 name=/u01/product/oradata/itown01/tools01.dbf

channel ORA_DISK_1: starting piece 1 at 26-OCT-04

channel ORA_DISK_1: finished piece 1 at 26-OCT-04

piece handle=/u01/backup/full_01g3gh8b_1_1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:20

Finished backup at 26-OCT-04

 

RMAN> delete obsolete; #####删除冗余的不需要的归档和备份###########

 

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type                 Key    Completion Time    Filename/Handle

-------------------- ------ ------------------ --------------------

Archive Log          1239   26-OCT-04          /u01/arch/1_4419.dbf

Archive Log          1238   26-OCT-04          /u01/arch/1_4418.dbf

Archive Log          1237   26-OCT-04          /u01/arch/1_4417.dbf

Archive Log          1236   26-OCT-04          /u01/arch/1_4416.dbf

Archive Log          1235   26-OCT-04          /u01/arch/1_4415.dbf

Archive Log          1234   26-OCT-04          /u01/arch/1_4414.dbf

Archive Log          1233   26-OCT-04          /u01/arch/1_4413.dbf

Archive Log          1232   26-OCT-04          /u01/arch/1_4412.dbf

Archive Log          1231   26-OCT-04          /u01/arch/1_4411.dbf

Archive Log          1230   26-OCT-04          /u01/arch/1_4410.dbf

Archive Log          1229   26-OCT-04          /u01/arch/1_4409.dbf

Archive Log          1228   26-OCT-04          /u01/arch/1_4408.dbf

Archive Log          1203   26-OCT-04          /u01/arch/1_4407.dbf

Archive Log          1202   26-OCT-04          /u01/arch/1_4406.dbf

Archive Log          1201   26-OCT-04          /u01/arch/1_4405.dbf

Archive Log          1200   26-OCT-04          /u01/arch/1_4404.dbf

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted archive log

archive log filename=/u01/arch/1_4419.dbf recid=16 stamp=540557433

deleted archive log

archive log filename=/u01/arch/1_4418.dbf recid=15 stamp=540557199

deleted archive log

archive log filename=/u01/arch/1_4417.dbf recid=14 stamp=540557182

deleted archive log

archive log filename=/u01/arch/1_4416.dbf recid=13 stamp=540557177

deleted archive log

archive log filename=/u01/arch/1_4415.dbf recid=12 stamp=540557132

deleted archive log

archive log filename=/u01/arch/1_4414.dbf recid=11 stamp=540557128

deleted archive log

archive log filename=/u01/arch/1_4413.dbf recid=10 stamp=540557124

deleted archive log

archive log filename=/u01/arch/1_4412.dbf recid=9 stamp=540557122

deleted archive log

archive log filename=/u01/arch/1_4411.dbf recid=8 stamp=540556718

deleted archive log

archive log filename=/u01/arch/1_4410.dbf recid=7 stamp=540555361

deleted archive log

archive log filename=/u01/arch/1_4409.dbf recid=6 stamp=540555356

deleted archive log

archive log filename=/u01/arch/1_4408.dbf recid=5 stamp=540555351

deleted archive log

archive log filename=/u01/arch/1_4407.dbf recid=4 stamp=540554041

deleted archive log

archive log filename=/u01/arch/1_4406.dbf recid=3 stamp=540554039

deleted archive log

archive log filename=/u01/arch/1_4405.dbf recid=2 stamp=540553921

deleted archive log

archive log filename=/u01/arch/1_4404.dbf recid=1 stamp=540553492

Deleted 16 objects

 

 

##########整个恢复过程###############

 [oracle@ciqdz oracle]$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Oct 26 13:11:44 2004

 

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

 

SQL> connect test/test;

Connected.

 

SQL> select count(*) from object;

 

  COUNT(*)

----------

     57934

 

SQL> select count(*) from test;

 

  COUNT(*)

----------

     28932

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

[oracle@ciqdz itown01]$ ls -l

total 1100148

-rw-r-----    1 oracle   dba      24125440 Oct 26 13:16 EPORT_IDX_L_01.dbf

-rw-r-----    1 oracle   dba       8396800 Oct 26 13:16 EPORT_IDX_S_01.dbf

-rw-r-----    1 oracle   dba      115351552 Oct 26 13:16 EPORT_TAB_L_01.dbf

-rw-r-----    1 oracle   dba      104865792 Oct 26 13:16 EPORT_TAB_S_01.dbf

-rw-r-----    1 oracle   dba      52436992 Oct 26 13:16 TEST.dbf

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:16 control01.ctl

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:16 control02.ctl

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:16 control03.ctl

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:16 cwmlite01.dbf

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:16 drsys01.dbf

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:16 odm01.dbf

-rw-r-----    1 oracle   dba       1049088 Oct 26 13:12 redo04.log

-rw-r-----    1 oracle   dba       1049088 Oct 26 13:16 redo05.log

-rw-r-----    1 oracle   dba       1049088 Oct 26 12:53 redo06.log

-rw-r--r--    1 oracle   dba      440410112 Oct 26 13:16 system01.dbf

-rw-r--r--    1 oracle   dba      41951232 Jul 29 17:48 temp01.dbf

-rw-r--r--    1 oracle   dba       5251072 Oct 26 13:16 tools01.dbf

-rw-r--r--    1 oracle   dba      256909312 Oct 26 13:16 undotbs01.dbf

-rw-r--r--    1 oracle   dba      39985152 Oct 26 13:16 xdb01.dbf

SQL> select count(*) from test;

 

  COUNT(*)

----------

     28933

 

SQL> alter system switch logfile;

 

System altered.

 

SQL> connect / as sysdba;

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

 

#########删除数据文件来模拟文件损坏#######

 

 [oracle@ciqdz itown01]$ cp TEST.dbf TEST.dbf.BAK ##做个操作系统级别的备份

 

 [oracle@ciqdz itown01]$ rm TEST.dbf #######删除物理文件

rm: remove `TEST.dbf'? y

 

########打开数据库报错#########

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  370217240 bytes

Fixed Size                   450840 bytes

Variable Size             201326592 bytes

Database Buffers          167772160 bytes

Redo Buffers                 667648 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 5 - see DBWR trace file

ORA-01110: data file 5: '/u01/product/oradata/itown01/TEST.dbf'

 

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 5 - see DBWR trace file

ORA-01110: data file 5: '/u01/product/oradata/itown01/TEST.dbf'

 

SQL> alter database datafile 5 offline drop;

Database altered.

SQL> alter database open;

Database altered.

 

开始准备使用rman恢复

 

##连接到恢复目录已经目标数据库

 [oracle@dbtest bin]$ ./rman target system/manager@oldhg catalog rman/rman

Recovery Manager: Release 9.2.0.1.0 - Production

 

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

 

connected to target database: ITOWN01 (DBID=2824908530)

connected to recovery catalog database

 

恢复五号文件

 

RMAN> run{

2> allocate channel c1 type disk;

3> restore datafile 5;

4> recover datafile 5;

5> sql 'alter database datafile 5 online';

6> release channel c1;

7> }

 

allocated channel: c1

channel c1: sid=26 devtype=DISK

 

Starting restore at 26-OCT-04

 

channel c1: starting datafile backupset restore

channel c1: specifying datafile(s) to restore from backup set

restoring datafile 00005 to /u01/product/oradata/itown01/TEST.dbf

channel c1: restored backup piece 1

piece handle=/u01/backup/full_01g3gh8b_1_1 tag=OLDHG_BACKUP params=NULL

channel c1: restore complete

Finished restore at 26-OCT-04

 

Starting recover at 26-OCT-04

 

starting media recovery

#########应用归档日志###########

archive log thread 1 sequence 4420 is already on disk as file /u01/arch/1_4420.dbf

archive log thread 1 sequence 4421 is already on disk as file /u01/arch/1_4421.dbf

archive log thread 1 sequence 4422 is already on disk as file /u01/arch/1_4422.dbf

archive log thread 1 sequence 4423 is already on disk as file /u01/arch/1_4423.dbf

archive log filename=/u01/arch/1_4420.dbf thread=1 sequence=4420

archive log filename=/u01/arch/1_4421.dbf thread=1 sequence=4421

media recovery complete

Finished recover at 26-OCT-04

##########完成恢复##############

sql statement: alter database datafile 5 online

 

##########打开文件##############

released channel: c1

 

RMAN>

 

###########重新连接到数据库######

 

SQL> connect test/test;

Connected.

SQL> select count(*) from test;

 

  COUNT(*)

----------

     28934

 

SQL> select count(*) from object;

 

  COUNT(*)

----------

     57939

 

 

 

[oracle@ciqdz itown01]$ ls -l

total 1202676

-rw-r-----    1 oracle   dba      24125440 Oct 26 13:29 EPORT_IDX_L_01.dbf

-rw-r-----    1 oracle   dba       8396800 Oct 26 13:29 EPORT_IDX_S_01.dbf

-rw-r-----    1 oracle   dba      115351552 Oct 26 13:29 EPORT_TAB_L_01.dbf

-rw-r-----    1 oracle   dba      104865792 Oct 26 13:29 EPORT_TAB_S_01.dbf

-rw-r-----    1 oracle   dba      52436992 Oct 26 13:33 TEST.dbf

-rw-r-----    1 oracle   dba      52436992 Oct 26 13:26 TEST.dbf.BAK

-rw-r-----    1 oracle   dba      52436992 Oct 26 13:27 TESTBAK.dbf

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:34 control01.ctl

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:34 control02.ctl

-rw-r-----    1 oracle   dba       2072576 Oct 26 13:34 control03.ctl

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:29 cwmlite01.dbf

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:29 drsys01.dbf

-rw-r--r--    1 oracle   dba      10493952 Oct 26 13:29 odm01.dbf

-rw-r-----    1 oracle   dba       1049088 Oct 26 13:29 redo04.log

-rw-r-----    1 oracle   dba       1049088 Oct 26 13:29 redo05.log

-rw-r-----    1 oracle   dba       1049088 Oct 26 13:34 redo06.log

-rw-r--r--    1 oracle   dba      440410112 Oct 26 13:29 system01.dbf

-rw-r--r--    1 oracle   dba      41951232 Jul 29 17:48 temp01.dbf

-rw-r--r--    1 oracle   dba       5251072 Oct 26 13:29 tools01.dbf

-rw-r--r--    1 oracle   dba      256909312 Oct 26 13:29 undotbs01.dbf

-rw-r--r--    1 oracle   dba      39985152 Oct 26 13:29 xdb01.dbf

 

 

我们可以看到重新生成了TEST.dbf文件

恢复成功!

 

误删除表的恢复

 

 

先说明一下误删除表的恢复思路,

比如我们今天突然发现昨天删除了一个表,而且这个表很重要,我们肯定不可以恢复到昨天的时刻,因为还有其它的业务表做了很多事务。首先,我们把数据库关闭,做一个全备份,然后只能先恢复到昨天删除表的时刻,把这个表导出来,接着,使用刚才做的全备份,把数据库还原到现在的时刻,然后在把表导入。

 

以上方法适合于表空间的误删除,用户的删除!

 

11点45分误删除了表test

那么,现在我们先恢复到11.45分

 

 [oracle@dbtest bin]$ ./rman target system/manager@oldhg catalog rman/rman

 

Recovery Manager: Release 9.2.0.1.0 - Production

 

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

 

connected to target database: ITOWN01 (DBID=2824908530)

connected to recovery catalog database

 

RMAN> run{

2> set until time "to_date('10/27/2004 11:45:00','mm/dd/yyyy hh24:mi:ss')";

3> restore database;

4> recover database;

5> alter database open resetlogs;

6> }

 

executing command: SET until clause

 

Starting restore at 27-OCT-04

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=14 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/product/oradata/itown01/system01.dbf

restoring datafile 00002 to /u01/product/oradata/itown01/undotbs01.dbf

restoring datafile 00003 to /u01/product/oradata/itown01/cwmlite01.dbf

restoring datafile 00004 to /u01/product/oradata/itown01/drsys01.dbf

restoring datafile 00005 to /u01/product/oradata/itown01/TEST.dbf

restoring datafile 00006 to /u01/product/oradata/itown01/EPORT_TAB_L_01.dbf

restoring datafile 00007 to /u01/product/oradata/itown01/odm01.dbf

restoring datafile 00008 to /u01/product/oradata/itown01/tools01.dbf

restoring datafile 00009 to /u01/product/oradata/itown01/EPORT_TAB_S_01.dbf

restoring datafile 00010 to /u01/product/oradata/itown01/xdb01.dbf

restoring datafile 00011 to /u01/product/oradata/itown01/EPORT_IDX_L_01.dbf

restoring datafile 00012 to /u01/product/oradata/itown01/EPORT_IDX_S_01.dbf

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/full_01g3gh8b_1_1 tag=OLDHG_BACKUP params=NULL

channel ORA_DISK_1: restore complete

Finished restore at 27-OCT-04

 

Starting recover at 27-OCT-04

using channel ORA_DISK_1

 

starting media recovery

 

archive log thread 1 sequence 4420 is already on disk as file /u01/arch/1_4420.dbf

archive log thread 1 sequence 4421 is already on disk as file /u01/arch/1_4421.dbf

archive log thread 1 sequence 4422 is already on disk as file /u01/arch/1_4422.dbf

archive log thread 1 sequence 4423 is already on disk as file /u01/arch/1_4423.dbf

archive log thread 1 sequence 4424 is already on disk as file /u01/arch/1_4424.dbf

archive log thread 1 sequence 4425 is already on disk as file /u01/arch/1_4425.dbf

archive log thread 1 sequence 4426 is already on disk as file /u01/arch/1_4426.dbf

archive log thread 1 sequence 4427 is already on disk as file /u01/arch/1_4427.dbf

archive log thread 1 sequence 4428 is already on disk as file /u01/arch/1_4428.dbf

archive log thread 1 sequence 4429 is already on disk as file /u01/arch/1_4429.dbf

archive log thread 1 sequence 4430 is already on disk as file /u01/arch/1_4430.dbf

archive log thread 1 sequence 4431 is already on disk as file /u01/arch/1_4431.dbf

archive log thread 1 sequence 4432 is already on disk as file /u01/arch/1_4432.dbf

archive log thread 1 sequence 4433 is already on disk as file /u01/arch/1_4433.dbf

archive log thread 1 sequence 4434 is already on disk as file /u01/arch/1_4434.dbf

archive log thread 1 sequence 4435 is already on disk as file /u01/arch/1_4435.dbf

archive log thread 1 sequence 4436 is already on disk as file /u01/arch/1_4436.dbf

archive log thread 1 sequence 4437 is already on disk as file /u01/arch/1_4437.dbf

archive log thread 1 sequence 4438 is already on disk as file /u01/arch/1_4438.dbf

archive log thread 1 sequence 4439 is already on disk as file /u01/arch/1_4439.dbf

archive log thread 1 sequence 4440 is already on disk as file /u01/arch/1_4440.dbf

archive log thread 1 sequence 4441 is already on disk as file /u01/arch/1_4441.dbf

archive log thread 1 sequence 4442 is already on disk as file /u01/arch/1_4442.dbf

archive log thread 1 sequence 4443 is already on disk as file /u01/arch/1_4443.dbf

archive log thread 1 sequence 4444 is already on disk as file /u01/arch/1_4444.dbf

archive log thread 1 sequence 4445 is already on disk as file /u01/arch/1_4445.dbf

archive log thread 1 sequence 4446 is already on disk as file /u01/arch/1_4446.dbf

archive log thread 1 sequence 4447 is already on disk as file /u01/arch/1_4447.dbf

archive log filename=/u01/arch/1_4420.dbf thread=1 sequence=4420

archive log filename=/u01/arch/1_4421.dbf thread=1 sequence=4421

archive log filename=/u01/arch/1_4422.dbf thread=1 sequence=4422

archive log filename=/u01/arch/1_4423.dbf thread=1 sequence=4423

archive log filename=/u01/arch/1_4424.dbf thread=1 sequence=4424

archive log filename=/u01/arch/1_4425.dbf thread=1 sequence=4425

archive log filename=/u01/arch/1_4426.dbf thread=1 sequence=4426

archive log filename=/u01/arch/1_4427.dbf thread=1 sequence=4427

archive log filename=/u01/arch/1_4428.dbf thread=1 sequence=4428

archive log filename=/u01/arch/1_4429.dbf thread=1 sequence=4429

archive log filename=/u01/arch/1_4430.dbf thread=1 sequence=4430

archive log filename=/u01/arch/1_4431.dbf thread=1 sequence=4431

archive log filename=/u01/arch/1_4432.dbf thread=1 sequence=4432

archive log filename=/u01/arch/1_4433.dbf thread=1 sequence=4433

archive log filename=/u01/arch/1_4434.dbf thread=1 sequence=4434

archive log filename=/u01/arch/1_4435.dbf thread=1 sequence=4435

archive log filename=/u01/arch/1_4436.dbf thread=1 sequence=4436

archive log filename=/u01/arch/1_4437.dbf thread=1 sequence=4437

archive log filename=/u01/arch/1_4438.dbf thread=1 sequence=4438

archive log filename=/u01/arch/1_4439.dbf thread=1 sequence=4439

archive log filename=/u01/arch/1_4440.dbf thread=1 sequence=4440

archive log filename=/u01/arch/1_4441.dbf thread=1 sequence=4441

archive log filename=/u01/arch/1_4442.dbf thread=1 sequence=4442

archive log filename=/u01/arch/1_4443.dbf thread=1 sequence=4443

archive log filename=/u01/arch/1_4444.dbf thread=1 sequence=4444

archive log filename=/u01/arch/1_4445.dbf thread=1 sequence=4445

archive log filename=/u01/arch/1_4446.dbf thread=1 sequence=4446

archive log filename=/u01/arch/1_4447.dbf thread=1 sequence=4447

media recovery complete

Finished recover at 27-OCT-04

 

database opened

new incarnation of database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

RMAN>

 

 

已经恢复到11:45分

 

 

 

现在把test表导出来

 

[oracle@ciqdz oradata]$ exp test/test tables=(test) file=test.dmp log=test.log

 

Export: Release 9.2.0.1.0 - Production on Wed Oct 27 14:51:42 2004

 

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

 

 

Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning option

JServer Release 9.2.0.1.0 - Production

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

 

About to export specified tables via Conventional Path ...

. . exporting table                           TEST      29199 rows exported

Export terminated successfully without warnings.

[oracle@ciqdz oradata]$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.1.0 - Production on Wed Oct 27 14:51:52 2004

 

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

 

SQL> connect / as sysdba;

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

 

 

还原到现在的时刻

使用os的冷备份的全备份来还原到现在时刻

 

=======================================

[oracle@ciqdz oradata]$ cp -a itown01_bak itown01

[oracle@ciqdz oradata]$ ls -l

total 3116

drwxr-xr-x    2 oracle   dba          4096 Oct 27 14:40 itown01/

drwxr-xr-x    2 oracle   dba          4096 Oct 27 14:40 itown01_bak/

drwxr-xr-x    2 oracle   dba          4096 Oct 26 13:32 itown01_good/

-rw-r--r--    1 oracle   dba       3170304 Oct 27 14:51 test.dmp

-rw-r--r--    1 oracle   dba           399 Oct 27 14:51 test.log

[oracle@ciqdz oradata]$ rm -rf itown01_bak

[oracle@ciqdz oradata]$ ls

itown01/  itown01_good/  test.dmp  test.log

 

现在的时刻,这个表肯定是不存在的因为已经删除了

SQL> connect test/test;

Connected.

SQL> select count(*) from test;

select count(*) from test

                     *

ERROR at line 1:

ORA-00942: table or view does not exist

 

 

SQL> select count(*) from object;

 

  COUNT(*)

----------

     59399

 

现在把这个表导入

 

 [oracle@ciqdz oradata]$ imp test/test tables=(test) file=test.dmp log=testimp.log

 

Import: Release 9.2.0.1.0 - Production on Wed Oct 27 14:58:55 2004

 

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

 

 

Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning option

JServer Release 9.2.0.1.0 - Production

 

Export file created by EXPORT:V09.02.00 via conventional path

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

. importing TEST's objects into TEST

. . importing table                         "TEST"      29199 rows imported

Import terminated successfully without warnings.

[oracle@ciqdz oradata]$

[oracle@ciqdz oradata]$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.1.0 - Production on Wed Oct 27 14:59:27 2004

 

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

 

SQL> connect test/test

Connected.

 

SQL> select count(*) from test;

 

  COUNT(*)

----------

     29199

 

现在已经有这个表了――――――

SQL> select count(*) from object;

 

  COUNT(*)

----------

     59401

 

而且object这个表的记录是最新的!

我为了模拟正在进行事务出来,在oracle中做了个job让它每分钟给object添加一条记录

到现在为止成功的恢复了表的误删除

 

 

 

 

 

select sequence#,applied from v$archived_log

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9408/viewspace-102240/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 回深圳了
请登录后发表评论 登录
全部评论

注册时间:2002-04-05

  • 博文量
    464
  • 访问量
    352739