RMAN迁移数据库(RMAN异机恢复)

源库和目标库的数据库软件版本需要一致(已安装数据库软件),操作系统架构需一致。源库名为mydb,dbid号为

在源和目标服务器创建备份目录(源为172.16.100.100,目标为172.16.100.200)

[oracle@localhost u01]$ mkdir -p /u01/backup

在源库用RMAN进行全备数据库,记住dbid号。

[oracle@localhost backup]$ export ORACLE_SID=mydb

[oracle@localhost backup]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Aug 31 01:10:35 2015

 

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

 

connected to target database: MYDB (DBID=2804130787)

RMAN>

run {

allocate channel c1 device type disk;

backup incremental level 0

format '/u01/backup/db_full_%U.bkp'

tag '2015-09-05-FULL'

database plus archivelog;

release channel c1;

}

backup current controlfile format '/u01/backup/control20150906.bak';

backup spfile format '/u01/backup/spfile20150905.bak';

[oracle@localhost backup]$ ll

total 1033740

-rw-r----- 1 oracle oinstall 9797632 Sep 5 23:08 control20150906.bak

-rw-r----- 1 oracle oinstall 1047584768 Sep 5 22:50 db_full_0kqfujba_1_1.bkp

-rw-r----- 1 oracle oinstall 3584 Sep 5 22:50 db_full_0lqfujeu_1_1.bkp

-rw-r----- 1 oracle oinstall 98304 Sep 5 23:08 spfile20150905.bak

拷贝备份文件到目标库,并创建好数据库相关目录

[root@localhost u01]# scp backup/* oracle@172.16.100.200:/u01/backup

[oracle@localhost admin]$ mkdir -p /u01/app/oracle/admin/mydb/{adump,bdump,cdump,dpdump,udump,pfile}

[oracle@localhost oradata]$ mkdir –p /u01/app/oracle/oradata/mydb

[oracle@localhost flash_recovery_area]$ mkdir –p /u01/app/oracle/flash_recovery_area/mydb

目标库进行恢复

[oracle@localhost backup]$ export ORACLE_SID=mydb

[oracle@localhost backup]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Sep 5 23:01:36 2015

 

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

 

connected to target database (not started)

 

RMAN> set dbid 2804130787

 

executing command: SET DBID

RMAN> startup nomount;

RMAN> restore spfile from '/u01/backup/spfile20150905.bak';

 

Starting restore at 05-SEP-15

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/spfile20150905.bak

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 05-SEP-15

 

 

 

SQL> create pfile from spfile;

 

File created.

 

 

RMAN> startup force;

 

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

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

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

RMAN-03002: failure of startup command at 09/05/2015 23:17:11

RMAN-04014: startup failed: ORA-00119: invalid specification for system parameter LOCAL_LISTENER

ORA-00132: syntax error or unresolved network name 'LISTENER_MYDB'

[oracle@localhost backup]$vim /u01/app/oracle/product/11.2.0.1/dbs/initmydb.ora 修改如下

*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521))'

 

RMAN> startup nomount force pfile='/u01/app/oracle/product/11.2.0.1/dbs/initmydb.ora';

 

Oracle instance started

 

Total System Global Area 839282688 bytes

 

Fixed Size 2217992 bytes

Variable Size 503318520 bytes

Database Buffers 331350016 bytes

Redo Buffers 2396160 bytes

 

RMAN> restore controlfile from '/u01/backup/control20150906.bak';

 

 

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> restore database;

 

Starting restore at 05-SEP-15

Starting implicit crosscheck backup at 05-SEP-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=20 device type=DISK

Crosschecked 7 objects

Finished implicit crosscheck backup at 05-SEP-15

 

Starting implicit crosscheck copy at 05-SEP-15

using channel ORA_DISK_1

Finished implicit crosscheck copy at 05-SEP-15

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/mydb/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/mydb/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/mydb/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/mydb/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/mydb/example01.dbf

channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/mydb/mytest01.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_0kqfujba_1_1.bkp

channel ORA_DISK_1: piece handle=/u01/backup/db_full_0kqfujba_1_1.bkp tag=2015-09-05-FULL

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 05-SEP-15

 

[oracle@localhost mydb]$ ll

total 1378020

-rw-r----- 1 oracle oinstall 9748480 Sep 5 23:35 control01.ctl

-rw-r----- 1 oracle oinstall 104865792 Sep 5 23:35 example01.dbf

-rw-r----- 1 oracle oinstall 52436992 Sep 5 23:35 mytest01.dbf

-rw-r----- 1 oracle oinstall 492838912 Sep 5 23:35 sysaux01.dbf

-rw-r----- 1 oracle oinstall 702554112 Sep 5 23:35 system01.dbf

-rw-r----- 1 oracle oinstall 41951232 Sep 5 23:35 undotbs01.dbf

-rw-r----- 1 oracle oinstall 5251072 Sep 5 23:35 users01.dbf

[oracle@localhost mydb]$ pwd

/u01/app/oracle/oradata/mydb

 

MAN> recover database;

 

Starting recover at 05-SEP-15

using channel ORA_DISK_1

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=7

channel ORA_DISK_1: reading from backup piece /u01/backup/db_full_0lqfujeu_1_1.bkp

channel ORA_DISK_1: piece handle=/u01/backup/db_full_0lqfujeu_1_1.bkp tag=2015-09-05-FULL

channel ORA_DISK_1: restored backup piece 1

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

archived log file name=/u01/app/oracle/flash_recovery_area/MYDB/archivelog/2015_09_05/o1_mf_1_7_byp31mfv_.arc thread=1 sequence=7

channel default: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/MYDB/archivelog/2015_09_05/o1_mf_1_7_byp31mfv_.arc RECID=6 STAMP=889659443

unable to find archived log

archived log thread=1 sequence=8

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

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

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

RMAN-03002: failure of recover command at 09/05/2015 23:37:26

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8 and starting SCN of 991779

 

[oracle@localhost mydb]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 5 23:38:16 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> select instance_name,status from v$instance;

 

INSTANCE_NAME     STATUS

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

mydb         MOUNTED

SQL> recover database using backup controlfile until cancel;

ORA-00279: change 991779 generated at 08/31/2015 01:14:06 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/flash_recovery_area/MYDB/archivelog/2015_09_05/o1_mf_1_8_%u_.arc

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

 

 

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

cancel

Media recovery cancelled.

SQL> alter database open resetlogs;

 

Database altered.

SQL> select instance_name,status from v$instance;

 

INSTANCE_NAME     STATUS

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

mydb         OPEN

 

 

 

 

 

 

 

posted on 2015-09-05 21:13  侯志清  阅读(1599)  评论(0编辑  收藏  举报

导航