【RMAN】windows2008 Oracle通過rman增量遷移

xysoul_雲龍發表於2017-07-31

環境介紹: windows2008R2 Oracle11.2.0.1  非歸檔模式

遷移過程:

修改歸檔:

點選(此處)摺疊或開啟

  1. alter system set log_archive_dest_1='location=d:\archivelog' scope=spfile;

  2. shutdown immediate;
  3. startup mount;
  4. alter database archivelog;
  5. alter database open

通過rman進行全備,當然也可以進行0級備份,後續增量備份,這裡使用歸檔日誌方式進行追加資料。

點選(此處)摺疊或開啟

  1. run {
  2.     allocate channel ch1 type disk;
  3.     allocate channel ch2 type disk;
  4.     allocate channel ch3 type disk;
  5.     allocate channel ch4 type disk;
  6.     sql 'alter system archive log current';
  7.     sql 'alter system archive log current';
  8.     backup format 'E:\rmanbackup\orcl_full_%T_%s_%p' database plus archivelog delete all input;
  9.     backup format 'E:\rmanbackup\orcl_controlfile_%T_%s_%p' current controlfile;
  10.     sql 'alter system archive log current';
  11.     backup format 'E:\rmanbackup\orcl_arch_%Y%M%D_%s_%p' archivelog all;
  12.     release channel ch1;
  13.     release channel ch2;
  14.     release channel ch3;
  15.     release channel ch4;
  16. }

生成pfile檔案

點選(此處)摺疊或開啟

  1. create pfile='d:\pfile20170721.ora' from spfile

目標端建立例項:

點選(此處)摺疊或開啟

  1. oradim -new -sid orcl

將備份檔案、引數檔案、密碼檔案拷貝至目標端

編輯pfile檔案,建立相關目錄,修改相關引數(如sga、pga等)

點選(此處)摺疊或開啟

  1. md D:\app\Administrator\admin\orcl\adump
  2. md D:\app\Administrator\admin\orcl\dpdump
  3. md D:\app\Administrator\oradata\orcl
啟動nomount階段

點選(此處)摺疊或開啟

  1. create spfile from pfile='d:\pfile20170721.ora';
  2. startup nomount

恢復控制檔案:

點選(此處)摺疊或開啟

  1. --恢復控制檔案 ,注意修改備份的控制檔名
  2. restore controlfile from 'D:\rmanbackup\ORCL_CONTROLFILE_20170731_74_1';

  3. --啟動到mount階段
  4. sql 'alter database mount'

恢復資料檔案:

點選(此處)摺疊或開啟

  1. catalog start with 'D:\rmanbackup';

  2. --檢視對應資料檔案
  3. --檢視對應的表空間、資料檔案資訊
  4. set lines 150
  5. col tname for a10
  6. col dname for a65
  7. select t.ts#,t.name tname,d.file#,d.name dname,d.status from v$tablespace t,v$datafile d where t.ts#=d.ts#;

  8. --對資料檔案重新命名查詢語句
  9. select 'set newname for datafile '||d.file#||' to '''||d.name||''';' from v$datafile d,v$tablespace t where d.ts#=t.ts# and t.INCLUDED_IN_DATABASE_BACKUP='YES';

  10. --更改目標碟符,這裡是d: 原來為E
  11. ------------------------------

  12. --恢復資料檔案 跟客戶通過,資料檔案目錄XHLISDB不變
  13. run{
  14. set newname for datafile 1 to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF';
  15. set newname for datafile 2 to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF';
  16. set newname for datafile 3 to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF';
  17. set newname for datafile 4 to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF';
  18. …………
  19. restore database;
  20. switch datafile all;
  21. }


--修改redo 位置


點選(此處)摺疊或開啟

  1. --檢視redo路徑
  2. select * from v$logfile;

  3. --修改redo路徑,檢視路徑後,如路徑不對,修改為目標路徑
  4. select 'alter database rename file '''||member||''' to '''||member||''';' from v$logfile;

  5. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO002.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO002.LOG';
  6. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO003.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO003.LOG';
  7. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO001.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO001.LOG';
  8. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO004.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO004.LOG';
  9. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO005.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO005.LOG';
  10. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO006.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO006.LOG';
  11. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO007.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO007.LOG';
  12. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO008.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO008.LOG';
  13. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO009.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO009.LOG';
  14. alter database rename file 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO010.LOG' to 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO010.LOG'

==================================================================================
開始切換資料庫:


點選(此處)摺疊或開啟

  1. --停止原庫監聽,手動切換幾次歸檔
  2. alter system archive log current;

  3. --確保資料庫資料一致,重啟資料庫例項,再次切換幾次歸檔
  4. alter system archive log current;

  5. --備份歸檔
  6. backup format 'E:\rmanbackup\orcl_arch_%T_%s_%p' archivelog all


附:使用增量

點選(此處)摺疊或開啟

  1. --也可以使用增量的方式(主要相關語句,具體參考其他檔案 )
  2. select current_scn from v$database;
  3. BACKUP INCREMENTAL FROM SCN 1013684 DATABASE FORMAT 'E:\rmanbackup\orcl_incr_%T_%s_%p';
  4. backup current controlfile format 'E:\rmanbackup\orcl_arch_%T_%s_%p';
  5. recover database noredo


拷貝檔案到目標伺服器:
開始恢復:

點選(此處)摺疊或開啟

  1. catalog start with 'D:\rmanbackup\ORCL_ARCH_20170721_61_1';

  2. list backup of archivelog all;

  3. --歸檔日誌備份最早序號開始
  4. restore archivelog from sequence 57;
  5.  
  6. --將資料庫例項恢復至最後一個歸檔檔案序號

  7. recover database until sequence 63;

  8. --open
  9. alter database open resetlogs;

  10. --修改臨時表空間
  11. alter database tempfile 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF' drop;

  12. ALTER TABLESPACE TEMP ADD TEMPFILE 'D:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF' SIZE 10G autoextend on


注意:通過oradim 命令建立例項,開機無法自動啟動例項,可修改登錄檔修改。ORA_CTY1_AUTOSTART  預設為false,修改為true。也可以執行下面命令:

點選(此處)摺疊或開啟

  1. oradim.exe -NEW -SID orcl -INTPWD oracle -STARTMODE auto -PFILE "D:\Agilent\Oracle\Admin\..\initorcl.ora"

恢復後,建議進行資料庫、系統相關檢查。


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

相關文章