使用RMAN進行資料移轉

來源:互聯網
上載者:User

使用RMAN進行資料移轉

使用RMAN進行資料移轉

1.查看SCN,然後備份資料庫

run{
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 allocate channel c5 type disk;
 sql 'alter system archive log current';
 backup database tag 'db0'  include current controlfile plus archivelog;
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
 release channel c5;
 }

備份的檔案249G,備份用時20分鐘

2.將備份傳輸至目標伺服器 (53分鐘)

3.在目標伺服器還原
 先在$Oracle_HOME/dbs下建立檔案 initmvbox.ora
裡面只有一行
db_name=mvbox

將資料庫啟動至nomount
 restore spfile to '/xxxx/spfilemvbox.ora' from '/xxxx/2015_06_11/o1_mf_nnsnf_DB0_bqky8s7r_.bkp';

還原控制檔案
shutdown abort;
 startup mount;
 restore controlfile from '/xxxx/2015_06_11/o1_mf_ncnnf_DB0_bqky8pq9_.bkp';
 sql 'alter database mount';

掛載備份
catalog start with '/xxxx/2015_06_11';

還原資料庫
run{
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 allocate channel c5 type disk;
 restore database;
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
 release channel c5;
 }

還原資料庫用時 30分鐘

4.在目標伺服器進行資料庫恢複(業務實際停機時間)
首先,業務停機
 然後查看當前的SCN
 select to_char(CURRENT_SCN) from v$database;

備份歸檔日誌
sql 'alter system archive log current';
 run{
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 allocate channel c5 type disk;
 backup archivelog all tag 'arch0';
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
 release channel c5;
 }

因為在遷移之前,清空過歸檔日誌,所以歸檔日誌只是從備份開始到現在的這段時間
 日誌量不大,10分鐘以內就可以完成 備份和傳輸

 清空歸檔日誌的命令(delete noprompt archivelog all;)

掛載歸檔日誌
catalog start with '/xxxx/2015_06_11';

進行不完全恢複,
set until scn xxx
這個數字就是備份歸檔日誌之前查看的SCN

 run{
 shutdown immediate; 
 startup mount; 
 set until scn  79377202898; 
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 allocate channel c5 type disk;
 recover database;
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
 release channel c5;
 }

恢複用時11分鐘(應用歸檔日誌從10:40至14:39,4個小時)

alter database open resetlogs;

遷移完成.

比對MySQL的不完全恢複
 可以發現
MySQL先恢複,再應用binlog,最後還原
 他恢複的時間比較短,主要的時間是應用binlog(每恢複一小時的binlog需要15分鐘),最後的還原不需要時間(直接改datadir..)

而Oracle,先還原再恢複
 還原的時間比較長(30分鐘),而恢複的時間比較短(每推進一小時的資料需要2到3分鐘)
所以,在備份的伺服器,保持一個最近還原的備份很重要..最起碼會節省30分鐘的還原時間..

--------------------------------------推薦閱讀 --------------------------------------

RMAN 配置歸檔日誌刪除策略

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

--------------------------------------分割線 --------------------------------------

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.