利用RMAN將非ASM檔案移動到ASM裡 - [ASM]

season0891發表於2011-04-13

利用RMAN將非ASM檔案移動到ASM裡 - [ASM]

:轉載時請以超連結形式標明文章原始出處和作者資訊及本宣告
http://oracler.blogbus.com/logs/39754517.html

ASM是將來的趨勢,這段時間一直在研究ASM。進入正題。

1、要移動的資料檔案

SQL> select file_name from dba_data_files where tablespace_name='USERS';

 FILE_NAME

----------------------------------------

+GQISJ/gqsj/datafile/users.264.686852255

+GQISJ/gqsj/datafile/users.268.687200231

+GQ/tmp/user01

/opt/app/oracle/user01.dbf

 

2、連線到RMAN

[oracle@lee dbs]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Fri May 22 17:46:40 2009

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

connected to target database: GQSJ (DBID=2809640057)

RMAN>

 

3、把表空間置為只讀狀態

RMAN> sql'alter database datafile 7 offline';

using target database control file instead of recovery catalog

sql statement: alter database datafile 7 offline

RMAN>

 

4、複製資料檔案到ASM磁碟組

RMAN> backup as copy datafile 7 format'+gqisj';

Starting backup at 22-MAY-09

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=143 devtype=DISK

channel ORA_DISK_1: starting datafile copy

input datafile fno=00007 name=/opt/app/oracle/user01.dbf

output filename=+GQISJ/gqsj/datafile/users.269.687549245 tag=TAG20090522T175403 recid=1 stamp=687549244

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 22-MAY-09

 

5switch資料檔案

RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy "+GQISJ/gqsj/datafile/users.269.687549245"

 

6、把資料檔案置為ONLINE

RMAN> sql'alter database datafile 7 online';

sql statement: alter database datafile 7 online

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of sql command on default channel at 05/22/2009 17:56:37

RMAN-11003: failure during parse/execution of SQL statement: alter database data                                                                             file 7 online

ORA-01113: file 7 needs media recovery

ORA-01110: data file 7: '+GQISJ/gqsj/datafile/users.269.687549245'

這裡是由於把資料檔案置為OFFLINE沒有做檢查點,所以需要恢復。

 

RMAN> recover datafile 7;

Starting recover at 22-MAY-09

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 22-MAY-09

 

RMAN> sql'alter database datafile 7 online';

sql statement: alter database datafile 7 online

 

7、刪除原始的檔案

[oracle@lee oracle]$ rm user01.dbf

 

8、同理我們可以把一個表空間移動到ASM,也可以從一個磁碟組移動到另一個磁碟組。

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

相關文章