今天在RMAN還原測試過程中,遇到了"RMAN-06172: no autobackup found or specified handle is not a valid copy or piece"這個錯誤,如下所示: RMAN> restore spfile to pfile "/u01/app... ...
今天在RMAN還原測試過程中,遇到了"RMAN-06172: no autobackup found or specified handle is not a valid copy or piece"這個錯誤,如下所示:
RMAN> restore spfile to pfile "/u01/app/oracle/product/10.2.0/db_1/dbs/initSCM2.ora"
from "/u04/backup/backupsets/ora_cfc-4095319980-20180327-00";
Starting restore at 28-MAR-18
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/28/2018 14:20:12
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece
當然,此處是還原參數文件,其實還原控制文件或其它數據文件都會遇到這個錯誤,關於這個錯誤,官方解釋為:
Versions 11.1, 11.2, 12.1
Error: RMAN-06172 no AUTOBACKUP found or specified handle is not a valid copy or piece
---------------------------------------------------------------------------
Cause: A restore could not proceed because no AUTOBACKUP was found or
specified handle is not a valid copy or backup piece. In case of
restore from AUTOBACKUP, it may be the case that a backup exists, but
it does not satisfy the criteria specified in the user's restore
operands. In case of restore from handle, it may be the handle is not a
backup piece or control file copy. In may be that it does not exist.
Action: Modify AUTOBACKUP search criteria or verify the handle.
Versions 9.2, 10.1, 10.2
Error: RMAN-06172 no autobackup found or specified handle is not a valid copy or piece
---------------------------------------------------------------------------
Cause: A restore could not proceed because no autobackup was found or
specified handle is not a valid copy or backup piece. In case of
restore from autobackup, it may be the case that a backup exists, but
it does not satisfy the criteria specified in the user's restore
operands. In case of restore from handle, it may be the handle is not a
backup piece or controflile copy. In may be that it does not exist.
Action: Modify autobackup search criteria or verify the handle.
導致RMAN-06172錯誤的原因如上,但是引起這個錯誤的場景非常多, 個人總結了一下,大概可以從下麵幾個方面去判別、分析:
1:備份集過期或備份文件不存在
RMAN> list backup of controlfile;
RMAN> list backup of spfile;
如果備份集文件不存在,那麼肯定會報這個錯誤,另外backuppiece過期了,那麼上面命令就會顯示spfile或controlfile過期(expired),此時需要運行類似下麵命令來解決問題。
RMAN> crosscheck backup of controlfile;
備份集有兩種狀態A(Available,RMAN認為該項存在於備份介質上);X(Expired,備份存在於控制文件或恢複目錄中,但是並沒有物理存在於備份介質上)
crosscheck backup 命令的目的是檢查RMAN的目錄以及物理文件,如果物理文件不存在於介質上,將標記為Expired。如果物理文件存在,將維持Available。
如果原先標記為Expired的備份集再次存在於備份介質上(如恢復了損壞的磁碟驅動器後),crosscheck backup將把狀態重新從Expired標記回Available。
還有一種情況是從自動備份還原出現RMAN-06172錯誤。這個是因為備份集不存在了,也可以通過list backup of xxx查看確認。
RMAN> restore spfile from autobackup;
2:RMAN通道(CHANNEL)配置不正確
參考官方文檔:Restore of controlfile autobackup using LiteSpeed (tape) fails with RMAN-06172 (文檔 ID 2021758.1)
原因分析:
LiteSpeed requires a tape channel to be allocated. A disk channel will not work even though when using LiteSpeed you can see the controlfile backup on disk. If a 'list backup of controlfile" shows the backup as on tape, a tape channel must be allocated.
LiteSpeed
需要分配一個磁帶通道。 即使使用LiteSpeed,磁碟通道也不起作用,您可以在磁碟上看到控制文件備份。 如果“控制文件的列表備份”將備份顯示為磁帶上,則必須分配磁帶通道。
解決方案:
Use a run block with a tape channel allocation:
run {
allocate channel dev device type 'sbt_tape';
restore controlfile from '<full path/file name to controlfile backup>';
release channel dev;
}
3:Media Manager安裝錯誤
參考官方文檔Cannot restore controlfile from RMAN backup (文檔 ID 1054412.1)
解決方案:
After reinstalling the Lite Speed Media Manager the controlfile was able to restore successfully.
Support for third party Media Management software that interacts with RMAN is provided by the 3rd party software vendo
4:文件許可權問題
個人遇到的這個案例中,在root賬號下使用SFTP拷貝了備份文件,文件的屬主為root用戶,而RMAN命令運行在oracle用戶下,所以在還原時,由於許可權問題,RMAN認為文件不存在,從而報RMAN-06172錯誤。
這種情況的判別、驗證步驟如下:
1: 找到對應的備份文件
list backup of xxx
2: 使用ls -lrt 檢查文件許可權屬性。
3: 修改備份文件的屬主