使用rman进行数据库迁移

本文详细阐述了在Oracle数据库环境中,通过使用RMAN命令进行数据库的恢复与迁移操作的流程与注意事项,包括备份策略设置、控制文件备份、备份集复制、控制文件恢复、备份集加载与数据库恢复等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

51上操作:
RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/db/oracle10g/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/db/oracle10g/bakup/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/db/oracle10g/product/10.2.0/db/dbs/snapcf_peak.f'; # default

RMAN>backup database;

Starting backup at 13-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=307 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/db/oracle10g/oradata/peak/system01.dbf
input datafile fno=00003 name=/db/oracle10g/oradata/peak/sysaux01.dbf
input datafile fno=00002 name=/db/oracle10g/oradata/peak/undotbs01.dbf
input datafile fno=00005 name=/db/oracle10g/oradata/test/test01.dbf
input datafile fno=00004 name=/db/oracle10g/oradata/peak/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-MAY-12
channel ORA_DISK_1: finished piece 1 at 13-MAY-12
piece handle=/db/oracle10g/bakup/05narvr6_1_1 tag=TAG20120513T070406 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 13-MAY-12

Starting Control File Autobackup at 13-MAY-12
piece handle=/db/oracle10g/c-1833158544-20120513-01 comment=NONE
Finished Control File Autobackup at 13-MAY-12


53上操作:
[oracle@node53 db]$ mkdir -p /db/oracle10g/bakup/
[oracle@node53 db]$ cd /db/oracle10g/bakup/
[oracle@node53 bakup]$pwd
/db/oracle10g/bakup/
[oracle@node53 bakup]$
[oracle@node53 bakup]$ ll
总计 0

复制备份集到53服务器的相应目录下:
[oracle@node53 bakup]$scp 192.168.11.51:/db/oracle10g/bakup/05narvr6_1_1 .
oracle@192.168.11.51'spassword:
05narvr6_1_1                                                                                     100%  527MB   6.8MB/s   01:17   
[oracle@node53 bakup]$ls
05narvr6_1_1
[oracle@node53 bakup]$ cd /db/oracle10g/
[oracle@node53 oracle10g]$ll
总计 20
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 admin
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 flash_recovery_area
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 oradata
drwxr-x--- 6 oracle oinstall 4096 05-13 05:44 oraInventory
drwxr-xr-x 3 oracle oinstall 4096 05-13 05:44 product

复制控制文件的备份集到53服务上的相应目录下:
[oracle@node53 oracle10g]$ scp 192.168.11.51:/db/oracle10g/c-1833158544-20120513-01 .
oracle@192.168.11.51'spassword:
c-1833158544-20120512-01                                                                           100% 6976KB   6.8MB/s   00:01   
[oracle@node53 oracle10g]$ ll
总计 7008
drwxr-x--- 3 oracle oinstall    4096 05-13 05:44 admin
-rw-r----- 1 oracle oinstall 7143424 05-13 05:52 c-1833158544-20120512-01
drwxr-x--- 3 oracle oinstall    4096 05-13 05:44 flash_recovery_area
drwxr-x--- 3 oracle oinstall    4096 05-13 05:44 oradata
drwxr-x--- 6 oracle oinstall    4096 05-13 05:44 oraInventory
drwxr-xr-x 3 oracle oinstall    4096 05-13 05:44 product

[oracle@node53 dbs]$ sqlplus  / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 06:02:08 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL>select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
#这里没有TEST表空间

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Current log sequence           2
SQL>
SQL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              75499088 bytes
Database Buffers          205520896 bytes
Redo Buffers                2973696 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL>alter database open;

Database altered.

SQL>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 oracle10g]$rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 13 05:54:19 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: PEAK (DBID=1833158544)

RMAN> exit


