本文讲述如何用rman将一个库迁移到另一个服务器上。

服务器A:linux es4 + oracle9204 (源)
服务器B:linux es4 + oracle9204 (目标)

一、创建目录

为了简单起见,在服务器B上建立与A相同的目录结构。如果因为空间或其他原因,可以考虑用软链接来实现目录结构的统一。
如果实在不能做到的话,可以用rman的set newname来实现数据的重定位。

[oracle@datasrv2 ~]$ mkdir -p /data/oradata/gpodb
[oracle@datasrv2 dbback]$ mkdir -p /data/dbback/gpofullbak
[oracle@datasrv2 admin]$ mkdir -p /data/admin/gpodb/udump
[oracle@datasrv2 admin]$ mkdir -p /data/admin/gpodb/bdump
[oracle@datasrv2 admin]$ mkdir -p /data/admin/gpodb/cdump
[oracle@datasrv2 admin]$ mkdir -p /data/archivelog/gpodb --归档

二、全库备份

[oracle@datasrv1 gpofullbak]$ export ORACLE_SID=gpodb
[oracle@datasrv1 gpofullbak]$ rman target /

Recovery Manager: Release 9.2.0.4.0 - 64bit Production

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

connected to target database: GPODB (DBID=1026346035)

RMAN> run{
2> CONFIGURE CONTROLFILE AUTOBACKUP ON;
3> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/dbback/gpofullbak/%F';
4> allocate channel c1 type disk format '/data/dbback/gpofullbak/full_%U';
5> backup database tag 'full_gpodb_data' FILESPERSET 10 PLUS ARCHIVELOG FILESPERSET 20 DELETE ALL INPUT;
6> release channel c1;
7> }

using target database controlfile instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/dbback/gpofullbak/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/dbback/gpofullbak/%F';
new RMAN configuration parameters are successfully stored

allocated channel: c1
channel c1: sid=15 devtype=DISK

Starting backup at 25-4?? -07
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=97 recid=68 stamp=620843481
channel c1: starting piece 1 at 25-4?? -07
channel c1: finished piece 1 at 25-4?? -07
piece handle=/data/dbback/gpofullbak/full_26ig2kep_1_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c1: deleting archive log(s)
archive log filename=/data/archivelog/gpodb/1_97.dbf recid=68 stamp=620843481
Finished backup at 25-4?? -07

Starting backup at 25-4?? -07
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00007 name=/data/oradata/gpodb/ndindex01.dbf
input datafile fno=00009 name=/data/oradata/gpodb/ndindex03.dbf
input datafile fno=00011 name=/data/oradata/gpodb/ndindex05.dbf
input datafile fno=00013 name=/data/oradata/gpodb/ndmain02.dbf
input datafile fno=00015 name=/data/oradata/gpodb/ndmain04.dbf
input datafile fno=00017 name=/data/oradata/gpodb/ndmain06.dbf
input datafile fno=00004 name=/data/oradata/gpodb/indx01.dbf
input datafile fno=00003 name=/data/oradata/gpodb/drsys01.dbf
input datafile fno=00005 name=/data/oradata/gpodb/tools01.dbf
input datafile fno=00002 name=/data/oradata/gpodb/undotbs01.dbf
channel c1: starting piece 1 at 25-4?? -07
channel c1: finished piece 1 at 25-4?? -07
piece handle=/data/dbback/gpofullbak/full_27ig2ker_1_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:05:45
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00006 name=/data/oradata/gpodb/users01.dbf
input datafile fno=00008 name=/data/oradata/gpodb/ndindex02.dbf
input datafile fno=00010 name=/data/oradata/gpodb/ndindex04.dbf
input datafile fno=00012 name=/data/oradata/gpodb/ndmain01.dbf
input datafile fno=00014 name=/data/oradata/gpodb/ndmain03.dbf
input datafile fno=00016 name=/data/oradata/gpodb/ndmain05.dbf
input datafile fno=00001 name=/data/oradata/gpodb/system01.dbf
channel c1: starting piece 1 at 25-4?? -07
channel c1: finished piece 1 at 25-4?? -07
piece handle=/data/dbback/gpofullbak/full_28ig2kpk_1_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:05:35
Finished backup at 25-4?? -07

Starting backup at 25-4?? -07
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=98 recid=69 stamp=620844163
channel c1: starting piece 1 at 25-4?? -07
channel c1: finished piece 1 at 25-4?? -07
piece handle=/data/dbback/gpofullbak/full_29ig2l43_1_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c1: deleting archive log(s)
archive log filename=/data/archivelog/gpodb/1_98.dbf recid=69 stamp=620844163
Finished backup at 25-4?? -07

Starting Control File and SPFILE Autobackup at 25-4?? -07
piece handle=/data/dbback/gpofullbak/c-1026346035-20070425-07 comment=NONE
Finished Control File and SPFILE Autobackup at 25-4?? -07

released channel: c1

RMAN> exit

Recovery Manager complete.

