溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

windows2008 Oracle如何通過rman進(jìn)行增量遷移

發(fā)布時(shí)間:2021-11-12 14:27:34 來源:億速云 閱讀:201 作者:柒染 欄目:關(guān)系型數(shù)據(jù)庫

本篇文章為大家展示了windows2008 Oracle如何通過rman進(jìn)行增量遷移,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。


環(huán)境介紹: windows2008R2 Oracle11.2.0.1  非歸檔模式

遷移過程:

修改歸檔:

點(diǎn)擊(此處)折疊或打開

  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進(jìn)行全備,當(dāng)然也可以進(jìn)行0級(jí)備份,后續(xù)增量備份,這里使用歸檔日志方式進(jìn)行追加數(shù)據(jù)。

點(diǎn)擊(此處)折疊或打開

  1. run {

  2.     allocate channel ch2 type disk;

  3.     allocate channel ch3 type disk;

  4.     allocate channel ch4 type disk;

  5.     allocate channel ch5 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 ch2;

  13.     release channel ch3;

  14.     release channel ch4;

  15.     release channel ch5;

  16. }


生成pfile文件

點(diǎn)擊(此處)折疊或打開

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


目標(biāo)端創(chuàng)建實(shí)例:

點(diǎn)擊(此處)折疊或打開

  1. oradim -new -sid orcl


將備份文件、參數(shù)文件、密碼文件拷貝至目標(biāo)端

編輯pfile文件,創(chuàng)建相關(guān)目錄,修改相關(guān)參數(shù)(如sga、pga等)

點(diǎn)擊(此處)折疊或打開

  1. md D:\app\Administrator\admin\orcl\adump

  2. md D:\app\Administrator\admin\orcl\dpdump

  3. md D:\app\Administrator\oradata\orcl

啟動(dòng)nomount階段

點(diǎn)擊(此處)折疊或打開

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

  2. startup nomount


恢復(fù)控制文件:

點(diǎn)擊(此處)折疊或打開

  1. --恢復(fù)控制文件 ,注意修改備份的控制文件名

  2. restore controlfile from 'D:\rmanbackup\ORCL_CONTROLFILE_20170731_74_1';


  3. --啟動(dòng)到mount階段

  4. sql 'alter database mount'


恢復(fù)數(shù)據(jù)文件:

點(diǎn)擊(此處)折疊或打開

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


  2. --查看對(duì)應(yīng)數(shù)據(jù)文件

  3. --查看對(duì)應(yīng)的表空間、數(shù)據(jù)文件信息

  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. --對(duì)數(shù)據(jù)文件重命名查詢語句

  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. --更改目標(biāo)盤符,這里是d: 原來為E

  11. ------------------------------


  12. --恢復(fù)數(shù)據(jù)文件  跟客戶通過,數(shù)據(jù)文件目錄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 位置


點(diǎn)擊(此處)折疊或打開

  1. --查看redo路徑

  2. select * from v$logfile;


  3. --修改redo路徑,查看路徑后,如路徑不對(duì),修改為目標(biāo)路徑

  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'


==================================================================================
開始切換數(shù)據(jù)庫:


點(diǎn)擊(此處)折疊或打開

  1. --停止原庫監(jiān)聽,手動(dòng)切換幾次歸檔

  2. alter system archive log current;


  3. --確保數(shù)據(jù)庫數(shù)據(jù)一致,重啟數(shù)據(jù)庫實(shí)例,再次切換幾次歸檔

  4. alter system archive log current;


  5. --備份歸檔

  6. backup format 'E:\rmanbackup\orcl_arch_%T_%s_%p' archivelog all


附:使用增量

點(diǎn)擊(此處)折疊或打開

  1. --也可以使用增量的方式(主要相關(guān)語句,具體參考其他文件 )

  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



拷貝文件到目標(biāo)服務(wù)器
開始恢復(fù):

點(diǎn)擊(此處)折疊或打開

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


  2. list backup of archivelog all;


  3. --歸檔日志備份最早序號(hào)開始

  4. restore archivelog from sequence 57;

  5.  

  6. --將數(shù)據(jù)庫實(shí)例恢復(fù)至最后一個(gè)歸檔文件序號(hào)


  7. recover database until sequence 63;


  8. --open

  9. alter database open resetlogs;


  10. --修改臨時(shí)表空間

  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 命令創(chuàng)建實(shí)例,開機(jī)無法自動(dòng)啟動(dòng)實(shí)例,可修改注冊表修改。ORA_CTY1_AUTOSTART  默認(rèn)為false,修改為true。也可以執(zhí)行下面命令:

點(diǎn)擊(此處)折疊或打開

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


恢復(fù)后,建議進(jìn)行數(shù)據(jù)庫、系統(tǒng)相關(guān)檢查。


上述內(nèi)容就是windows2008 Oracle如何通過rman進(jìn)行增量遷移,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI