准备工作,使用如下脚本进行数据库的全备份
[oracle@localhost ~]$ more rman_backup.sh
#!/bin/sh

RMAN_OUTPUT_LOG=/home/oracle/rman_output.log
RMAN_ERROR_LOG=/home/oracle/rman_error.log
rman target / log=/home/oracle/rman_output.log<<EOF
run
{
allocate channel ch1 device type disk;
backup full database format '/home/oracle/rman_bakckup/db_fullbackup_%d_%s_%p_%T';
backup current controlfile format '/home/oracle/rman_bakckup/ctl_%d_%s_%p_%T';
backup archivelog all format '/home/oracle/rman_bakckup/arch_%d_%s_%p_%T';
backup spfile format '/home/oracle/rman_bakckup/spfile_%d_%s_%p_%T';
release channel ch1;
}
EOF

1.退出日志应用模式
[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 14 14:31:26 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

SQL> connect / as sysdba
Connected.
SQL> alter database recover managed standby database cancel;

Database altered.

2.停掉数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

3.模拟删除掉users01.dbf数据文件
[oracle@localhost slnngkdg]$cd /u01/app/oracle/oradata/slnngkdg
[oracle@localhost slnngkdg]$ mv users01.dbf bak_users01.dbf

4.启动数据库
SQL> startup
ORACLE instance started.

Total System Global Area 3724607488 bytes
Fixed Size 2258760 bytes
Variable Size 788531384 bytes
Database Buffers 2919235584 bytes
Redo Buffers 14581760 bytes
Database mounted.
ORA-10458: standby database requires recovery
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/slnngkdg/users01.dbf'

提示数据文件找不到

5.完成恢复数据库
步骤4的已经启动数据库到mount状态,可以直接做恢复
run{
restore database;
recover database;
}

RMAN> run{
2> restore database;
3> recover database;
4> }

Starting restore at 14-JAN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/slnngkdg/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/slnngkdg/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/slnngkdg/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/slnngkdg/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/slnngkdg/tps_data01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/slnngkdg/mrkt.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rman_bakckup/db_fullbackup_SLNNGK_26_1_20190114
channel ORA_DISK_1: piece handle=/home/oracle/rman_bakckup/db_fullbackup_SLNNGK_26_1_20190114 tag=TAG20190114T140841
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:55
Finished restore at 14-JAN-19

Starting recover at 14-JAN-19
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 281 is already on disk as file /u01/app/oracle/archlog/1_281_994182077.dbf
archived log for thread 1 with sequence 282 is already on disk as file /u01/app/oracle/archlog/1_282_994182077.dbf
archived log file name=/u01/app/oracle/archlog/1_281_994182077.dbf thread=1 sequence=281
archived log file name=/u01/app/oracle/archlog/1_282_994182077.dbf thread=1 sequence=282
unable to find archived log
archived log thread=1 sequence=283
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/14/2019 15:12:39
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 283 and starting SCN of 5975154

原以为在主库做alter system switch logfile把283的归档日志同步到从库即可解决问题,但是还是不行,283的同步过去了,又要找284的
archived log thread=1 sequence=284
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/14/2019 15:25:39
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 284 and starting SCN of 5976687

6.只能做不完全恢复(注意::until不包括这个点,如until sequence 284,则不包括sequence 284)
run{
set until sequence 284;
restore database;
recover database;
}

RMAN> run{
2> set until sequence 284;
restore database;
recover database;
3> 4> 5> }

executing command: SET until clause

Starting restore at 14-JAN-19
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/slnngkdg/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/slnngkdg/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/slnngkdg/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/slnngkdg/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/slnngkdg/tps_data01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/slnngkdg/mrkt.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rman_bakckup/db_fullbackup_SLNNGK_26_1_20190114
channel ORA_DISK_1: piece handle=/home/oracle/rman_bakckup/db_fullbackup_SLNNGK_26_1_20190114 tag=TAG20190114T140841
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:15
Finished restore at 14-JAN-19

Starting recover at 14-JAN-19
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 281 is already on disk as file /u01/app/oracle/archlog/1_281_994182077.dbf
archived log for thread 1 with sequence 282 is already on disk as file /u01/app/oracle/archlog/1_282_994182077.dbf
archived log for thread 1 with sequence 283 is already on disk as file /u01/app/oracle/archlog/1_283_994182077.dbf
archived log file name=/u01/app/oracle/archlog/1_281_994182077.dbf thread=1 sequence=281
archived log file name=/u01/app/oracle/archlog/1_282_994182077.dbf thread=1 sequence=282
archived log file name=/u01/app/oracle/archlog/1_283_994182077.dbf thread=1 sequence=283
media recovery complete, elapsed time: 00:00:18
Finished recover at 14-JAN-19

7.打开数据库
SQL> alter database open;

Database altered.

从库必须是以open的方式打开,不能使用resetlogs选项

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/14/2019 16:56:15
ORA-01666: control file is for a standby database

8.应用主库日志
alter database recover managed standby database using current logfile disconnect from session;

dataguard从库数据库丢失恢复例子(模拟丢失数据文件)的更多相关文章

  1. RMAN数据库恢复之恢复表空间和数据文件

    执行表空间或数据文件恢复时,数据库既可以是MOUNT状态,也可以是OPEN状态.1.恢复表空间在执行恢复之前,如果被操作的表空间未处理OFFLINE状态,必须首先通过ALTER TABLESPACE… ...

  2. dataguard从库数据库丢失恢复例子(模拟所有的控制文件)

    1.退出日志应用模式[oracle@localhost ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 14 ...

  3. oracle 12c 多租户 pdb 恢复(单个pdb数据文件、非系统pdb表空间、整个pdb数据库)

    环境:数据库版本 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 实验准备:1.-- 数据库归 ...

  4. ORACLE模拟一个数据文件坏块并使用RMAN备份来恢复

    1.创建一个实验用的表空间并在此表空间上创建表 create tablespace blocktest datafile '/u01/oradata/bys1/blocktest.dbf' size ...

  5. Linux环境下利用句柄恢复Oracle误删除的数据文件

    在误删除Oracle的数据文件后,如果未关闭数据库,文件句柄还没有释放,且被删除的数据文件占用的磁盘块未被复写,则可以利用句柄的方式来恢复数据文件.下面模拟恢复过程. (一)环境 OS版本:redha ...

  6. [工作相关] GS产品使用LInux下Oracle数据库以及ASM存储时的数据文件路径写法.

    1. 自从公司的GS5版本就已经支持Linux下的oracle数据库通过安装工具自动安装注册了, 只不过路径需要使用linux的命名规则, 如图: /home/oracle/ 注意 最后是有一个 斜线 ...

  7. vs2010开发环境恢复--(mysql,数据文件可直接拷贝,并可用navicat直接管理)

    一.linq to mysql (DBLINQ) 1.安装mysql phpstudy2014,数据库文件可直接拷贝,在命令行中运行select version();查看版本为5.5.38 ,单独安装 ...

  8. dataguard从库删除归档的例子

    deletearchlog.sh #!/bin/sh export PATH TABLE='v$archived_log' sqlplus -silent "/ as sysdba" ...

  9. GS70 使用 Linux 下面Oracle数据库时 设定 特定目录存储数据文件

    1. 创建目录 mkdir /cwdata 2. 修改目录属性 chown -R oracle:oinstall /cwdata chmod -R /cwdata 效果为: 创建数据库实例时的界面为: ...

随机推荐

  1. 记录一份Oracle 正确的监听配置文件listener.ora与tnsnames.ora

    一.前言 昨天中午接到领导指示,有其他组的负责人B在厄瓜多尔演示他们组的产品,然后我们组的负责人就想说也在那边搭一套环境,(北美那边的亚马逊云环境),让B帮忙演示下我们的系统. 于是,开始了一个比较曲 ...

  2. Linux Tomcat8 启动堆内存溢出

    今天在部署一个开源项目的时候,Tomcat8启动异常,报错信息: Exception in thread "RMI TCP Connection(idle)" java.lang. ...

  3. 对unicode数据进行部分replace

    unicode = u'\u9879\u76ee\u7ba1\u7406\u90e8' print unicode #项目管理部 unicode = unicode.replace("项目& ...

  4. 1 主机WiFi连接下与虚拟机通信问题

    环境: 主机:win10系统 虚拟机软件:VMware 虚拟机:winserver 2012 R2 datacenter (数据中心版) 网络上有很多方法说设置NAT模式,并不好用,主机如果用网线连接 ...

  5. eclipse反编译不起作用

    今天用eclipse安装反编译插件,分别按百度安装了好几个,但是都没起到作用.想想可能是因为我的eclipse是现在最新的版本,可能以前的方法不适用了,所以就自己折腾了一下.以下为教程: 1.首先我的 ...

  6. ArcGIS Runtime For Android setViewpointCenterAsync(Point center, double scale)效果奇葩,不响应

    最近做一个东西,用的是ArcGIS Runtime Sdk for Android 100.1.0,由于刚用这个版本,理解不够,出现了一个奇葩问题 在对FeatureLayer进行Query之后,想要 ...

  7. 计算属性和监听,computed,watch

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 爬虫IP代理中的http与https

    之前使用代理IP,构造的proxies一直都是http模式 proxies={"http": "http://{}".format(ip)} 但是今天遇到的网站 ...

  9. Java编程基础篇第一章

    计算机语言 人与计算机交流的方式. 计算机语言有很多种如:C语言,c++,Java等 人机交互 软件的出现实现了人与计算机之间的更好的交流(交互) 交互方式 图形化界面:便于交互,容易操作,简单直观, ...

  10. MySQL慢查询语句的定位

    使用以下语句可以查询相关的配置和日志所在位置: show variables like '%slow%'; 名词解释: log_slow_admin_statements: 打开后可以将一些比较慢的管 ...