当前位置: 首页 > news >正文

oracle表级恢复的,12c RMAN 表级恢复

利用物理备份来恢复表和分区是不行的。只能用逻辑恢复。这种情况在12c中得到了改变,

可以在truncate或drop表的情况下从RMAN备份将表或分区恢复到某个时间点或SCN和log sequence.

以下情况不能恢复

1)Tables and table partitions belonging to SYS schema cannot be recovered.

2)Tables and table partitions from SYSTEM and SYSAUX tablespaces cannot be recovered.

3)Single table partitions can be recovered only if your Oracle Database version is Oracle Database 11g Release 1 or later.

4)Tables and table partitions on standby databases cannot be recovered.Tables with named NOT NULL constraints cannot be recovered with the REMAP option.

https://www.cndba.cn/Expect-le/article/250

1)The target database must be in read-write mode.

2)The target database must be in ARCHIVELOG mode.

3)You must have RMAN backups of the tables or table partitions as they existed at the point in time to which you want recover these objects.

4)To recover single table partitions, the COMPATIBLE initialization parameter for target database must be set to 11.1.0 or higher

官方文档:

1.创建表

https://www.cndba.cn/Expect-le/article/250

SQL> conn lei/lei@zhixin

SQL> create tablespace zhixintbs datafile '/u01/oracle/oradata/zhixin/zhixintbs.dbf' size 500m autoextend on;

Tablespace created.

SQL> create table test_c tablespace zhixintbs as select * from dba_objects;

Table created.

SQL> select count(*) from test_c;

COUNT(*)

----------

90940

2.备份数据库

恢复前提是要有有效的备份,必须执行一次全备。为了恢复PDB中的表,你需要CDB的undo,SYSTEM,SYSAUX表空间的备份

和PDB的SYSTEM,SYSAUX的备份。

如果在表空间tbs1里表的索引或分区包含在表空间TBS2,只有tbs2表空间也恢复集中,你才可以

这个表。为了恢复表,这个表所有依赖的对象必须在恢复集中。。

RMAN可以恢复多个表/分区,而且不影响以及存在的对象。你可以恢复到备份之后的任意时间点。

RMAN恢复表/分区适合下面情况:https://www.cndba.cn/Expect-le/article/250

1).You need to recover a very small number of tables to a particular point in time. In this situation,

TSPITR is not the most effective solution because it moves all the objects in the tablespace to a specified point in time.

2).You need to recover tables that have been logically corrupted or have been dropped and purged.

3).Flashback Table is not possible because the desired point-in-time is older than available undo.

4).You want to recover data that is lost after a DDL operation modified the structure of tables.

Using Flashback Table is not possible because a DDL was run on the tables between the desired point in time and the current time.

Flashback Table cannot rewind tables through structural changes such as a truncate table operation.

--恢复流程:

1)确定要恢复的表/分区所需的备份集https://www.cndba.cn/Expect-le/article/250

2)在恢复表/分区的过程中,一个辅助数据库会临时设置为某个时间点

4)你可以从原数据库导入表/分区(可选)

5)在恢复过程中进行重命名操作(可选)

--备份数据库

[root@rac2 ~]# su - oracle

[oracle@rac2 ~]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Sep 8 01:58:11 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ZXKJ (DBID=1929263251)

RMAN>backup database;

Starting backup at 2016:09:08 19:58:16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=261 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

······略

channel ORA_DISK_1: finished piece 1 at 2016:09:08 19:59:14

piece handle=/u01/oracle/fast_recovery_area/ZXKJ_S/3A3486B9DE751C7CE053B501A8C094BC/backupset/2016_09_08/o1_mf_nnndf_TAG20160908T015817_cx0ocd0b_.bkp tag=TAG20160908T015817 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

Finished backup at 2016:09:08 19:59:15

Starting Control File and SPFILE Autobackup at 2016:09:08 19:59:15

piece handle=/u01/oracle/fast_recovery_area/ZXKJ_S/autobackup/2016_09_08/o1_mf_s_921981555_cx0ocnbz_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 2016:09:08 19:59:16

3.查看drop之前的scn

SQL> select current_scn from v$database;

CURRENT_SCN

-----------

5810317

4.drop掉表

SQL> conn lei/lei@zhixin

Connected.

SQL> drop table test_c;

Table dropped.

SQL> select count(*) from test_c;

select count(*) from test_c

*

ERROR at line 1:

ORA-00942: table or view does not exist

5.尝试恢复

恢复一定要指定AUXILIARY DESTINATION和TIME,SCN,SEQUENCE中一个

AUXILIARY DESTINATION:RMAN在恢复过程中用到的一个辅助数据库

RMAN target /

target database Password:

connected to target database: ZXKJ (DBID=1929263251)

这里遇到个奇葩的问题就是指定时间点还原的时候报错,找了半天也没发现哪边有问题。

run{

RECOVER TABLE lei.test_c

UNTIL TIME "to_char('20160908 18:29:13','yyyymmdd hh24:mi:ss')"

AUXILIARY DESTINATION '/u01/oracle';

}

Starting recover at 2016:09:0819:05:35

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 09/08/2016 20:00:35

ORA-00907: missing right parenthesis

只能这样了,一小时之前。或者用SCN

run{

RECOVER TABLE lei.test_c

UNTIL TIME 'sysdate - 1/24'

AUXILIARY DESTINATION '/tmp/oracle/recover';

}

5.1创建恢复目录

[root@rac1 ZXKJ_P]# mkdir /home/oracle/recover

[root@rac1 ZXKJ_P]# chown oracle:oinstall /home/oracle/recover

