您的位置:首页 > 其它

RMAN异机恢复,将指定的表空间恢复到8月12号2点8分

2012-08-23 14:53 357 查看
大致步骤如下:

0:拷贝备份的文件到恢复机,路径也备份时的路径一致;

1:使用默认的init.ora修改出initeagaodb.ora参数文件;

2:创建initeagaodb.ora参数文件中的相关文件目录,把目录创建在空闲分区比较大的分区,注意闪回目录在后续的recover时会被自动存储恢复的归档,应用后又被自动删除;

3:使用startup nomount启动数据库;

4:使用rman恢复控制文件,注意此控制文件需要恢复到指定需要恢复时间点之后的备份,下面是恢复到8点中的备份

RMAN> restore controlfile from '/data4/130.177.65.815back/contorlfileback/controlc-1839368230-20120812-03';

5:启动数据库到mount状态

SQL> alter database mount;

6:重命名数据文件路径,以及restore需要的数据文件(数据文件id号可以备份日志中获取);

RMAN> run{

allocate channel ch1 type disk;

allocate channel ch2 type disk;

allocate channel ch3 type disk;

allocate channel ch4 type disk;

set newname for datafile 1 to '/data2/oradatarecovery/system01.dbf';

set newname for datafile 2 to '/data2/oradatarecovery/undotbs01.dbf';

set newname for datafile 3 to '/data2/oradatarecovery/sysaux01.dbf';

set newname for datafile 61 to '/data2/oradatarecovery/system02.dbf';

set newname for datafile 67 to '/data2/oradatarecovery/sysaux02.dbf';

set newname for datafile 69 to '/data2/oradatarecovery/eaunion_data01.dbf';

restore datafile 1,2,3,61,67,69;

switch datafile all;

release channel ch1;

release channel ch2;

release channel ch3;

release channel ch4;

}

7:recover数据库到指定时间点

RMAN> sql 'alter session set nls_Date_format="yyyy-mm-dd hh24:mi:ss"';

RMAN>recover database until time '2012-08-12 01:08:00' skip tablespace eaon_log,fnk_ta,z_dta,nion,zdan,eion_log,enex;

8:使用只读打开数据库后expdp出需要的数据即可

SQL> alter database open read only;

DBLINK 导出到别的库 …………………..

大致步骤如下(全部在恢复机上操作,把备份拷贝过来,拷贝的路径与备份时的路径一致):

1:创建参数文件

[oracle@sz dbs]$ cat initeagaodb.ora

db_name='eagaodb'

memory_target=10G

processes = 150

audit_file_dest='/data2/oradatarecovery/admin/orcl/adump'

db_block_size=8192

db_recovery_file_dest='/data2/oradatarecovery/flash_recovery_area'

db_recovery_file_dest_size=2G

diagnostic_dest='/data2/oradatarecovery/diag'

dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'

open_cursors=300

remote_login_passwordfile='EXCLUSIVE'

undo_tablespace='UNDOTBS1'

# You may want to ensure that control files are created on separate physical

# devices

control_files = '/data2/oradatarecovery/control01.ctl','/data2/oradatarecovery/control02.ctl'

compatible ='11.2.0'

2:建立上述目录文件

3:启动数据库

SQL> startup nomount;

4:恢复控制文件

[oracle@szmlserver12_32 ~]$ rlwrap rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Aug 23 12:05:05 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: EAGAODB (not mounted)

RMAN> restore controlfile from '/data4/130.177.65.815back/contorlfileback/controlc-1839368230-20120812-03';

Starting restore at 2012-08-23 12:07:32

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=189 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:08

output file name=/data2/oradatarecovery/control01.ctl

output file name=/data2/oradatarecovery/control02.ctl

Finished restore at 2012-08-23 12:07:40

RMAN> quit

5:重命名数据文件路径,以及restore需要的数据文件(数据文件id号可以备份日志中获取);

RMAN> run{

allocate channel ch1 type disk;

allocate channel ch2 type disk;

allocate channel ch3 type disk;

allocate channel ch4 type disk;

set newname for datafile 1 to '/data2/oradatarecovery/system01.dbf';

set newname for datafile 2 to '/data2/oradatarecovery/undotbs01.dbf';

set newname for datafile 3 to '/data2/oradatarecovery/sysaux01.dbf';

set newname for datafile 61 to '/data2/oradatarecovery/system02.dbf';

set newname for datafile 67 to '/data2/oradatarecovery/sysaux02.dbf';

set newname for datafile 69 to '/data2/oradatarecovery/enion_data01.dbf';

restore datafile 1,2,3,61,67,69;

switch datafile all;

release channel ch1;

release channel ch2;

release channel ch3;

release channel ch4;

}

