最近為了不影響開發庫的使用,打算複制建立一個備庫,定時更新,防止開發庫不能使用的情況下,可以臨時使用備庫,不影響進度。
環境:
11.2.0.4的單執行個體庫。
庫1是源庫(target),庫2是備庫(auxiliary)
操作過程:
1.庫1執行全庫備份
2.庫1備份控制檔案
3.将備份集(1)拷貝到庫2相同路徑下,即/home/oracle/duplicate,此時産生了三個檔案:
4.将庫1的inittest.ora參數檔案拷貝到庫2,并按照其中配置的控制檔案路徑,将庫1的控制檔案(2)可以直接copy到庫2對應路徑下,包括檔案名需要保持和參數檔案總定義一緻:
建立檔案夾:
5.庫2啟動nomount狀态
6.庫2執行恢複
報錯提示資料庫需要置為mount狀态。
7.庫2置為mount狀态
8.庫2執行恢複
9.庫2執行打開
報錯提示需要使用RESETLOGS或NORESETLOGS。
10.庫2執行打開
依舊報錯,提示:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: ‘/u01/app/oracle/11.2.0.4/oradata/dep/system01.dbf’
檢視這兩個報錯:
[oracle@testvm001 dbs]$ oerr ora 1152 01152, 00000, “file %s was not restored from a sufficiently old backup ” *Cause: An incomplete recovery session was started, but an insufficient number of logs were applied to make the database consistent. This file is still in the future of the last log applied. The most likely cause of this error is forgetting to restore the file from a backup before doing incomplete recovery. *Action: Either apply more logs until the database is consistent or > restore the database file from an older backup and repeat recovery. [oracle@testvm001 dbs]$ oerr ora 1110 01110, 00000, “data file %s: ‘%s’” *Cause: Reporting file name for details of another error. The reported name can be of the old file if a data file move operation is in progress. *Action: See associated error message.
11.庫2執行recover
提示需要sequence=745号的archivelog
12.檢視備份集中歸檔檔案al_t902681874_s12_p1的sequence是12。
13.再次執行恢複
對應alert日志:
14.開啟庫2
15.登入庫2,使用者、對象等資訊和庫1完全一緻。
總結:
1.RMAN執行restore需要資料庫置于mount狀态。
2.可以先将target的control控制檔案拷貝到auxiliary庫相同路徑下,需要注意參數檔案中定義的控制檔案路徑以及其他檔案夾均需要提前在auxiliary庫中建立,如果提前将控制檔案拷貝到auxiliary庫對應路徑下,則無需restore control,相當于已經做了這不操作。
3.resetlogs提示ORA1152錯誤,需要進行相應歸檔日志的恢複,根據拷貝過來的歸檔日志檔案名推算seq号。