概述
分享下最近做的一個rman跨版本遷移的案例,主要是從生產環境遷移數據到測試環境,中間出了個小問題,整體問題不大。
環境
因為都裝了Oracle軟體了,所以這部分安裝過程就不做介紹了。
一、source資料庫準備
1.獲取數據文件編號和路徑
SQL> select file_id,file_name from dba_data_files order by file_id;
2.獲取臨時文件編號和路徑
SQL> select file#, name from v$tempfile;
3.獲取在線日誌文件組和路徑
SQL> select group#,member from v$logfile;
4.獲取資料庫字符編碼
SQL> select * from nls_database_parameters ;
其中:
- 1. Language: 指定伺服器消息的語言, 影響提示信息是中文還是英文
- 2. Territory: 指定伺服器的日期和數字格式,
- 3. Charset: 指定字符集。
二、source資料庫備份
在業務空閒時間段,先切換幾次歸檔日誌,然後開始rman備份。
1. rman備份腳本
F:\\rmanbackup\\fslda_rman_backup.bat
###############################################################
rman target sys/xxx@orcl msglog=F:\\rmanbackup\\rman.log cmdfile=F:\\rmanbackup\\full_backup.txt
echo "rman備份完成!"
pause
################################################################
F:\\rmanbackup\\full_backup.txt
##############################################################
run
{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
sql 'alter system archive log current';
backup as compressed backupset database format 'F:/rmanbackup/fullbak_%d_%I_%s_%p_%T.bkp' include current controlfile;
backup current controlfile format 'F:/rmanbackup/spfile_controlfile_%d_%I_%s_%p_%T.bkp';
backup as compressed backupset archivelog all format 'F:/rmanbackup/archivelog_%d_%I_%s_%p_%T.bkp' delete input;
release channel c1;
release channel c2;
release channel c3;
}
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
################################################################
2.創建參數文件
create pfile='F:\\rmanbackup\\pfile.ora' from spfile;
這步實際上也可以省略的,自己編輯下文件就可以了。
篇幅有限,這塊內容就先介紹源資料庫方面的事前檢查和備份工作了,後面開始介紹在目的端的恢復工作,感興趣的朋友可以關注下~
今天是祖國的70周年,在這裡祝福祖國,繁榮富強,國泰民安!也祝大家國慶節快樂~