Recovery Manager complete.
[oracle@node53 oracle10g]$cd product/10.2.0/db/dbs/
[oracle@node53 dbs]$ll
总计 48
-rw-r----- 1 oracle oinstall  1544 05-13 05:45 hc_peak.dat
-rw-r----- 1 oracle oinstall 12920 05-13 05:45 initdw.ora
-rw-r----- 1 oracle oinstall  8385 05-13 05:45 init.ora
-rw-r--r-- 1 oracle oinstall   991 05-13 05:45 initpeak.ora
-rw-r----- 1 oracle oinstall    24 05-13 05:45 lkPEAK
-rw-r----- 1 oracle oinstall  1536 05-13 05:45 orapwpeak
-rw-r----- 1 oracle oinstall  2560 05-13 05:53 spfilepeak.ora
[oracle@node53 dbs]$sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 05:55:26 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL>create pfile from spfile;

File created.

SQL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 dbs]$ ll
总计 48
-rw-r----- 1 oracle oinstall  1544 05-13 05:45 hc_peak.dat
-rw-r----- 1 oracle oinstall 12920 05-13 05:45 initdw.ora
-rw-r----- 1 oracle oinstall  8385 05-13 05:45 init.ora
-rw-r--r-- 1 oracle oinstall   991 05-13 05:55 initpeak.ora
-rw-r----- 1 oracle oinstall    24 05-13 05:45 lkPEAK
-rw-r----- 1 oracle oinstall  1536 05-13 05:45 orapwpeak
-rw-r----- 1 oracle oinstall  2560 05-13 05:53 spfilepeak.ora
[oracle@node53 dbs]$

#要注意,备份控制文件的时候用的SID,在备库上也要用同样的SID.

[oracle@node53 dbs]$sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 05:55:32 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>startup nomount pfile='/db/oracle10g/product/10.2.0/db/dbs/initpeak.ora';
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              75499088 bytes
Database Buffers          205520896 bytes
Redo Buffers                2973696 bytes
SQL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 13 05:57:13 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: peak (not mounted)

RMAN>restore controlfile to '/db/oracle10g/oradata/peak/control01.ctl' from '/db/oracle10g/c-1833158544-20120512-01';  
#注意:from后面就是从51拷贝过来的控制文件的备份集。to后面的那句可以不写,有时写了反而麻烦。
#可直接写为restore controlfile from '/db/oracle10g/c-1833158544-20120512-01';  
Starting restore at 13-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 13-MAY-12

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


#向控制文件中加载备份集:
RMAN> catalog start with '/db/oracle10g/c-1833158544-20120512-01';  

Starting implicit crosscheck backup at 13-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 13-MAY-12

Starting implicit crosscheck copy at 13-MAY-12
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 13-MAY-12

searching for all files in the recovery area
cataloging files...
no files cataloged

searching for all files that match the pattern /db/oracle10g/c-1833158544-20120512-01

List of Files Unknown to the Database
=====================================
File Name: /db/oracle10g/c-1833158544-20120512-01

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /db/oracle10g/c-1833158544-20120512-01

RMAN> crosscheck backup ;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/db/oracle10g/bakup/05narvr6_1_1 recid=1 stamp=783113788
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/db/oracle10g/c-1833158544-20120512-01 recid=2 stamp=783151167
Crosschecked 2 objects


RMAN> report schema;

RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    480      SYSTEM               ***     /db/oracle10g/oradata/peak/system01.dbf
2    25       UNDOTBS1             ***     /db/oracle10g/oradata/peak/undotbs01.dbf
3    240      SYSAUX               ***     /db/oracle10g/oradata/peak/sysaux01.dbf
4    5        USERS                ***     /db/oracle10g/oradata/peak/users01.dbf
5    0        TEST                 ***     /db/oracle10g/oradata/test/test01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /db/oracle10g/oradata/peak/temp01.dbf

RMAN>

