一、 準備工作
1. DBA
- 恢復服務器安裝與原庫相同版本的操作系統、數據庫軟件、NBU客戶端
- 雙向開通到NBU備份服務器的1556、13724、13720、13782、13790端口的防火牆策略(應該只要1556和13724,但爲避免還原時出現其他異常,建議都開)
- /etc/hosts文件添加NBU備份服務器主機名及原庫主機名,ping 主機名測試能否解析成功
- 確保恢復服務器磁盤空間足夠
2. NBU管理員
- /etc/hosts文件添加待恢復服務器主機名,ping 主機名測試能否解析成功,若不成功可使用bpclntcmd -clear_host_cache清除nbu端dns緩存
- 配置恢復授權,確保備份機器和還原機器都在列表中,且允許還原
Host Properties->Mater server->Client Attributes
- 若是異機恢復,需在NBU給備份機器和恢復機器增加異機恢復的權限
cd /usr/openv/netbackup/db/altnames
touch 主機名
- 檢查異機恢復參數
NBUInstallPath/NetBackup/bin/admincmd/bpgetconfig | grep "DISALLOW_CLIENT"
#輸出
DISALLOW_CLIENT_LIST_RESTORE = NO
DISALLOW_CLIENT_RESTORE = NO
#若如上兩個參數爲YES,則表示禁止進行異機恢復,需要將兩個參數改成NO,爲保證參數生效,建議修改後重啓主服務器上的NBU服務
NBUInstallPath/NetBackup/bin/bp.kill_all
NBUInstallPath/NetBackup/bin/bp.start_all
二、 數據恢復
以下均在待恢復服務器操作
1. 檢查備份文件情況
/usr/openv/netbackup/bin/bplist -C iZwz94g9fehswlnzd19jv2Z -t 4 -b -l -R /
# -C後跟備份庫主機名;-t後跟還原類型,4是oracle標誌;-b指列出備份文件的日期和時間;-l指列出備份文件的詳細信息;-R以遞歸的方式顯示子目錄。
- c-和cntrl開頭的是控制文件自動備份,包含參數文件和控制文件
- al開頭的是歸檔日誌備份
- bk開頭的是數據庫備份
2. Oracle用戶執行oracle_link
Linux/Unix需要在netbackup/bin路徑下執行oracle_link,以便rman調用nbu接口進行讀取數據備份信息
/usr/openv/netbackup/bin/oracle_link
3. 手工創建參數文件
測試使用控制文件備份中恢復的spfile可能遇到在restore數據庫時無法找到正確的備份文件路徑等難以排查的問題,NBU供應商建議手工創建參數文件,優先恢復數據文件,待數據可讀後再恢復原來的參數文件。
檢查參數文件中的各路徑位置,確保目錄已存在,或修改參數文件指定新路徑
cd $ORACLE_HOME/dbs
vi inittmp.ora
#內容如下
*.audit_file_dest='/data/prd/oracle/database/admin/ORCL/adump'
*.compatible='12.1.0.2.0'
*.control_files='/data/prd/oracle/database/oradata/ORCL/controlfile/o1_mf_h9bx082j_.ctl','/data/prd/oracle/database/fast_recovery_area/ORCL/controlfile/o1_mf_h9bx08cr_.ctl'
*.db_block_size=8192
*.db_file_multiblock_read_count=16
*.db_create_file_dest='/data/restore/'
*.db_recovery_file_dest='/data/restore/'
*.db_recovery_file_dest_size=500g
*.enable_pluggable_database=ture
*.db_name='HYBRID'
*.log_archive_dest_1='location=/data/arch'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.processes=1500
*.remote_login_passwordfile='exclusive'
*.sessions=1655
*.sga_max_size=4G
*.sga_target=4G
*.pga_aggregate_limit=3G
*.pga_aggregate_target=1G
*.undo_management='AUTO'
undo_tablespace='UNDOTBS1'
*.diagnostic_dest='/data/prd/oracle/database'
利用pfile啓動數據庫到nomount狀態
startup nomount pfile='/data/prd/oracle/database/12.1.0.2/ORCL/dbs/inittmp.ora'
4. 恢復控制文件
注意NB_ORA_CLIENT後是備份庫的主機名,控制文件備份一般選最新的即可
rman target /
Set DBID=2334928137;
run{
allocate channel ch00 type 'SBT_TAPE';
send 'nb_ora_serv=nbu01';
send 'nb_ora_client=iZwz94g9fehswlnzd19jv2Z';
restore controlfile from '/c-2334928137-20200513-09';
release channel ch00;
}
啓動數據庫到mount狀態
alter database mount;
檢查控制文件中記錄的數據和日誌文件位置,確保目錄已存在,或在恢復時指定新路徑
select name from v$datafile;
select name from v$tempfile;
select member from v$logfile;
archive log list
5. 恢復數據文件
本文以恢復到指定時間點、不同數據文件目錄爲例
rman target /
run {
ALLOCATE CHANNEL CH1 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL CH2 TYPE 'SBT_TAPE';
send 'nb_ora_serv=nbu01';
send 'nb_ora_client=iZwz94g9fehswlnzd19jv2Z';
set newname for database to '/data/restore/%b';
set until time "to_date('2020-05-13 14:00:00','yyyy-mm-dd hh24:mi:ss')";
restore database;
switch datafile all;
recover database;
RELEASE CHANNEL CH1;
RELEASE CHANNEL CH2;
}
open數據庫
alter database open resetlogs;
select status from v$instance;
6. 檢查是否恢復到要求時間點
基於時間點的還原並不一定準確,可能會有10分鐘左右的誤差
RMAN> list incarnation of database;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 HYBRID 2334928137 PARENT 1 14-APR-20
2 2 HYBRID 2334928137 CURRENT 11836309 13-MAY-20
RMAN> select scn_to_timestamp(11836309) from dual;
SCN_TO_TIMESTAMP(11836309)
-------------------------------
13-MAY-20 01.50.11.000000000 PM
三、 報錯小結
1. 報錯1
RMAN> run{
2> allocate channel ch00 type 'SBT_TAPE';
3> send 'nb_ora_serv=nbu01';
4> send 'nb_ora_client=iZwz9bqyoktgse85mhpwd8Z';
5> restore controlfile from '/c-2334928137-20200511-09';
6> release channel ch00;
7> }
using target database control file instead of recovery catalog
allocated channel: ch00
channel ch00: SID=1150 device type=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915)
sent command to channel: ch00
sent command to channel: ch00
Starting restore at 11-MAY-20
released channel: ch00
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/11/2020 22:10:12
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
解決方法:nb_ora_client參數後應該填備份服務器名而非還原服務器名
2. 報錯2
RMAN> run {
2> ALLOCATE CHANNEL CH1 type 'SBT_TAPE';
3> send 'NB_ORA_CLIENT=iZwz94g9fehswlnzd19jv2Z,NB_ORA_SERV=nbu01';
4> restore spfile from '/c-2334928137-20200511-09';
5> RELEASE CHANNEL CH1;
6> }
using target database control file instead of recovery catalog
allocated channel: CH1
channel CH1: SID=1150 device type=SBT_TAPE
channel CH1: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915)
sent command to channel: CH1
Starting restore at 11-MAY-20
channel CH1: restoring spfile from AUTOBACKUP /c-2334928137-20200511-09
released channel: CH1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/11/2020 22:19:04
ORA-19870: error while restoring backup piece /c-2334928137-20200511-09
ORA-19507: failed to retrieve sequential file, handle="/c-2334928137-20200511-09", parms=""
ORA-27029: skgfrtrv: sbtrestore returned error
ORA-19511: non RMAN, but media manager or vendor specific failure, error text:
Failed to open backup file for restore.
解決方法:測試時實際遇到的問題是還原服務器主機名配置錯誤,有許多情況可能導致該報錯,還原前務必按照第一步中準備項檢查清楚。參考鏈接:https://www.modb.co/db/13817 (13782端口實際應該是不需要的)
3. 報錯3
RMAN> run {
2> ALLOCATE CHANNEL CH1 TYPE 'SBT_TAPE';
3> ALLOCATE CHANNEL CH2 TYPE 'SBT_TAPE';
4> send 'nb_ora_serv=nbu01';
5> send 'nb_ora_client=iZwz94g9fehswlnzd19jv2Z';
6> set until time "to_date('2020-05-08 17:00:00','yyyy-mm-dd hh24:mi:ss')";
7> restore database;
8> recover database;
9> RELEASE CHANNEL CH1;
10> RELEASE CHANNEL CH2;
11> }
allocated channel: CH1
channel CH1: SID=1150 device type=SBT_TAPE
channel CH1: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915)
allocated channel: CH2
channel CH2: SID=6 device type=SBT_TAPE
channel CH2: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915)
sent command to channel: CH1
sent command to channel: CH2
sent command to channel: CH1
sent command to channel: CH2
executing command: SET until clause
Starting restore at 13-MAY-20
Starting implicit crosscheck backup at 13-MAY-20
Finished implicit crosscheck backup at 13-MAY-20
Starting implicit crosscheck copy at 13-MAY-20
Finished implicit crosscheck copy at 13-MAY-20
searching for all files in the recovery area
cataloging files...
cataloging done
released channel: CH1
released channel: CH2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/13/2020 00:16:30
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 8 found to restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN> exit
解決方法:測試時的解決方法爲使用手工創建的參數文件而非控制文件中恢復的spfile,也查到有很多別的問題可能導致此類報錯,詳情可在MOS中搜索。
參考
https://blog.csdn.net/m0_37083172/article/details/75052175
https://www.linuxidc.com/Linux/2013-08/88499.htm
Common Causes for RMAN-06023 and RMAN-06026 (文檔 ID 1366610.1)
RMAN RESTORE FAILS WITH RMAN-06023 ALTHOUGH BACKUPS ARE AVAILABLE (文檔 ID 965122.1)
RMAN-6026 RMAN-6023 when restoring to new host (文檔 ID 1300586.1)