--创建spfile
[oracle@datasrv1 gpofullbak]$ sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on D??úèy 4?? 25 10:48:17 2007

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

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production

SQL> create pfile from spfile;

File created.

三、传送文件
把文件放到B服务器上的同样目录下。
[oracle@datasrv1 gpofullbak]$ scp * 172.25.13.51:`pwd`
oracle@172.25.13.51's password: 
c-1026346035-20070425-07 100% 1696KB 1.7MB/s 00:01 
full_26ig2kep_1_1 100% 901KB 900.5KB/s 00:00 
full_27ig2ker_1_1 100% 1591MB 11.0MB/s 02:25 
full_28ig2kpk_1_1 100% 1281MB 11.0MB/s 01:57 
full_29ig2l43_1_1 100% 140KB 139.5KB/s 00:00 
[oracle@datasrv1 dbs]$ scp initgpodb.ora 172.25.13.51:`pwd`
oracle@172.25.13.51's password: 
initgpodb.ora 100% 1021 1.0KB/s 00:00

[oracle@datasrv1 dbs]$ scp orapwgpodb 172.25.13.51:`pwd`
oracle@172.25.13.51's password: 
orapwgpodb 100% 1536 1.5KB/s 00:00

四、在B机恢复

[oracle@datasrv2 dbback]$ export ORACLE_SID=gpodb
[oracle@datasrv2 dbback]$ sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on D??úèy 4?? 25 11:00:50 2007

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

Connected to an idle instance.

SQL> startup pfile=?/dbs/init@.ora nomount
ORACLE instance started.

Total System Global Area 2585760448 bytes
Fixed Size 746176 bytes
Variable Size 486539264 bytes
Database Buffers 2097152000 bytes
Redo Buffers 1323008 bytes

SQL> exit
[oracle@datasrv2 gpofullbak]$ rman target /

Recovery Manager: Release 9.2.0.4.0 - 64bit Production

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

connected to target database: gpodb (not mounted)

RMAN> set dbid=1026346035;

executing command: SET DBID

RMAN> restore controlfile from '/data/dbback/gpofullbak/c-1026346035-20070425-07';

Starting restore at 25-4?? -2007 16:57:38

using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=12 devtype=DISK
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/data/oradata/gpodb/control01.ctl
output filename=/data/oradata/gpodb/control02.ctl
output filename=/data/oradata/gpodb/control03.ctl
Finished restore at 25-4?? -2007 16:57:46

RMAN> alter database mount;

database mounted

RMAN> restore database from tag='full_gpodb_data';

Starting restore at 25-4?? -2007 16:58:39

using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /data/oradata/gpodb/undotbs01.dbf
restoring datafile 00003 to /data/oradata/gpodb/drsys01.dbf
restoring datafile 00004 to /data/oradata/gpodb/indx01.dbf
restoring datafile 00005 to /data/oradata/gpodb/tools01.dbf
restoring datafile 00007 to /data/oradata/gpodb/ndindex01.dbf
restoring datafile 00009 to /data/oradata/gpodb/ndindex03.dbf
restoring datafile 00011 to /data/oradata/gpodb/ndindex05.dbf
restoring datafile 00013 to /data/oradata/gpodb/ndmain02.dbf
restoring datafile 00015 to /data/oradata/gpodb/ndmain04.dbf
restoring datafile 00017 to /data/oradata/gpodb/ndmain06.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/data/dbback/gpofullbak/full_27ig2ker_1_1 tag=FULL_GPODB_DATA params=NULL
channel ORA_DISK_1: restore complete
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data/oradata/gpodb/system01.dbf
restoring datafile 00006 to /data/oradata/gpodb/users01.dbf
restoring datafile 00008 to /data/oradata/gpodb/ndindex02.dbf
restoring datafile 00010 to /data/oradata/gpodb/ndindex04.dbf
restoring datafile 00012 to /data/oradata/gpodb/ndmain01.dbf
restoring datafile 00014 to /data/oradata/gpodb/ndmain03.dbf
restoring datafile 00016 to /data/oradata/gpodb/ndmain05.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/data/dbback/gpofullbak/full_28ig2kpk_1_1 tag=FULL_GPODB_DATA params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 25-4?? -2007 17:09:24

RMAN> recover database;

Starting recover at 26-4?? -07
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=8 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=98
channel ORA_DISK_1: restored backup piece 1
piece handle=/data/dbback/gpofullbak/full_29ig2l43_1_1 tag=TAG20070425T164243 params=NULL
channel ORA_DISK_1: restore complete
archive log filename=/data/archivelog/gpodb/1_98.dbf thread=1 sequence=98
unable to find archive log
archive log thread=1 sequence=99
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/26/2007 09:58:41
RMAN-06054: media recovery requesting unknown log: thread 1 scn 32837861

RMAN> alter database open resetlogs;

database opened

由于联机日志没有传送过来,一般需要用resetlogs打开数据库。

