資料檔案遷移至其他磁碟組

abin1703發表於2020-12-28

有的時候我們需要遷移ASM下的資料檔案到其他ASM磁碟組,前幾天剛遷移了3T左右的資料,個人認為純屬體力工作,現在把步驟記錄下來,以後有這樣的工作直接複製貼上就好了。
我的方法是利用rman的copy命令,所以必須得在歸檔方式下進行,    以下為具體實施步驟:

--先檢查下備份資訊
list datafilecopy all;
crosscheck copy;
delete expired copy;

--確認要遷移的資料檔案
col name for a60
select file#,name,status,bytes/1024/1024 sizeMB from v$datafile; 

--對於普通資料檔案直接在RMAN命令列下執行
(對於UNDO資料檔案,要注意offline undo datafiles 需要在兩個節點分別進行,並且最好在sqlplus環境下一步一步執行,因為offline和recover的時候會報錯,這時退出重進就好了)
sql "alter database datafile 5 offline"; 
copy datafile 5 to '+DATA2/';  
switch datafile 5 to copy;  
recover datafile 5;  
sql "alter database datafile 5 online"; 
delete noprompt datafilecopy '+DATA/tcendba/datafile/undotbs2.355.855996443'; 


--對於SYSTEM、SYSAUX表空間就需要在mount狀態下操作了,針對datafile
shutdown immediate;
startup mount;
copy datafile 2 to '+DATA2/';
switch datafile 2 to copy;
recover database;
sql "alter database open";
delete datafilecopy '+DATA/bwc/datafile/sysaux.2430.886960935';

--   對於SYSTEM、SYSAUX表空間的第二種方法   ,針對tablespace
backup as copy tablespace system format '+DATA2/';
backup as copy tablespace sysaux format '+DATA2/';
shutdown immediate;
startup mount;
switch tablespace system to copy;
switch tablespace sysaux to copy;
recover database;
sql "alter database open";
delete noprompt datafilecopy '+DATA/tcendba/datafile/system.336.855996319';
delete noprompt datafilecopy '+DATA/tcendba/datafile/sysaux.344.855996319';

--對於TMEP表空間,新建一個temp檔案,之後再刪除老的temp檔案就可以了
select file_id,file_name,tablespace_name,bytes/1024/1024 sizeMB,status from dba_temp_files;
alter tablespace temp add tempfile '+DATA2/' size 32000m; autoextend on maxsize 2g;
alter database tempfile '+DATA/tcendbd/tempfile/temp.470.856022841' offline;
alter tablespace temp drop tempfile '+DATA/tcendba/tempfile/temp.356.855996395';

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

相關文章