RMAN>run
2> {
3> set newname for datafile 1 to '/db/oracle10g/oradata/peak/system01.dbf';
4> set newname for datafile 2 to '/db/oracle10g/oradata/peak/undotbs01.dbf';
5> set newname for datafile 3 to '/db/oracle10g/oradata/peak/sysaux01.dbf';
6> set newname for datafile 4 to '/db/oracle10g/oradata/peak/users01.dbf';
set newname for datafile 5 to '/db/oracle10g/oradata/test/test01.dbf';
8> restore database;
9> switch datafile all;
10> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 13-MAY-12
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 00001 to /db/oracle10g/oradata/peak/system01.dbf
restoring datafile 00002 to /db/oracle10g/oradata/peak/undotbs01.dbf
restoring datafile 00003 to /db/oracle10g/oradata/peak/sysaux01.dbf
restoring datafile 00004 to /db/oracle10g/oradata/peak/users01.dbf
restoring datafile 00005 to /db/oracle10g/oradata/test/test01.dbf
channel ORA_DISK_1: reading from backup piece /db/oracle10g/bakup/05narvr6_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/db/oracle10g/bakup/05narvr6_1_1 tag=TAG20120512T193628
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 13-MAY-12


RMAN> alter database open resetlogs;

database opened

RMAN>

RMAN> exit


Recovery Manager complete.
[oracle@node53 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 06:02:08 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL>select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
TEST

#这里有TEST表空间,恢复成功

6 rows selected.

SQL>




更多参考:

AIX mount RedHat的NFS

误删除/dev/dsk 和/dev/rdsk 下的文件怎么办?

unary operator expected

bash: /root/.bash_profile: line 15: syntax error: unexpected end of file

Linux下如何查看文件秒级修改及访问时间

EM乱码解决

linux里端口转发

windows xp 下使用FileZilla密钥

java.net.SocketException: Too many open files 问题的解决办法

UNExcepted inconsistency; run fsck manually

如何修改linux的mac地址?

mysqldump: Got error: 1066: Not unique table/alias

rsync详解一

rsync详解二

更改mysql的默认安装目录

httpd: apr_sockaddr_info_get() failed for centos1113

Real domain name required for sender address

Connection refused by [127.0.0.1]

MySQL bin_log文件占用空间太大

Centos 5 多路径配置步骤

rpc mount export: RPC: Unable to receive; errno = No route to host

nohup和screen的比较

vmware workstation 8 共享磁盘




更多参考:


the specified nodes are not clusterable

根据rowid删除表中重复的行

Agent process exited abnormally during initialization

一次字符乱码的解决过程

rman实验(一)

rman实验(二)

ORA-00600: internal error code, arguments: [keltnf

ORA-00600: ORA-12012 ORA-08102解决

linux下完全删除oracle

INFO: /usr/bin/ld: crt1.o: No such file: No such file or directory

centos4.8_64上安装oracle10201建库报ORA-12547

EM乱码解决

ORA-31613 Master process DM00 failed during startup

ORA-00600: internal error code, arguments: [4194], [29], [27], [], [], [], [], []

ORA-24324 ORA-01041 ORA-03113

centos5.3升级oracle

pdksh-5.2.14-36.el5.i386.rpm

使用rman进行数据库迁移

oracle10.2.0.1升级到10.2.0.4报错

Upgrade Oracle 10g from 10.2.0.1 to 10.2.0.4 (Single Instance)

改oracle的name和dbid

修改oracle实例名

Solaris8上迁移oracle8i---上

Solaris8上迁移oracle8i---下

未备份归档日志导致数据丢失的实验

使用NBU进行数据库迁移

catalog备份数据库

RMAN FORMAT字符串格式化

Error: can not register my instance state - -1

not all alterations performed

The ASM instance configured on the local node is a single-instance ASM

/u01/crs102/bin/crsctl.bin: error while loading shared libraries: libstdc++.so.5: cannot open shared

Initializing the Oracle ASMLib driver: [FAILED]

ORA-00245: control file backup operation failed

WARNING: failed to read mirror side 1 of virtual extent 229 logical extent

模拟恢复参数文件

Interface eth0 checked failed

import server uses ZHS16GBK character set (possible charset conversion)





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值