rman 迁移ASM到异机文件系统实战

rman 迁移ASM到异机文件系统实战

 

环境说明:

源库:192.168.0.10

目标库:192.168.0.11

 

源库备份:

RMAN> run {

2> allocate channel c1 device type disk;

3> allocate channel c2 device type disk;

4> backup database format '/home/oracle/full_database%U' include current controlfile;

5> sql 'alter system archive log current'; 

6> backup archivelog all format '/home/oracle/archivelog_%U';

7> crosscheck backup;

8> delete noprompt obsolete;

9> release channel c1;

10> release channel c2;

11> }

 

复制备份集到备库:

scp /home/oracle/full* oracle@192.168.0.11:/home/oracle/target_bk/

scp /home/oracle/archive* oracle@192.168.0.11:/home/oracle/target_bk/

[oracle@targetdb target_bk]$ ls

archivelog_0rnu4jbf_1_1  full_database0nnu4ja0_1_1  full_database0pnu4jb4_1_1

archivelog_0snu4jbf_1_1  full_database0onu4ja0_1_1  full_database0qnu4jb5_1_1

 

目标库操作

[oracle@targetdb sourcedb]$ mkdir {a,b,c,u}dump

[oracle@targetdb sourcedb]$ ls

adump  bdump  cdump  udump

 

[oracle@targetdb oradata]$ mkdir sourcedb

[oracle@targetdb oradata]$ ls

sourcedb 

[oracle@targetdb oradata]$ cd sourcedb/

[oracle@targetdb sourcedb]$ mkdir arch

[oracle@targetdb sourcedb]$ ls

arch

 

开始恢复:

因为还没有参数文件,先使用rman 无参数启动

export ORACLE_SID=sourcedb

RMAN> startup nomount;   

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/oracle/product/10.2.0/dbs/initsourcedb.ora'

 

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

 

Total System Global Area     159383552 bytes

 

Fixed Size                     1218268 bytes

Variable Size                 54528292 bytes

Database Buffers             100663296 bytes

Redo Buffers                   2973696 bytes

 

RMAN> exit

 

Recovery Manager complete.

 

Rman 默认启动了一个名字为DUMMY的实例

[oracle@targetdb target_bk]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Dec 30 04:40:27 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: DUMMY (not mounted)

RMAN>

[oracle@targetdb target_bk]$ ll -hr

total 596M

-rw-r--r-- 1 oracle oinstall  96K Dec 30 03:57 full_database0qnu4jb5_1_1

-rw-r--r-- 1 oracle oinstall 6.8M Dec 30 03:57 full_database0pnu4jb4_1_1

-rw-r--r-- 1 oracle oinstall 216M Dec 30 03:57 full_database0onu4ja0_1_1

-rw-r--r-- 1 oracle oinstall 373M Dec 30 03:57 full_database0nnu4ja0_1_1

-rw-r--r-- 1 oracle oinstall 2.5K Dec 30 03:56 archivelog_0snu4jbf_1_1

-rw-r--r-- 1 oracle oinstall 554K Dec 30 03:56 archivelog_0rnu4jbf_1_1

 

参数文件在哪个备份集呢?可以到原库上通过list backup 查看,有经验的查看备份集大小即可判断出。

[oracle@targetdb target_bk]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Dec 30 04:41:43 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: DUMMY (not mounted)

RMAN> restore spfile from '/home/oracle/target_bk/full_database0qnu4jb5_1_1';

 

Starting restore at 30-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /home/oracle/target_bk/full_database0qnu4jb5_1_1

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 30-DEC-12

 

RMAN> shutdown immediate;

 

Oracle instance shut down

 

RMAN>

 

恢复控制文件

使用刚刚恢复出来的参数文件启库:

[oracle@targetdb target_bk]$ rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Dec 30 04:45:54 2012

 

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

connected to target database (not started)

 

RMAN> startup nomount

 

Oracle instance started

 

Total System Global Area     167772160 bytes

 

Fixed Size                     1218316 bytes

Variable Size                 75499764 bytes