RMAN数据库异机迁移的更多相关文章

  1. RMAN数据库异机迁移步骤

    --RMAN数据库异机迁移步骤----------------------------2013/09/28 测试环境:AIX+ora11g   一. source数据库准备.   1.获取数据文件编号 ...

  2. 基于RMAN从活动数据库异机克隆(rman duplicate from active DB)

    Oracle 11g RMAN能够实现基于活动数据库进行异机克隆,从而省去需要先备份再ftp到辅助服务器的过程.这一切可以全部交给Oracle来搞定.在克隆期间,Oracle会读取Target DB的 ...

  3. 基于RMAN的异机数据库克隆(rman duplicate)

    对于基于生产环境下的数据库的版本升级或者测试新的应用程序的性能及其影响,备份恢复等等,我们可以采取从生产环境以克隆的方式将其克隆到本地而不影响生产数据库的正常使用.实现这个功能我们可以借助rman d ...

  4. 利用rman进行异机还原(目录相同)

    利用rman进行异机还原(目录相同) 源始库:192.168.201.2 目标库:192.168.201.3 --192.168.201.2 --rman [oracle@db01 ~]$ rman ...

  5. Oracle数据库异机升级

    环境: A机:RHEL5.5 + Oracle 10.2.0.4 B机:RHEL5.5 需求: A机10.2.0.4数据库,在B机升级到11.2.0.4,应用最新PSU补丁程序. 目录: 一. 确认是 ...

  6. openStack 重新resize时会进行重新调度,可能在本机Resize 扩展资源,也可能存在的情况时 ,新扩展的资源在当前节点不足分配,整个虚拟机将进行迁移调度,进行异机迁移时需要迁移 的两台主机间能使用nova系统用户经passless登录

    openStack 重新resize时会进行重新调度,可能在本机Resize 扩展资源,也可能存在的情况时 ,新扩展的资源在当前节点不足分配,整个虚拟机将进行迁移调度,进行异机迁移时需要迁移 的两台主 ...

  7. 使用rman备份异机恢复数据库

    一.RMAN备份源库注意点: 最好保留rman备份日志 $rman target / log=backup.log RMAN>run { allocate channel t1 type dis ...

  8. Hyper-V安装Oracle Linux6_4 Oracle db 12c并使用rman做异机恢复

    本文记录在Windows Server 2012 R2上安装Oracle Enterprise Linux 6.4以及使用RMAN进行进行异机恢复的过程. Windows服务器增加Hyper-V功能 ...

  9. RMAN - 备份异机恢复

    OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...

随机推荐

  1. console.log的使用

    相比alert他的优点是: 他能看到结构话的东西,如果是alert,淡出一个对象就是[object object],但是console能看到对象的内容. console不会打断你页面的操作,如果用al ...

  2. 信息化的“五观”与“N为”

    系统观:联系的总体的看 生产力工具观:人与工具关系 马克思政治经济学 辨证观:发展的看 技术观:第一生产力  改变生产生活(生存)方式 信息论观:“人”联网 控制论 工程观:群体合作的智力游戏论

  3. Linux学习笔记(5)-进程管理

    进程简介 进程是正在执行的一个程序或命令,每一个进程都有自己的地址空间,并占有一定的系统资源.感性的认识,进程就是一个正在运行的程序 进程管理的作用 判断服务器的运行状态 查看系统中有哪些进程 杀死进 ...

  4. 字符串截取 方法 String b=a.substring(0, a.indexOf("乘坐"));

    String b=a.substring(0, a.indexOf("乘坐"));

  5. Buffer

    Buffer 我们用原有 IO 读写文件应该不会陌生了,顺带回顾一下,大致两种: 1. 在 InputStream 或 OutputStream 上读写字节或字节数组,读 InputStream 时用 ...

  6. Detect loop in a singly linked list

    去Twitter面试的被问到这个问题,当时只想到了用HashMap的办法,这种办法时间复杂度O(n),空间复杂度是O(n), 更好的办法是用 FastRunner / SlowRunner appro ...

  7. PE 文件

    一.PE文件基本结构 上图便是PE文件的基本结构.(注意:DOS MZ Header和部分PE header的大小是不变的:DOS stub部分的大小是可变的.) 二.Section 详解 一个PE文 ...

  8. console中应用MFC类的方法

    1.添加#include <afx.h>或者<afxwin.h> 这时会报错1>c:\program files\microsoft visual studio 8\vc ...

  9. VS2013与MySql建立连接;您的项目引用了最新实体框架;但是,找不到数据链接所需的与版本兼容的实体框架数据库 EF6使用Mysql的技巧

    因为之前都是看别人的项目,而没有自己从头到尾建立一个项目,所以这次尝试搭建时就出现了问题,主要是ASP.Net MVC项目中VS2013和MySql的连接. 第一个问题: 数据库表已建好,相应的数据库 ...

  10. Ubuntu 12.04安装字体

    http://www.2cto.com/os/201210/160645.html 安装方法,终端输入:  $ sudo thunar /usr/share/fonts/truetype  待ture ...