当前位置:Gxlcms > mysql > 迁移ASM文件之backupascopytablespace

迁移ASM文件之backupascopytablespace

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

在Oracle 10g数据库中,如果需要将ASM实例中一个磁盘组的数据文件转移到另一个磁盘组上。可以采用以前传统的文件系统的方式迁移,

在Oracle 10g数据库中,如果需要将ASM实例中一个磁盘组的数据文件转移到另一个磁盘组上。可以采用以前传统的文件系统的方式迁移,也可以采用表空间级别拷贝的方式迁移。
例如有一个库sdb,users表空间的数据文件都在vg1磁盘组上,现在要移动vg2磁盘组上,,这样操作一下就能完成这个任务。
backup as copy tablespace users format '+vg2';
switch tablespace users to copy;
这两个命令需要在rman下操作,因为只有rman下才能管理ASM磁盘组中的文件。


测试环境为oracle 10.2.0.4 for linux x86,以下为测试过程。

第一步,检查环境,确认users表空间,并将数据库重启到mounted状态。

[oracle@db-172-17-2-8 bdump]$ export ORACLE_SID=sdb
[oracle@db-172-17-2-8 bdump]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Feb 19 16:47:13 2013

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$tablespace
2 ;

NAME
------------------------------
USERS
UNDOTBS1
SYSTEM
SYSAUX
OFCARDQUERY
TEMP

6 rows selected.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size 2084296 bytes
Variable Size 385876536 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14692352 bytes
Database mounted.

第二步,使用rman工具copy表空间,再switch。这个switch操作完成了数据字典的修改。

[oracle@db-172-17-2-8 bdump]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Feb 19 16:48:20 2013

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

connected to target database: SDB (DBID=2245827732, not open)

RMAN> backup as copy tablespace users format '+vg2';

Starting backup at 19-FEB-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+VG1/sdb/users02.dbf
output filename=+VG2/sdb/datafile/users.285.807814137 tag=TAG20130219T164857 recid=17 stamp=807814139
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+VG1/sdb/users01.dbf
output filename=+VG2/sdb/datafile/users.284.807814141 tag=TAG20130219T164857 recid=18 stamp=807814141
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 19-FEB-13

RMAN> switch tablespace users to copy;

datafile 4 switched to datafile copy "+VG2/sdb/datafile/users.284.807814141"
datafile 5 switched to datafile copy "+VG2/sdb/datafile/users.285.807814137"

RMAN> recover database;

Starting recover at 19-FEB-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 19-FEB-13

linux

人气教程排行