Database Buffers              88080384 bytes

Redo Buffers                   2973696 bytes

 

RMAN>  restore controlfile to '/u01/oracle/oradata/sourcedb/controlfile01.ctl' from '/home/oracle/target_bk/full_database0pnu4jb4_1_1';

 

Starting restore at 30-DEC-12

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

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

Finished restore at 30-DEC-12

 

到sqlplus 下修改参数文件位置:

SQL> show parameter control

 

NAME                                 TYPE        VALUE

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

control_file_record_keep_time        integer     7

control_files                        string      +DG1/sourcedb/controlfile/cont

                                                 rol01.ctl, +DG1/sourcedb/contr

                                                 olfile/control02.ctl

 

SQL> alter system set control_files='/u01/oracle/oradata/sourcedb/control01.ctl','/u01/oracle/oradata/sourcedb/control02.ctl' scope=spfile;

System altered.

 

 

注册备份集中,如果备份集中放在和原库相同目录可以省略这一步:

RMAN> catalog  start with '/home/oracle/target_bk/';

 

Starting implicit crosscheck backup at 30-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

Crosschecked 7 objects

Finished implicit crosscheck backup at 30-DEC-12

 

Starting implicit crosscheck copy at 30-DEC-12

using channel ORA_DISK_1

Crosschecked 6 objects

Finished implicit crosscheck copy at 30-DEC-12

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

searching for all files that match the pattern /home/oracle/target_bk/

 

List of Files Unknown to the Database

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

File Name: /home/oracle/target_bk/archivelog_0snu4jbf_1_1

File Name: /home/oracle/target_bk/full_database0pnu4jb4_1_1

File Name: /home/oracle/target_bk/full_database0nnu4ja0_1_1

File Name: /home/oracle/target_bk/full_database0onu4ja0_1_1

File Name: /home/oracle/target_bk/full_database0qnu4jb5_1_1

File Name: /home/oracle/target_bk/archivelog_0rnu4jbf_1_1

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

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

File Name: /home/oracle/target_bk/archivelog_0snu4jbf_1_1

File Name: /home/oracle/target_bk/full_database0pnu4jb4_1_1

File Name: /home/oracle/target_bk/full_database0nnu4ja0_1_1

File Name: /home/oracle/target_bk/full_database0onu4ja0_1_1

File Name: /home/oracle/target_bk/full_database0qnu4jb5_1_1

File Name: /home/oracle/target_bk/archivelog_0rnu4jbf_1_1

 

恢复数据文件:

run {

allocate channel c1 device type disk;

allocate channel c2 device type disk;

set newname for datafile '+DG1/sourcedb/datafile/system01.dbf' to '/u01/oracle/oradata/sourcedb/system01.dbf';

set newname for datafile '+DG1/sourcedb/datafile/undotbs301.dbf' to '/u01/oracle/oradata/sourcedb/undotbs301.dbf';

set newname for datafile '+DG1/sourcedb/datafile/users01.dbf' to  '/u01/oracle/oradata/sourcedb/users01.dbf';

set newname for datafile  '+DG1/sourcedb/datafile/sysaux01.dbf' to '/u01/oracle/oradata/sourcedb/sysaux01.dbf';

set newname for datafile '+DG1/sourcedb/datafile/example01.dbf' to '/u01/oracle/oradata/sourcedb/example01.dbf';

set newname for datafile '+DG1/sourcedb/datafile/gguser.dbf' to '/u01/oracle/oradata/sourcedb/gguser.dbf';

restore database;

switch datafile all;

release channel c1;

release channel c2;

}

 

 

allocated channel: c1

channel c1: sid=155 devtype=DISK

 

allocated channel: c2

channel c2: sid=153 devtype=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

 

Starting restore at 30-DEC-12

 

channel c1: starting datafile backupset restore

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

restoring datafile 00001 to /u01/oracle/oradata/sourcedb/system01.dbf

restoring datafile 00002 to /u01/oracle/oradata/sourcedb/undotbs301.dbf

restoring datafile 00004 to /u01/oracle/oradata/sourcedb/users01.dbf