run{

RECOVER TABLE lei.test_c of pluggable database zhixin

UNTIL SCN 5810317

AUXILIARY DESTINATION '/home/oracle/recover'

datapump destination '/home/oracle/recover';

}

Starting recover at 2016:09:0820:06:16

using channel ORA_DISK_1

RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments

Tablespace SYSTEM

Tablespace UNDOTBS1

Creating automatic instance, with SID='sfdv'

initialization parameters used for automatic instance:

db_name=ZXKJ

db_unique_name=sfdv_pitr_zhixin_ZXKJ

compatible=12.1.0.2.0

db_block_size=8192

db_files=200

diagnostic_dest=/u01/oracle

_system_trig_enabled=FALSE

sga_target=1504M

processes=200

db_create_file_dest=/u01/oracle

log_archive_dest_1='location=/u01/oracle'

enable_pluggable_database=true

_clone_one_pdb_recovery=true

#No auxiliary parameter file used

.......

auxiliary instance file /home/oracle/recover/ZXKJ_P/datafile/o1_mf_sysaux_cx36k1xq_.dbf deleted

auxiliary instance file /home/oracle/recover/ZXKJ_P/datafile/o1_mf_undotbs1_cx36k1yc_.dbf deleted

auxiliary instance file /home/oracle/recover/ZXKJ_P/datafile/o1_mf_system_cx36k1yb_.dbf deleted

auxiliary instance file /home/oracle/recover/ZXKJ_P/controlfile/o1_mf_cx36jw5r_.ctl deleted

auxiliary instance file tspitr_dhEo_52195.dmp deleted

Finished recover at 2016:09:0901:07:

在这个过程中,会新建一个auxiliary  instance,然后在auxiliary instance上做全库恢复,再通过datapump工具导出和导入,整个过程和TSPITR很相似.

5.3 验证数据

SQL> select count(*) from test_c;

COUNT(*)

----------

90940

表又回来了。

版权声明:本文为博主原创文章,未经博主允许不得转载。

12c rman

相关文章:

  • linux 查看文件多少m,linux 查询文件大小M为单位
  • linux服务器怎么安装证书,linux服务器证书安装指引
  • linux内核风格,Linux内核编码风格
  • centos 7 linux 内核,如何在Centos 7上升级Linux Kernel(内核)
  • windows和linux下如何查看端口被哪个进程占用,Windows查看端口被哪个进程占用
  • linux 怎么查看哪些端口被占用了,linux 怎么查看那些端口被占用
  • linux重新格式化分区表,linux 分区重新格式化
  • thrift linux java,Thrift, Protocol Buffers installation and Java code howto
  • linux里c语言实现http服务序,c/s模式Linux下用c语言实现发送http请求
  • linux下llt测试技巧,HLT与LLT测试简介
  • Linux系统安装matplotlib,linux – ImportError:没有安装了matplotlib的名为matplotlib的模块...
  • linux+qq+输入法下载官网,续:Linux下安装输入法和QQ软件
  • linux文件io缓冲区,linux下的文件IO缓冲区,及其相关操作
  • C语言坐标系判断范围,给定坐标点,判断是否在某区域范围内 地理围栏算法
  • c语言编程函数坐标式,vc++ 6.0 里面有没有坐标函数哦
  • [原]深入对比数据科学工具箱:Python和R 非结构化数据的结构化
  • 【402天】跃迁之路——程序员高效学习方法论探索系列(实验阶段159-2018.03.14)...
  • 【node学习】协程
  • 【挥舞JS】JS实现继承,封装一个extends方法
  • 5分钟即可掌握的前端高效利器:JavaScript 策略模式
  • centos安装java运行环境jdk+tomcat
  • Docker 1.12实践:Docker Service、Stack与分布式应用捆绑包
  • es6要点
  • Git学习与使用心得(1)—— 初始化
  • JavaScript中的对象个人分享
  • PaddlePaddle-GitHub的正确打开姿势
  • Python实现BT种子转化为磁力链接【实战】
  • SpingCloudBus整合RabbitMQ
  • ubuntu 下nginx安装 并支持https协议
  • 编写高质量JavaScript代码之并发
  • 从重复到重用
  • 分享一份非常强势的Android面试题
  • 机器学习中为什么要做归一化normalization
  • 基于web的全景—— Pannellum小试
  • 简析gRPC client 连接管理
  • 你真的知道 == 和 equals 的区别吗?
  • 实战:基于Spring Boot快速开发RESTful风格API接口
  • 世界上最简单的无等待算法(getAndIncrement)
  •  一套莫尔斯电报听写、翻译系统
  • 用quicker-worker.js轻松跑一个大数据遍历
  • Redis4.x新特性 -- 萌萌的MEMORY DOCTOR
  • ​一、什么是射频识别?二、射频识别系统组成及工作原理三、射频识别系统分类四、RFID与物联网​
  • #LLM入门|Prompt#1.8_聊天机器人_Chatbot
  • (04)odoo视图操作
  • (9)YOLO-Pose:使用对象关键点相似性损失增强多人姿态估计的增强版YOLO
  • (C#)一个最简单的链表类
  • (C++17) std算法之执行策略 execution
  • (附源码)ssm考生评分系统 毕业设计 071114
  • (区间dp) (经典例题) 石子合并
  • (三)Pytorch快速搭建卷积神经网络模型实现手写数字识别(代码+详细注解)
  • (十六)Flask之蓝图
  • (四)linux文件内容查看
  • (转)Linux下编译安装log4cxx
  • (转)ORM
  • ... 是什么 ?... 有什么用处?