released channel: ORA_DISK_1

allocated channel: ch1

channel ch1: SID=189 device type=DISK

allocated channel: ch2

channel ch2: SID=221 device type=DISK

allocated channel: ch3

channel ch3: SID=3 device type=DISK

allocated channel: ch4

channel ch4: SID=33 device type=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

datafile 1 switched to datafile copy

input datafile copy RECID=40 STAMP=792075637 file name=/data2/oradatarecovery/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=39 STAMP=792075427 file name=/data2/oradatarecovery/undotbs01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=41 STAMP=792075739 file name=/data2/oradatarecovery/sysaux01.dbf

datafile 61 switched to datafile copy

input datafile copy RECID=37 STAMP=792075295 file name=/data2/oradatarecovery/system02.dbf

datafile 67 switched to datafile copy

input datafile copy RECID=38 STAMP=792075398 file name=/data2/oradatarecovery/sysaux02.dbf

datafile 69 switched to datafile copy

input datafile copy RECID=42 STAMP=792076860 file name=/data2/oradatarecovery/eaunion_data01.dbf

released channel: ch1

released channel: ch2

released channel: ch3

released channel: ch4

6:recover数据库到指定时间点

RMAN> sql 'alter session set nls_Date_format="yyyy-mm-dd hh24:mi:ss"';

RMAN> recover database until time '2012-08-12 01:08:00' skip tablespace eaon_log,fnk_ta,z_dta,nion,zdan,eion_log,enex;

Starting recover at 23-AUG-12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=189 device type=DISK

datafile 68 not processed because file is offline

Executing: alter database datafile 5 offline

Executing: alter database datafile 6 offline

Executing: alter database datafile 7 offline

Executing: alter database datafile 8 offline

Executing: alter database datafile 9 offline

Executing: alter database datafile 10 offline

Executing: alter database datafile 11 offline

Executing: alter database datafile 12 offline

Executing: alter database datafile 13 offline

Executing: alter database datafile 14 offline

Executing: alter database datafile 15 offline

Executing: alter database datafile 17 offline

Executing: alter database datafile 18 offline

Executing: alter database datafile 19 offline

Executing: alter database datafile 20 offline

Executing: alter database datafile 21 offline

Executing: alter database datafile 22 offline

Executing: alter database datafile 23 offline

Executing: alter database datafile 24 offline

Executing: alter database datafile 25 offline

Executing: alter database datafile 26 offline

Executing: alter database datafile 27 offline

Executing: alter database datafile 28 offline

Executing: alter database datafile 29 offline

Executing: alter database datafile 70 offline

Executing: alter database datafile 71 offline

Executing: alter database datafile 72 offline

Executing: alter database datafile 73 offline

Executing: alter database datafile 74 offline

Executing: alter database datafile 75 offline

Executing: alter database datafile 4 offline

Executing: alter database datafile 63 offline

Executing: alter database datafile 64 offline

Executing: alter database datafile 30 offline

Executing: alter database datafile 65 offline

Executing: alter database datafile 66 offline

Executing: alter database datafile 16 offline

starting media recovery

RMAN-06560: WARNING: backup set with key 47 will be read 3 times

available space of 4794202 kb needed to avoid reading the backup set multiple times

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40346

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40347

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_20120812_1rnidrgm_1_1

channel ORA_DISK_1: piece handle=/backup/rmanback/arch_20120812_1rnidrgm_1_1 tag=TAG20120812T003429

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:02:05

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40346_83cjdpwd_.arc thread=1 sequence=40346

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40346_83cjdpwd_.arc RECID=2090 STAMP=792077966

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40347_83cjdqbk_.arc thread=1 sequence=40347

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40347_83cjdqbk_.arc RECID=2089 STAMP=792077962

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40348

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40349

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40350

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_20120812_1snidrgm_1_1

channel ORA_DISK_1: piece handle=/backup/rmanback/arch_20120812_1snidrgm_1_1 tag=TAG20120812T003429

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:45

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40348_83cjkbs5_.arc thread=1 sequence=40348

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40348_83cjkbs5_.arc RECID=2093 STAMP=792078092

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40349_83cjkbw2_.arc thread=1 sequence=40349

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40349_83cjkbw2_.arc RECID=2092 STAMP=792078068

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40350_83cjkbwn_.arc thread=1 sequence=40350

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40350_83cjkbwn_.arc RECID=2091 STAMP=792077995

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40351

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40352

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_1vnielk6_1_1_20120812_63

