oracle垮版本恢复,【RMAN】RMAN跨版本恢复(上)

【RMAN】RMAN跨版本恢复(上)--小版本异机恢复

BLOG文档结构图

5b0edc6419a891debd3d8c9dca158476.png

前几天去面试被问到了关于rman是否可以跨版本恢复的问题,其实之前有网友曾经问过只是我没有做实验,这几天有空就研究了下rman跨版本恢复的这个问题。

ORACLE_SID=orcl

原机:OS:Linux x86 64-bit  IP:192.168.59.129  oracle:11.2.0.1.0归档模式

异机:OS:Linux x86 64-bit  IP:192.168.59.10   oracle:11.2.0.3.0归档模式

目的:利用原机的rman备份集将原库恢复到异机。

一、全备份原数据库并拷贝到异机

备份脚本如下:

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database filesperset 4 format  '/home/oracle/oracle_bk/orcl/full_%n_%T_%t_%s_%p.bak';

backup spfile format='/home/oracle/oracle_bk/orcl/spfile_%n_%U_%T.bak';

sql 'alter system archive log current';

backup archivelog all format '/home/oracle/oracle_bk/orcl/arch_%d_%T_%s_%p.bak' delete input;

backup current controlfile format '/home/oracle/oracle_bk/orcl/ctl_%d_%T_%s_%p.bak';

release channel c1;

release channel c2;

}

