將asm上datafile移動到其他的diskgroup或者普通filesystem上

tolilong發表於2013-02-04
1,將asm上datafile移動到其他的diskgroup上[@more@]
[oracle@asm ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Feb 2 08:00:19 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database (not started)

RMAN> startup

Oracle instance started
database mounted
database opened

Total System Global Area 839282688 bytes

Fixed Size 2217992 bytes
Variable Size 549455864 bytes
Database Buffers 285212672 bytes
Redo Buffers 2396160 bytes

RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name ASM

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 670 SYSTEM *** +DATA/asm/system01.dbf
2 510 SYSAUX *** +DATA/asm/sysaux01.dbf
3 75 UNDOTBS1 *** +DATA/asm/undotbs01.dbf
4 5 USERS *** +DATA/asm/users01.dbf
5 1 USERS *** +DATA/asm/users02.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 +DATA/asm/temp01.dbf
backup該檔案到其他的diskgroup上:
RMAN> backup as copy datafile '+DATA/asm/users02.dbf' format '+flash'; (可以使用file_id代替檔案路徑)

Starting backup at 02-FEB-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/asm/users02.dbf
output file name=+FLASH/asm/datafile/users.260.806314045 tag=TAG20130202T080724 RECID=1 STAMP=806314045
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 02-FEB-13
offline需要移動的datafile
RMAN> sql "alter database datafile ''+DATA/asm/users02.dbf'' offline";

sql statement: alter database datafile ''+DATA/asm/users02.dbf'' offline
switch該datafile的name到新的diskgroup上
RMAN> switch datafile "+DATA/asm/users02.dbf" to copy;

datafile 5 switched to datafile copy "+FLASH/asm/datafile/users.260.806314045"
recover已經移動到新diskgroup的檔案
RMAN> recover datafile "+FLASH/asm/datafile/users.260.806314045";

Starting recover at 02-FEB-13
using channel ORA_DISK_1

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

Finished recover at 02-FEB-13
online移動的datafile
RMAN> sql "alter database datafile ''+FLASH/asm/datafile/users.260.806314045'' online";

sql statement: alter database datafile ''+FLASH/asm/datafile/users.260.806314045'' online
再次檢視檔案的路徑
RMAN> report schema;

Report of database schema for database with db_unique_name ASM

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 680 SYSTEM *** +DATA/asm/system01.dbf
2 510 SYSAUX *** +DATA/asm/sysaux01.dbf
3 75 UNDOTBS1 *** +DATA/asm/undotbs01.dbf
4 5 USERS *** +DATA/asm/users01.dbf
5 1 USERS *** +FLASH/asm/datafile/users.260.806314045

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 +DATA/asm/temp01.dbf
刪除以前的檔案
RMAN> delete datafilecopy '+data/asm/users02.dbf';

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK
List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
2 5 A 02-FEB-13 1027887 02-FEB-13
Name: +DATA/asm/users02.dbf


Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=+DATA/asm/users02.dbf RECID=2 STAMP=806314150
Deleted 1 objects
2,將asm上的datafile移動到普通的filesystem上
做的方法和上面的步驟一樣(在做之前確保database為archivelog模式)
RMAN> backup as copy datafile '+DATA/asm/users01.dbf' format '/oradata/user01.dbf';

Starting backup at 02-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/asm/users01.dbf
output file name=/oradata/user01.dbf tag=TAG20130202T082602 RECID=3 STAMP=806315163
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 02-FEB-13

RMAN> sql "alter database datafile 4 offline";

sql statement: alter database datafile 4 offline

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "/oradata/user01.dbf"

RMAN> recover datafile 4;

Starting recover at 02-FEB-13
using channel ORA_DISK_1

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

Finished recover at 02-FEB-13

RMAN> sql "alter database datafile 4 online";

sql statement: alter database datafile 4 online

RMAN> report schema;

Report of database schema for database with db_unique_name ASM

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 680 SYSTEM *** +DATA/asm/system01.dbf
2 510 SYSAUX *** +DATA/asm/sysaux01.dbf
3 75 UNDOTBS1 *** +DATA/asm/undotbs01.dbf
4 5 USERS *** /oradata/user01.dbf
5 1 USERS *** +FLASH/asm/datafile/users.260.806314045

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 +DATA/asm/temp01.dbf
RMAN> delete datafilecopy 4;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK
List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
4 4 A 02-FEB-13 1031361 02-FEB-13
Name: +DATA/asm/users01.dbf


Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=+DATA/asm/users01.dbf RECID=4 STAMP=806315204
Deleted 1 objects

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1060190/,如需轉載,請註明出處,否則將追究法律責任。

相關文章