当前位置:Gxlcms > mysql > 利用RMAN在文件系统与ASM之间迁移数据库

利用RMAN在文件系统与ASM之间迁移数据库

时间:2021-07-01 10:21:17 帮助过:12人阅读

在Oracle10g中在操作系统与ASM之间不能使用复制命令(11g有相关复制命令)比如cp操作来复制文件,为了使用ASM来管理已经存在的数

在Oracle10g中在操作系统与ASM之间不能使用复制命令(11g有相关复制命令)比如cp操作来复制文件,为了使用ASM来管理已经存在的数据库必须将数据库迁移到ASM中。可以通过RMAN来完成这项操作。假设在文件系统和ASM磁盘组中有足够的空间来存储整个数据库可以将数据库从文件系统中直接迁移到ASM中。如果在ASM和文件系统同时没有足够的空间来存储整个数据库,可以将数据库备份到磁带,使用旧的磁盘来创建ASM磁盘组并使用磁带备份将数据库还原到ASM中。

如果文件系统和ASM同时有足够的空间来存储整个数据库,可以不使用磁带过渡直接将数据库迁移到ASM中。在这个例子中目标ASM磁盘组为+DISK1。在迁移的过程中所有的闪回日志将会被丢弃,,因此,数据库中的任何受保护还原点都将变为无效。在执行迁移之前需要将其删除。

--------------------------------------推荐阅读 --------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

--------------------------------------分割线 --------------------------------------

将数据库从文件系统迁移到ASM的操作步骤如下:
1.记录数据库迁移之前的数据文件,控制文件,联机重做日志文件的文件名
SQL> select name,status from v$datafile;

NAME STATUS
-------------------------------------------------------------------------------- -------
/u01/app/oracle/oradata/test/system01.dbf SYSTEM
/u01/app/oracle/oradata/test/undotbs01.dbf ONLINE
/u01/app/oracle/oradata/test/sysaux01.dbf ONLINE
/u01/app/oracle/oradata/test/users01.dbf ONLINE
/u01/app/oracle/oradata/test/example01.dbf ONLINE
/u01/app/oracle/oradata/test/tspitr01.dbf ONLINE
/u01/app/oracle/oradata/test/test01.dbf ONLINE

7 rows selected

SQL> select member,status from v$logfile;

MEMBER STATUS
-------------------------------------------------------------------------------- -------
/u01/app/oracle/oradata/test/redo03.log
/u01/app/oracle/oradata/test/redo02.log
/u01/app/oracle/oradata/test/redo01.log

SQL> show parameter control_files

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/test/control01.ctl,
/u01/app/oracle/oradata/test/control02.ctl,
/u01/app/oracle/oradata/test/control03.ctl


2.将数据库文件作为副本备份到ASM磁盘组
[oracle@oracle11g ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';
[oracle@oracle11g ~]$ rman target catalog

Recovery Manager: Release 10.2.0.5.0 - Production on Wed Apr 1 16:06:19 2015

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

connected to target database: TEST (DBID=2168949517)
connected to recovery catalog database

RMAN> backup as copy incremental level 0 database format '+DISK1' tag 'DB_ASM_MIGRATION';

Starting backup at 2015-04-01 16:06:27
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/test/system01.dbf
output filename=+DISK1/test/datafile/system.266.875894803 tag=DB_ASM_MIGRATION recid=17 stamp=875894833
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/test/sysaux01.dbf
output filename=+DISK1/test/datafile/sysaux.267.875894845 tag=DB_ASM_MIGRATION recid=18 stamp=875894865
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/test/example01.dbf
output filename=+DISK1/test/datafile/example.265.875894871 tag=DB_ASM_MIGRATION recid=19 stamp=875894883
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf
output filename=+DISK1/test/datafile/tspitr.264.875894885 tag=DB_ASM_MIGRATION recid=20 stamp=875894892
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/test/undotbs01.dbf
output filename=+DISK1/test/datafile/undotbs1.263.875894899 tag=DB_ASM_MIGRATION recid=21 stamp=875894903
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/test/users01.dbf
output filename=+DISK1/test/datafile/users.262.875894907 tag=DB_ASM_MIGRATION recid=22 stamp=875894907
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf
output filename=+DISK1/test/datafile/test.261.875894909 tag=DB_ASM_MIGRATION recid=23 stamp=875894910
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-04-01 16:08:30

人气教程排行