首页 > 代码库 > RMAN数据库异机迁移
RMAN数据库异机迁移
本文讲述如何用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数据库异机迁移