资讯专栏INFORMATION COLUMN

Oracle数据库NBU备份异机恢复操作

IT那活儿 / 534人阅读
Oracle数据库NBU备份异机恢复操作

点击上方“IT那活儿”,关注后了解更多精彩内容!!!

背景

因业务侧误删一个重要的业务表,且无法通过常规手段恢复,最终为恢复此表,采用异机恢复方式,从NBU备份恢复到删除操作时间点2020年9月19日下午6点51分之前,即基于时间点2020/9/19 18:40:00的恢复,并用 open resetlogs 方式打开。

环境信息

1. 源数据环境

  • 操作系统版本:Red Hat  6.3

  • 数据库版本:11.2.0.4

2. 目标端环境

  • 操作系统版本:Red Hat  6.4

  • 数据库版本:11.2.0.4

恢复数据库(目标端操作)

1. 源端数据库生成参数文件并修改,启动目标端实例到nomount状态

cat initiyuanduanku.ora

*.control_files=+RESTORE/mubiaoku/control01.ctl,+RESTORE/mubiaoku/control02.ctl, +RESTORE/mubiaoku/control03.ctl
*.db_block_size=8192
*.db_create_file_dest=+restore
*.db_file_name_convert=+DATADG01,+RESTORE,+DATADG02,+RESTORE,+DATADG05,+RESTORE
*.db_name=yuanduan
*.diagnostic_dest=/opt/oracle/diag
*.log_archive_dest_1=location=+RESTORE
*.log_archive_max_processes=5
*.open_cursors=1000
*.sga_max_size=75G
*.shared_pool_size=19G
*.shared_pool_reserved_size=1020054732
*.sga_target=0
*.db_files=2000
  • 启动目标端到nomount状态;
sqlplus / as sysdba
startup nomount pfile=’/home/oracle/initiyuanduanku.ora’;

2. 从NBU备份中恢复控制文件,把数据库启动到 mount 状态

  • 恢复控制文件:
#!/bin/bash
rman target / log=/home/oracle/mubiaoku/rman_control_mubiaoku.log <run{
allocate channel ch00 type sbt_tape;
SEND ‘NB_ORA_SERV=XXX-XXX-BACKUP02-test,NB_ORA_CLIENT=test-dcn’;
restore controlfile from ‘/cntrl_74261_1_test’;
release channel ch00;
}
EOF
  • 恢复日志:
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Sep 19 19:40:23 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: mubiaoku (not mounted)
RMAN> 2> 3> 4> 5> 6>
using target database control file instead of recovery catalog
allocated channel: ch00
channel ch00: SID=3 device type=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 7.7.2 (2016011116)
sent command to channel: ch00
Starting restore at 19-Sep-20
channel ch00: restoring control file
channel ch00: restore complete, elapsed time: 00:00:15
output file name=+RESTORE/mubiaoku/control01.ctl
output file name=+RESTORE/mubiaoku/control02.ctl
output file name=+RESTORE/mubiaoku/control03.ctl
Finished restore at 19-Sep-20
released channel: ch00
RMAN>
Recovery Manager complete.
  • 目标库启动到mount状态
sqlplus / as sysdba
alter database mount;

3. 依据实际情况,调整文件位置

  • 调整目标库在线日志文件位置

alter database rename file +REDODG01/yuanduanku/redo03_1.log to +RESTORE/mubiaoku/redo/redo03_1.log
alter database rename file +REDODG01/yuanduanku/redo02_1.log to +RESTORE/mubiaoku/redo/redo02_1.log
alter database rename file +REDODG01/yuanduanku/redo01_1.log to +RESTORE/mubiaoku/redo/redo01_1.log
alter database rename file +REDODG01/yuanduanku/redo01_3.log to +RESTORE/mubiaoku/redo/redo01_3.log
alter database rename file +REDODG01/yuanduanku/redo02_3.log to +RESTORE/mubiaoku/redo/redo02_3.log
alter database rename file +REDODG01/yuanduanku/redo03_3.log to +RESTORE/mubiaoku/redo/redo03_3.log
alter database rename file +REDODG01/yuanduanku/redo01_2.log to +RESTORE/mubiaoku/redo/redo01_2.log
alter database rename file +REDODG01/yuanduanku/redo02_2.log to +RESTORE/mubiaoku/redo/redo02_2.log
alter database rename file +REDODG01/yuanduanku/redo03_2.log to +RESTORE/mubiaoku/redo/redo03_2.log
alter database rename file +REDODG01/yuanduanku/stbredo01_1.log to +RESTORE/mubiaoku/redo/stbredo01_1.log
alter database rename file +REDODG01/yuanduanku/stbredo02_1.log to +RESTORE/mubiaoku/redo/stbredo02_1.log
alter database rename file +REDODG01/yuanduanku/stbredo03_1.log to +RESTORE/mubiaoku/redo/stbredo03_1.log
alter database rename file +REDODG01/yuanduanku/stbredo04_1.log to +RESTORE/mubiaoku/redo/stbredo04_1.log
alter database rename file +REDODG01/yuanduanku/stbredo05_1.log to +RESTORE/mubiaoku/redo/stbredo05_1.log
......
alter database rename file +REDODG01/yuanduanku/stbredo05_3.log to +RESTORE/mubiaoku/redo/stbredo05_3.log
alter database rename file +REDODG01/yuanduanku/stbredo06_3.log to +RESTORE/mubiaoku/redo/stbredo06_3.log
alter database rename file +REDODG01/yuanduanku/stbredo07_3.log to +RESTORE/mubiaoku/redo/stbredo07_3.log
alter database rename file +REDODG01/yuanduanku/stbredo08_3.log to +RESTORE/mubiaoku/redo/stbredo08_3.log
alter database rename file +REDODG01/yuanduanku/stbredo09_3.log to +RESTORE/mubiaoku/redo/stbredo09_3.log
alter database rename file +REDODG01/yuanduanku/stbredo10_3.log to +RESTORE/mubiaoku/redo/stbredo10_3.log
  • 调整临时文件位置
