本文讲述如何用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. Python调用C模块以及性能分析

    一.c,ctypes和python的数据类型的对应关系 ctypes type ctype Python type c_char char 1-character string c_wchar wch ...

  2. esp8266的STM32驱动

    esp8266的STM32驱动,数据发送接收由DMA完成,释放CPU. 目前只能发送返回消息为成功或失败的AT命令,并判断是否成功,详见esp8266_cmd():其它返回消息不可预知的命令(如查看A ...

  3. ios 下引用第三方类库报错

    在最近刚接触的ios的一个项目中用到了腾讯的登录sdk,从git下下来之后编译报错,找不到文件,文件明明已经加入到项目中,为何找不到,由于刚接触ios开发,所有不知道什么原因,经过Google才知道 ...

  4. GUIText的淡入淡出

    单击按键“A”(随意改变),可以控制GUIText马上显示出来,然后淡出:按住按键“A”,可以使GUIText淡入,如果抬起按键则淡出. FadeInOut.cs using UnityEngine; ...

  5. 【BZOJ 1563】 [NOI2009]诗人小G

    Description Input Output 对于每组数据,若最小的不协调度不超过1018,则第一行一个数表示不协调度若最小的不协调度超过1018,则输出"Too hard to arr ...

  6. js获取当前浏览器页面高度及宽度信息的方法

    var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); var scroll ...

  7. CoInitialize()、CoInitializeEx()和AfxOleInit()区别联系

    CoInitialize()和AfxOleInit() 都是初始化COM库,不同之处在与: OLE是建立在COM之上的技术,层次比COM要高.AfxOleInit()调用的是OleInitialize ...

  8. 自己实现的android树控件,android TreeView

    1.开发原因 在项目中经常需要一个需要一个树状框架,这是非常常见的控件.不过可能是谷歌考虑到android是手机系统,界面宽度有限, 所以只提供了只有二级的ExpandableListView.虽然这 ...

  9. DOCTYPE html PUBLIC 指定了 HTML 文档遵循的文档类型定义

    DOCTYPE html PUBLIC 指定了 HTML 文档遵循的文档类型定义 今天看到一篇CSS应用的一个友好搜索,我按网页上的代码复制.粘贴后预览时总达不到效果,而直接拷贝他的实例却能达到效果, ...

  10. yum安装gcc

    如果服务器是自己的,并且机器就在身边,那什么都不用说了,缺少gcc顶多就是重新放入安装盘,把开发工具包安装上.但是如果是租的服务器,托管服务 方那帮人又搞不懂你说的啥子gcc,要安装gcc实在是太麻烦 ...