channel ORA_DISK_1: piece handle=/backup/rmanback/arch_1vnielk6_1_1_20120812_63 tag=TAG20120812T080005

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:02:35

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40351_83cjoc13_.arc thread=1 sequence=40351

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40351_83cjoc13_.arc RECID=2095 STAMP=792078269

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40352_83cjoc2d_.arc thread=1 sequence=40352

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40352_83cjoc2d_.arc RECID=2094 STAMP=792078268

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40353

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40354

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_1vnielk6_1_1_20120812_63

channel ORA_DISK_1: piece handle=/backup/rmanback/arch_1vnielk6_1_1_20120812_63 tag=TAG20120812T080005

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40353_83cjtv6m_.arc thread=1 sequence=40353

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40353_83cjtv6m_.arc RECID=2097 STAMP=792078322

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40354_83cjtv73_.arc thread=1 sequence=40354

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40354_83cjtv73_.arc RECID=2096 STAMP=792078321

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=40355

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_1vnielk6_1_1_20120812_63

channel ORA_DISK_1: piece handle=/backup/rmanback/arch_1vnielk6_1_1_20120812_63 tag=TAG20120812T080005

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40355_83cjw91q_.arc thread=1 sequence=40355

channel default: deleting archived log(s)

archived log file name=/data2/oradatarecovery/flash_recovery_area/EAGAODB/archivelog/2012_08_23/o1_mf_1_40355_83cjw91q_.arc RECID=2098 STAMP=792078358

media recovery complete, elapsed time: 00:00:02

Finished recover at 23-AUG-12

RMAN>

7:只读打开数据库

SQL> alter database open read only;

Database altered.

8:DBLINK导出数据

如果导出的数据量比较大,那么可以使用expdp导出,但此时数据库要处于读写模式,由于很多表空间都没restore,所以为了方便打开数据库,重建控制文件

a:创建控制文件

SQL> alter database backup controlfile to trace as '/tmp/contr_eagao.txt';

b:修改为:

[oracle@szmlserver12_32 oradatarecovery]$ cat /tmp/create_control.txt

CREATE CONTROLFILE REUSE DATABASE "EAGAODB" RESETLOGS FORCE LOGGING ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 9344

LOGFILE

GROUP 1 (

'/data2/oradatarecovery/redo101.log'

) SIZE 1024M,

GROUP 2 (

'/data2/oradatarecovery/redo201.log'

) SIZE 1024M

DATAFILE

'/data2/oradatarecovery/system01.dbf',

'/data2/oradatarecovery/undotbs01.dbf',

'/data2/oradatarecovery/sysaux01.dbf',

'/data2/oradatarecovery/system02.dbf',

'/data2/oradatarecovery/sysaux02.dbf',

'/data2/oradatarecovery/eaunion_data01.dbf'

CHARACTER SET AL32UTF8;

由于在线日志没restore,如果上面用NORESETLOGS会报错:

SQL> @/tmp/create_control.txt

CREATE CONTROLFILE REUSE DATABASE "EAGAODB" NORESETLOGS FORCE LOGGING ARCHIVELOG

*

ERROR at line 1:

ORA-01503: CREATE CONTROLFILE failed

ORA-01160: file is not a log file

ORA-01517: log member: '/data2/oradatarecovery/redo101.log'

c:运行创建控制文件脚本

SQL> @/tmp/create_control.txt

Control file created.

SQL> alter database open RESETLOGS;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE

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

READ WRITE

d:expdp需要用到临时表空间,所以要创建临时表空间

SQL> create temporary tablespace tbs_tmp tempfile '/data2/oradatarecovery/tbs_tmp1.dbf' size 10g;

Tablespace created.

SQL> alter database default temporary tablespace tbs_tmp;

Database altered.

e:导出表

$ expdp "'/ as sysdba'" tables=dba.finance directory=orabak dumpfile=finance_test.dmp logfile=finance_test.log

Export: Release 11.2.0.1.0 - Production on Thu Aug 23 16:33:16 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting "SYS"."SYS_EXPORT_TABLE_01": "/******** AS SYSDBA" tables=dba.finance directory=orabak dumpfile=finance_test.dmp logfile=finance_test.log

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 113 MB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/COMMENT

Processing object type TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported "DBA"."FINANCE" 238.6 MB 2085107 rows

Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

******************************************************************************

Dump file set for SYS.SYS_EXPORT_TABLE_01 is:

/backup/expdpback/finance_test.dmp

Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 16:33:34

完成!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: