NBU 异机恢复Oracle操作步骤

一、 准备工作

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开头的是数据库备份

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中搜索。

4. 报错4

RMAN> run {
2> ALLOCATE CHANNEL CH1 TYPE 'SBT_TAPE';
3> ALLOCATE CHANNEL CH2 TYPE 'SBT_TAPE';
4> send 'nb_ora_serv=nbu01-in';
5> send 'nb_ora_client=iZwz94g9fehswlnzd19jv2Z';
6> set newname for database to '/data/restore/%b';
7> set until time "to_date('2020-12-01 10:00:00','yyyy-mm-dd hh24:mi:ss')";
8> restore database;
9> switch datafile all;
10> recover database;
11> RELEASE CHANNEL CH1;
12> RELEASE CHANNEL CH2;
13> }

allocated channel: CH1
channel CH1: SID=1710 device type=SBT_TAPE
channel CH1: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915)
allocated channel: CH2
channel CH2: SID=5 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 NEWNAME
executing command: SET until clause
Starting restore at 25-DEC-20
released channel: CH1
released channel: CH2

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/25/2020 15:20:15
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

解决方法:使用的控制文件过新,已无欲恢复时间点备份记录。控制文件备份一般选晚于目标时间点并且离它最近的即可。

5. 报错5

SQL> alter database open resetlogs;

alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/data/oracle/oradata/pa/redo01.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1

解决方法:redo日志所在目录未创建或无权限。创建对应目录并授权,或者修改redo文件目录

6. 报错6

SQL> alter database open RESETLOGS;

alter database open RESETLOGS
*
ERROR at line 1:
ORA-00392: log 3 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 3 thread 1: '/data/oracle/oradata/pa/redo03.log'

解决方法

SQL> select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ---------------
         1          1 CLEARING
         2          1 CLEARING
         5          1 CLEARING
         4          1 CLEARING
         3          1 CLEARING_CURRENT

SQL> alter database clear logfile group 3;
Database altered.

SQL> select group#,thread#,status from v$log;

    GROUP#    THREAD# STATUS
---------- ---------- ----------------
         1          1 CLEARING
         2          1 CLEARING
         5          1 CLEARING
         4          1 CLEARING
         3          1 CURRENT

SQL>  alter database open RESETLOGS;
Database altered.

参考

https://www.modb.co/db/13817

NBU Rman异机恢复Oracle_Eliott_Chen的博客-CSDN博客

RMAN异机恢复——备份集权限问题_数据库技术_Linux公社-Linux系统门户网站

ORA-00392: log 7 of thread 1 is being cleared, operation not allowed - DBACLASS DBACLASS

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)

ALTER DATABASE OPEN RESETLOGS fails with ORA-00392 (文档 ID 1352133.1)

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hehuyi_In

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值