使用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分鐘的還原時間..

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分鐘的還原時間..

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1696223/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用rman遷移資料庫資料庫
- 使用dbeaver 用csv 檔案進行資料遷移
- Oracle使用RMAN從Windows遷移資料到LinuxOracleWindowsLinux
- 資料遷移的時候出現RMAN-03002,RMAN-06026
- 使用impdp,expdp資料泵進入海量資料遷移
- 資料庫上雲實踐:使用Ora2pg進行資料庫遷移資料庫
- 使用vplex的mirror功能對儲存層LUN進行資料的遷移
- Oracle rman duplicate遷移測試Oracle
- EF Core 小技巧:遷移已經應用到資料庫,如何進行遷移回退操作?資料庫
- 使用Mobilenet和Keras進行遷移學習!Keras遷移學習
- 使用Conda Pack進行環境打包遷移
- 1.5 使用nvicat和kettle進行全量遷移
- 【RMAN】Oracle使用rman將11.2.0.4資料庫遷移至Oracle12c命令參考Oracle資料庫
- Oracle資料庫中資料行遷移與行連結Oracle資料庫
- Laravel migration (資料庫遷移) 的使用Laravel資料庫
- 使用Liquibase和Spring Boot進行資料庫遷移的一站式指南 - reflectoringUISpring Boot資料庫
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 【Redis 技術探索】「資料遷移實戰」手把手教你如何實現線上 + 離線模式進行遷移 Redis 資料實戰指南(scan模式遷移)Redis模式
- 杉巖資料銀行Documentum遷移方案
- Kafka資料遷移Kafka
- Harbor資料遷移
- gitlab資料遷移Gitlab
- 資料庫遷移資料庫
- 使用DistCp將Hadoop進行雲遷移時注意事項TCPHadoop
- 【DBA Part01】國產Linux上安裝Oracle進行資料遷移LinuxOracle
- 資料遷移(1)——通過資料泵表結構批量遷移
- 資料遷移測試專案實戰,2個系統的使用者資料如何進行關聯?(圖)
- Mysql資料遷移方法MySql
- 【Hive】hive資料遷移Hive
- 【Redis】 redis資料遷移Redis
- redis資料庫遷移Redis資料庫
- congregate遷移gitlab資料Gitlab
- 系統資料遷移
- 資料庫遷移 :理解資料庫
- laravel資料庫遷移Laravel資料庫
- Fastdfs資料遷移方案AST
- Velero系列文章(四):使用Velero進行生產遷移實戰
- 伺服器資料遷移的方法-硬體不同如何遷移資料伺服器
- 【Redis 技術探索】「資料遷移實戰」手把手教你如何實現線上 + 離線模式進行遷移Redis資料實戰指南(離線同步資料)Redis模式