RMAN数据库异机迁移

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

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

一、创建目录

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

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

二、全库备份

[[email protected] gpofullbak]$ export ORACLE_SID=gpodb
[[email protected] 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
[[email protected] 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服务器上的同样目录下。
[[email protected] gpofullbak]$ scp * 172.25.13.51:`pwd`
[email protected]‘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 
[[email protected] dbs]$ scp initgpodb.ora 172.25.13.51:`pwd`
[email protected]‘s password: 
initgpodb.ora 100% 1021 1.0KB/s 00:00

[[email protected] dbs]$ scp orapwgpodb 172.25.13.51:`pwd`
[email protected]‘s password: 
orapwgpodb 100% 1536 1.5KB/s 00:00

四、在B机恢复

[[email protected] dbback]$ export ORACLE_SID=gpodb
[[email protected] 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/[email protected] 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
[[email protected] 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打开数据库。

时间: 2024-10-29 19:13:44

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

RMAN数据库异机迁移步骤

--RMAN数据库异机迁移步骤----------------------------2013/09/28 测试环境:AIX+ora11g   一. source数据库准备.   1.获取数据文件编号和路径   SQL> select file_id,file_name from dba_data_files order by file_id;      FILE_ID FILE_NAME ---------- ------------------------------------------

rman 冷备份异机迁移

rman 作为 oracle 推荐的备份.恢复方式,我们常使用它来进行异机迁移数据库. 网上的攻略都是 rman 的热备份异机迁移,相比冷备份的异机迁移需要多备份归档(未归档)日志文件.联机日志文件,操作步骤较为复杂. 如果是可以停机的数据库,更推荐使用 mount 方式下的冷备份来做异机迁移. 写了一个迁移文件,以备后用. Part1 Env { 'first database':{ 'os':'suse11' 'oracle_version':'11gr2' } 'second databa

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

Oracle 11g RMAN能够实现基于活动数据库进行异机克隆,从而省去需要先备份再ftp到辅助服务器的过程.这一切可以全部交给Oracle来搞定.在克隆期间,Oracle会读取Target DB的所有数据结构,无须人为的干预(不同的磁盘系统,文件路径与文件名要指定转换方式).尽管如此,对于生产环境数据库在整个克隆期间性能会下降,其次在Target Server与Auxiliary Server中会产生较大的网络流量.如果这些可以接受的话,从活动数据库进行异机克隆是一个不错的选择.本文首先描述

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

对于基于生产环境下的数据库的版本升级或者测试新的应用程序的性能及其影响,备份恢复等等,我们可以采取从生产环境以克隆的方式将其克隆到本地而不影响生产数据库的正常使用.实现这个功能我们可以借助rman duplicate方式以及其简单的方式来完成.duplicate方式不同于OS级别的备份,它会为辅助数据库(克隆出来的数据库)生成一个新的dbid,而能够同时将目标数据库(原数据库)与辅助数据库注册到同一个恢复目录.本文描述了使用rman duplicate实现异机数据库克隆. 1.RMAN支持的du

在Oracle Database 12.1 中异机迁移恢复数据库【实战】

平台环境:源OS:Oracle Linux 7.3源DB:Oracle Database 12.1.0.2 目标OS:Oracle Linux 7.3目标DB:Oracle Database 12.1.0.2 一.准备工作1.查询当前SCN col current_scn form 99999999999999 SQL> select current_scn from v$database;     CURRENT_SCN ---------------   5965538762695 2.显示

RMAN - 备份异机恢复

OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production ① RMAN异机恢复的时候,db_name必须相同.如果想要改别的实例命,可以在RMAN恢复成功后,用 nid 命令修改. ② 恢复路径与源库不相同,在restore时用set指定新位置,并用switch logfile all 将信息更新到controlfile文

ASM磁盘组异机迁移

环境: Source: OS:redhat 6.3 DB:Oralce RAC 11.2.4.0 destination: OS:redhat 6.3 DB:Oralce RAC 11.2.4.0 背景:客户的PC机上面有两个实例,压力太大,需要迁移出一个实例.数据量TB级别,因为同平台,同版本,外挂存储.所以这里采用直接迁移asm磁盘组 操作前需要注意的: 1.Voting Disk是单独的盘,不包含需要迁移的数据 话不多,这里模拟出来分享给大家(PS:我的原库和目标库的主机名是一样的,第三步

Oracle之使用rman进行异机恢复测试记录

本次测试目的是从生产数据库导出rman备份然后在测试数据库恢复 1,拷贝备份至相应目录 2,进入rman rman target \ 3,关闭数据库 shutdown 4,以nomount模式启动数据库 startup nomount 5,恢复控制文件 restore controlfile from ' /home/oracle/rman_backup/cf_c-1383295282-20171102-00'; 6,挂载数据库 alter database mount; 7,设置catalog

ORACLE中采用rman备份异机恢复数据库详细过程

场景:        有一个生产库的用户下面所有的表都不见了,怀疑人为被删除了,现在需要用备份去恢复下,找出原来的表,线上是oracle dataguard环境,有全库备份文件,准备去测试库恢复一下. 1,从生产库上copy好全备份文件恢复数据库需要准备的文件:rman完整备份(包括数据文件.日志文件.控制文件.参数文件),记录源数据库的DBID 安装的测试数据库ORACLE数据库软件并创建跟源数据库同名和数据库SID并修改数据库DBID跟源数据库DBID一样,创建跟源数据库服务器相同的数据文件