alter database rename file +DATADG01/yuanduanku/temp01.dbf to +RESTORE/mubiaoku/tempfile/temp01.dbf
alter database rename file +DATADG01/tbs_forum_tmp01.dbf to +RESTORE/mubiaoku/tempfile/tbs_forum_tmp01.dbf
alter database rename file +DATADG01/tbs_sns_tmp01.dbf to +RESTORE/mubiaoku/tempfile/tbs_sns_tmp01.dbf
alter database rename file +DATADG01/tbs_henews_tmp.dbf to +RESTORE/mubiaoku/tempfile/tbs_henews_tmp.dbf
alter database rename file +DATADG01/consume/consume_temp03 to +RESTORE/mubiaoku/tempfile/consume_temp03
alter database rename file +DATADG01/consume/consume_temp04 to +RESTORE/mubiaoku/tempfile/consume_temp04
alter database rename file +DATADG01/tbs_forum_tmp02.dbf to +RESTORE/mubiaoku/tempfile/tbs_forum_tmp02.dbf
  • 调整数据文件位置

在恢复脚本中调整。

4. 恢复数据库到指定时间点

  • 恢复脚本:

rman target / log=/home/oracle/mubiaoku/rman_database_mubiaoku.log <run {
set newname for datafile 1 to +RESTORE/mubiaoku/datafile/system01.dbf;
set newname for datafile 2 to +RESTORE/mubiaoku/datafile/sysaux01.dbf;
set newname for datafile 3 to +RESTORE/mubiaoku/datafile/undotbs01.dbf;
set newname for datafile 4 to +RESTORE/mubiaoku/datafile/users01.dbf;
set newname for datafile 5 to +RESTORE/mubiaoku/datafile/undotbs02.dbf;
set newname for datafile 6 to +RESTORE/mubiaoku/datafile/undotbs03.dbf;
set newname for datafile 7 to +RESTORE/mubiaoku/datafile/tbs_henews_dat01.dbf;
set newname for datafile 8 to +RESTORE/mubiaoku/datafile/tbs_henews_dat02.dbf;
set newname for datafile 9 to +RESTORE/mubiaoku/datafile/tbs_henews_dat03.dbf;
......
set newname for datafile 202 to +RESTORE/mubiaoku/datafile/tbs_henews_dat45.dbf;
configure channel device type disk rate 51200k;
allocate channel ch00 typesbt_tape parms=ENV=(NB_ORA_CLIENT=yuanduanku-dcn);
set until time "to_date(2020/09/19 18:40:00,yyyy/mm/dd hh24:mi:ss)";
restore database;
switch datafile all;
recover database;
release channel ch00;
}
EOF

5. open resetlogs 打开数据库报错

  • 报错信息:

SQL> alter database open resetlogs;
alter database open resetlogs
*
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Process ID: 30486
Session ID: 358 Serial number: 3
  • 查看故障描述信息
SQL> ho oerr ora 39700
39700, 00000, "database must be opened with UPGRADE option"
// *Cause: A normal database open was attempted, but the database has not
// been upgraded to the current server version.
// *Action: Use the UPGRADE option when opening the database to run
// catupgrd.sql (for database upgrade), or to run catalog.sql
// and catproc.sql (after initial database creation).
  • 通过升级数据字典修复报错
sql>startup upgrade
sql>@$ORACLE_HOME/rdbms/admin/catupgrd.sql
sql>@$ORACLE_HOME/rdbms/admin/utlrp.sql

操作注意事项

1. 在控制文件恢复出来后,要先更改在线日志、临时文件位置到新的恢复目录。
2. 用 open resetlogs 打开数据库,完成不完全恢复。
3. 用 open resetlogs 打开数据库时,部分redolog错误可以忽略。


本 文 原 创 来 源:IT那活儿微信公众号(上海新炬王翦团队)




END



文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/129722.html

相关文章

  • 企业数字化转型,数据如何保护

    摘要:在企业这场数字化转型的马拉松赛跑中,聪明的正在寻求新的技术方案以保护企业的数据和业务安全,而英方不管在技术方案还是在实践案例方面,都以全新的奔跑姿态与们在同一条跑道的同一水平上。企业数字化转型就像一场马拉松赛跑,在漫长的赛道上,哪怕最顶级的选手,也有可能会被后来者赶超。因为在数字化进程中,除了业务方向跑对之外,企业的信息安全是会影响企业战略大局的关键。这绝非危言耸听,而是有事实依据。美国德克...

    bovenson 评论0 收藏0

发表评论

0条评论

IT那活儿

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<