[oracle@rhel6 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 9 10:14:24 2015

Copyright (c) 1982, 2009, Oracle.  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

SQL>create pfile from spfile;

File created.

[oracle@rhel6 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Apr 9 09:37:44 2015

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

connected to target database: ORCL (DBID=1379935487)

RMAN> run{

2>  allocate channel c1 type disk;

3>  allocate channel c2 type disk;

4>  backup database filesperset 4 format  '/home/oracle/oracle_bk/orcl/full_%n_%T_%t_%s_%p.bak';

5>  sql 'alter system archive log current';

6>  backup archivelog all format '/home/oracle/oracle_bk/orcl/arch_%d_%T_%s_%p.bak' delete input;

7>  backup current controlfile format '/home/oracle/oracle_bk/orcl/ctl_%d_%T_%s_%p.bak';

8> release channel c1;

9> release channel c2;

10> }

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: SID=50 device type=DISK

allocated channel: c2

channel c2: SID=17 device type=DISK

Starting backup at 09-APR-15

channel c1: starting compressed full datafile backup set

channel c1: specifying datafile(s) in backup set

input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/goldengate01.dbf

channel c1: starting piece 1 at 09-APR-15

channel c2: starting compressed full datafile backup set

channel c2: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf

channel c2: starting piece 1 at 09-APR-15

channel c1: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/full_ORCLxxxx_20150409_876562667_61_1.bak tag=TAG20150409T093747 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:56

channel c2: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/full_ORCLxxxx_20150409_876562667_62_1.bak tag=TAG20150409T093747 comment=NONE

channel c2: backup set complete, elapsed time: 00:01:16

Finished backup at 09-APR-15

Starting backup at 09-APR-15

using channel ORA_DISK_1

using channel ORA_DISK_2

channel ORA_DISK_1: starting compressed full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 09-APR-15

channel ORA_DISK_1: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/spfile_ORCLxxxx_26q3ujt4_1_1_20150409.bak tag=TAG20150409T100628 comment=NONE

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

Finished backup at 09-APR-15

Starting Control File and SPFILE Autobackup at 09-APR-15

piece handle=/home/oracle/oracle_bk/orclasm/control_c-1379935487-20150409-02.bak comment=NONE

Finished Control File and SPFILE Autobackup at 09-APR-15

sql statement: alter system archive log current

Starting backup at 09-APR-15

current log archived

channel c1: starting compressed archived log backup set

channel c1: specifying archived log(s) in backup set

input archived log thread=1 sequence=13 RECID=61 STAMP=876562747

channel c1: starting piece 1 at 09-APR-15

channel c2: starting compressed archived log backup set

channel c2: specifying archived log(s) in backup set

input archived log thread=1 sequence=14 RECID=62 STAMP=876562747

channel c2: starting piece 1 at 09-APR-15

channel c1: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/arch_ORCL_20150409_64_1.bak tag=TAG20150409T093907 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:01

channel c1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2015_04_09/o1_mf_1_13_blcp1vb5_.arc RECID=61 STAMP=876562747

channel c2: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/arch_ORCL_20150409_65_1.bak tag=TAG20150409T093907 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:01

channel c2: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2015_04_09/o1_mf_1_14_blcp1vd5_.arc RECID=62 STAMP=876562747

Finished backup at 09-APR-15

Starting backup at 09-APR-15

channel c1: starting compressed full datafile backup set

channel c1: specifying datafile(s) in backup set

including current control file in backup set

channel c1: starting piece 1 at 09-APR-15

channel c1: finished piece 1 at 09-APR-15

piece handle=/home/oracle/oracle_bk/orcl/ctl_ORCL_20150409_66_1.bak tag=TAG20150409T093908 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:01

Finished backup at 09-APR-15

Starting Control File and SPFILE Autobackup at 09-APR-15

piece handle=/home/oracle/oracle_bk/orclasm/control_c-1379935487-20150409-03.bak comment=NONE

Finished Control File and SPFILE Autobackup at 09-APR-15

released channel: c1

released channel: c2

RMAN>

[root@rhel6 ~]# cd /home/oracle/oracle_bk/orcl/

[root@rhel6 orcl]# ll

total 281732

-rw-r-----. 1 oracle asmadmin      3072 Apr  9 09:39 arch_ORCL_20150409_64_1.bak

-rw-r-----. 1 oracle asmadmin      2560 Apr  9 09:39 arch_ORCL_20150409_65_1.bak

-rw-r-----. 1 oracle asmadmin   1114112 Apr  9 09:39 ctl_ORCL_20150409_66_1.bak

-rw-r-----. 1 oracle asmadmin  75538432 Apr  9 09:38 full_ORCLxxxx_20150409_876562667_61_1.bak

-rw-r-----. 1 oracle asmadmin 211828736 Apr  9 09:38 full_ORCLxxxx_20150409_876562667_62_1.bak

-rw-r-----. 1 oracle asmadmin     98304 Apr  9 09:38 spfile_ORCLxxxx_26q3ujt4_1_1_20150409.bak

[root@rhel6 orcl]#

[root@rhel6 orcl]# su - oracle

[oracle@rhel6 ~]$ cd /home/oracle/oracle_bk/

[oracle@rhel6 oracle_bk]$scp -r orcl [email protected]:/tmp/

[email protected]'s password:

full_ORCLxxxx_20150409_876562667_62_1.bak                                                                                                                                       100%  202MB  10.6MB/s   00:19

arch_ORCL_20150409_65_1.bak                                                                                                                                                     100% 2560     2.5KB/s   00:00

ctl_ORCL_20150409_66_1.bak                                                                                                                                                      100% 1088KB   1.1MB/s   00:00

arch_ORCL_20150409_64_1.bak                                                                                                                                                     100% 3072     3.0KB/s   00:00

full_ORCLxxxx_20150409_876562667_61_1.bak                                                                                                                                       100%   72MB  72.0MB/s   00:01

spfile_ORCLxxxx_26q3ujt4_1_1_20150409.bak                                                                                                                                       100%   96KB  96.0KB/s   00:00

[oracle@rhel6 oracle_bk]$

[oracle@rhel6 orcl]$scp $ORACLE_HOME/dbs/initorcl.ora [email protected]:/tmp/orcl/

[email protected]'s password:

initorcl.ora                                                                                                                                                                    100% 1035     1.0KB/s   00:00

[oracle@rhel6 orcl]$scp $ORACLE_HOME/dbs/orapworcl [email protected]:/tmp/orcl/

[email protected]'s password:

orapworcl                                                                                                                                                                       100% 1536     1.5KB/s   00:00

[oracle@rhel6 orcl]$

二、在异机的操作

1、恢复spfile

这里不采用rman恢复了,因为要实验异机不同路径的恢复,所以直接修改pfile文件吧。

[oracle@testdb orcl]$ cp initorcl.ora $ORACLE_HOME/dbs/

[oracle@testdb orcl]$ cp orapworcl  $ORACLE_HOME/dbs/

[oracle@testdb orcl]$ vi $ORACLE_HOME/dbs/initorcl.ora

修改pfile文件之后:

[oracle@testdb orcl]$ more $ORACLE_HOME/dbs/initorcl.ora

*.audit_file_dest='/u01/app/oracle/admin/orcltest/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/app/oracle/oradata/orcltest/control01.ctl','/u01/app/oracle/oradata/orcltest/control02.ctl'#Restore Controlfile

*.db_block_size=8192

*.db_name='orcl'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=8589934592

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.job_queue_processes=1000

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=314572800

*.open_cursors=300

*.processes=50

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=60

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值