資料庫檔案存放在存儲上,當需要更換新存儲時,就需要變更新的存儲路徑,遷移原有的資料檔案,本文檔介紹兩種資料檔案遷移的方法。省略輸出結果。
一、RMAN遷移資料檔案 步驟:
1.修改參數檔案中控制檔案的存放位置
SQL>alter system set control_files='/newdirect/control01.ctl' scope=spfile
2.備份控制檔案
RMAN>backup current controlfile format '/任意的備份路徑/control01.ctl'
3.關閉資料庫并啟動到nomount狀态,恢複按“步驟1”中新設定的控制檔案位置恢複控制檔案
RMAN>restore controlfile from '/任意的備份路徑/control01.ctl'
4.備份現有的資料庫檔案原存儲位置至新存儲路徑間進行轉換
RMAN>backup as copy db_file_name_convent('/新的存儲路徑','/舊存儲路徑') tablespace system, users,sysaux, undotbs01;
RMAN>switch database to copy;
RMAN>recover database;
RMAN>alter database open resetlogs;
5.建立線上重做日志檔案
SQL>alter database add logfile thread 1 group 4 ('/新存儲路徑/redo04.log') size 1024m;
6.删除舊的線上重做日志檔案,删除前一定要确認日志組為inactive狀态
SQL>alter database drop logfile group 1;
7.建立臨時表空間,删除舊的臨時表空間
SQL>alter tablespace temp add tempfile '/新存儲路徑/temp01.dbf' size 1G;
SQL>alter tablespace temp drop tempfile '/舊存儲路徑下的/temp01.dbf';
二、通過拷貝資料檔案再rename的方式遷移資料檔案
1.修參數檔案中控制檔案存儲位置
SQL>alter system set control_files='/新存儲位置/ocntrol01.ctl' scope=spfile;
2.一緻性關閉資料庫,拷貝資料檔案和控制檔案至新的存儲位置
3.開啟資料庫起資料,分别重命名system,sysaux,undo,users,線上重做日志檔案的表空間對應資料檔案的名字
SQL>alter database rename file '舊檔案位置' to '新檔案位置'
4.建立新的臨時表空間,删除舊的臨時表空間
SQL>alter tablespace temp add tempfile '/新路徑下的/temp01.dbf' size 1G;
SQL>alter teblespace temp drop tempfile '/舊路徑下的/temp01.dbf';
原文位址https://blog.csdn.net/FC_BarceIona/article/details/80267685