Oracle 資料庫WEBDB 在新的伺服器環境進行備份的異地恢複測試,在執行到還原資料檔案時出現“ORA-01861: literal does not match format string ”的錯誤。
該錯誤不是NLS_DATE_FORMAT 參數設定不正確導致的,而是一個Oracle bug 導致的。在該錯誤的解決過程中,我們沒有採用官方推薦的重建控制檔案的解決方案,而是使用自己的解決方案,將老備份組完全刪除再註冊進新備份組。
生產資料庫是10.2.0.3 ,RAC 叢集,ASM 儲存,測試資料庫為單一實例,檔案系統儲存。
這個bug 不會影響到生產庫的正常的備份和恢複操作。
1. 問題
在還原資料檔案時,出現ORA-01861 錯誤,檔案無法還原,導致備份恢複工作停止。
整個還原過程操作如下:
1 、在sqlplus 中啟動執行個體到nomount 狀態;
2 、在rman 中還原控制檔案;
restore controlfile from ‘/backup/ctl.xxx’;
3 、啟動執行個體到mounted 狀態
sql ‘alter database mount’;
4 、註冊備份組
catalog start with ‘/backup/’;
因為生產庫的備份組所在目錄和測試庫的備份組所在目錄不一樣,所以使用catalog 將新位置註冊進控制檔案中。
5 、還原所有資料檔案,並重新命名。
這裡測試還原第一個資料檔案,檔案位置從ASM 修改檔案系統目錄。
run
{
allocate channel ch01 type disk;
set until time "to_date('2012-06-25 23:00:00','yyyy-mm-dd hh24:mi:ss')";
set newname for datafile 1 to '/stor2T/app/oracle/oradata/WEBDB/system01.dbf';
restore datafile 1;
switch datafile all;
release channel ch01;
}
在這一步操作時,出現如下錯誤:
RMAN-03002: failure of restore command at 06/27/2012 16:09:51
ORA-01861: literal does not match format string
備份恢複測試工作因此而中止。
從錯誤資訊看,這個應該是NLS_DATE_FORMAT 的格式設定的不對,set until time 的格式有問題。
於是,我們換成set until scn 進行資料檔案的還原,還原作業的腳步如下是這樣。
run
{
allocate channel ch01 type disk;
set until scn 3054150330;
set newname for datafile 1 to '/stor2T/app/oracle/oradata/WEBDB/system01.dbf';
restore datafile 1;
switch datafile all;
release channel ch01;
}
但是,還是報ORA-01861 錯誤。
甚至執行列出所有備份組時都出現這個錯誤。
RMAN> list backupset summary;
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 06/27/2012 16:29:18
ORA-01861: literal does not match format string
從這個現象看,這個問題已經不是一個參數設定不正確那麼簡單了。