channel c1: reading from backup piece /home/oracle/target_bk/full_database0nnu4ja0_1_1

channel c2: starting datafile backupset restore

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

restoring datafile 00003 to /u01/oracle/oradata/sourcedb/sysaux01.dbf

restoring datafile 00005 to /u01/oracle/oradata/sourcedb/example01.dbf

restoring datafile 00006 to /u01/oracle/oradata/sourcedb/gguser.dbf

channel c2: reading from backup piece /home/oracle/target_bk/full_database0onu4ja0_1_1

channel c1: restored backup piece 1

piece handle=/home/oracle/target_bk/full_database0nnu4ja0_1_1 tag=TAG20121230T033424

channel c1: restore complete, elapsed time: 00:00:47

channel c2: restored backup piece 1

piece handle=/home/oracle/target_bk/full_database0onu4ja0_1_1 tag=TAG20121230T033424

channel c2: restore complete, elapsed time: 00:00:46

Finished restore at 30-DEC-12

 

datafile 1 switched to datafile copy

input datafile copy recid=32 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/system01.dbf

datafile 2 switched to datafile copy

input datafile copy recid=33 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/undotbs301.dbf

datafile 4 switched to datafile copy

input datafile copy recid=34 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/users01.dbf

datafile 3 switched to datafile copy

input datafile copy recid=35 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/sysaux01.dbf

datafile 5 switched to datafile copy

input datafile copy recid=36 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/example01.dbf

datafile 6 switched to datafile copy

input datafile copy recid=37 stamp=803367018 filename=/u01/oracle/oradata/sourcedb/gguser.dbf

 

released channel: c1

 

released channel: c2

 

 

RMAN> recover database;

 

Starting recover at 30-DEC-12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

 

starting media recovery

 

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=12

channel ORA_DISK_1: reading from backup piece /home/oracle/target_bk/archivelog_0snu4jbf_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/target_bk/archivelog_0snu4jbf_1_1 tag=TAG20121230T033511

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

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=11

channel ORA_DISK_1: reading from backup piece /home/oracle/target_bk/archivelog_0rnu4jbf_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/target_bk/archivelog_0rnu4jbf_1_1 tag=TAG20121230T033511

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

archive log filename=/u01/oracle/oradata/sourcedb/arch/1_11_803260244.dbf thread=1 sequence=11

archive log filename=/u01/oracle/oradata/sourcedb/arch/1_12_803260244.dbf thread=1 sequence=12

unable to find archive log

archive log thread=1 sequence=13

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

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

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

RMAN-03002: failure of recover command at 12/30/2012 05:32:41

RMAN-06054: media recovery requesting unknown log: thread 1 seq 13 lowscn 743601

 

这里报找不到13号日志,因为在原库备份的时候13号日志还没归档,所以备份集中没有这个日志。

 

这里需要注意,因为控制文件记录的联机日志是放在ASM中,我们需要修改控制文件中联机日志的位置,可以通过rename 来修改,也可以通过重建控制文件来修改,这里我们使用重建控制文件:

CREATE CONTROLFILE REUSE DATABASE "SOURCEDB" RESETLOGS FORCE LOGGING ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/u01/oracle/oradata/sourcedb/redo01.log'  SIZE 50M,

  GROUP 2 '/u01/oracle/oradata/sourcedb/redo02.log'  SIZE 50M,

  GROUP 3 '/u01/oracle/oradata/sourcedb/redo03.log'  SIZE 50M

DATAFILE

  '/u01/oracle/oradata/sourcedb/system01.dbf',

  '/u01/oracle/oradata/sourcedb/undotbs301.dbf',

  '/u01/oracle/oradata/sourcedb/sysaux01.dbf',

  '/u01/oracle/oradata/sourcedb/users01.dbf',

  '/u01/oracle/oradata/sourcedb/example01.dbf',

  '/u01/oracle/oradata/sourcedb/gguser.dbf'

CHARACTER SET ZHS16GBK

;

 

Alter database open resetlogs;

 

恢复完毕。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值