(Les16 执行数据库恢复)-表空间恢复
set linesize 300
set pagesize 600
col file_name format a50
col tablespace_name format a20
select tablespace_name,file_name from dba_data_files; 创建一个非关键表空间进行测试 create tablespace redo_data datafile '/u01/app/oracle/oradata/xiocpt0/redo_data01.dbf' size 32M autoextend on next 32M maxsize 1024M; SQL> create tablespace redo_data datafile '/u01/app/oracle/oradata/xiocpt0/redo_data01.dbf' size 32M autoextend on next 32M maxsize 1024M; Tablespace created. SQL> set linesize 300
set pagesize 600
col file_name format a50
col tablespace_name format a20
select tablespace_name,file_name from dba_data_files; TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
USERS /u01/app/oracle/oradata/xiocpt0/users01.dbf
UNDOTBS1 /u01/app/oracle/oradata/xiocpt0/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/xiocpt0/sysaux01.dbf
SYSTEM /u01/app/oracle/oradata/xiocpt0/system01.dbf
REDO_DATA /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG; 对数据进行一次完全备份 RMAN> shutdown immediate
RMAN> startup mount
RMAN> run
{
allocate channel c1 device type disk format '/u01/backup/backup01_%U' ;
backup as compressed backupset database;
backup current controlfile;
alter database open;
} RMAN> list backup; List of Backup Sets
=================== BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Full 321.23M DISK 00:00:38 22-MAY-18
BP Key: 7 Status: AVAILABLE Compressed: YES Tag: TAG20180522T151208
Piece Name: /u01/backup/backup01_08t3hoq8_1_1
List of Datafiles in backup set 7
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1058982 22-MAY-18 /u01/app/oracle/oradata/xiocpt0/system01.dbf
2 Full 1058982 22-MAY-18 /u01/app/oracle/oradata/xiocpt0/sysaux01.dbf
3 Full 1058982 22-MAY-18 /u01/app/oracle/oradata/xiocpt0/undotbs01.dbf
4 Full 1058982 22-MAY-18 /u01/app/oracle/oradata/xiocpt0/users01.dbf
5 Full 1058982 22-MAY-18 /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8 Full 1.05M DISK 00:00:03 22-MAY-18
BP Key: 8 Status: AVAILABLE Compressed: YES Tag: TAG20180522T151208
Piece Name: /u01/backup/backup01_09t3horl_1_1
SPFILE Included: Modification time: 22-MAY-18
SPFILE db_unique_name: XIOCPT0
Control File Included: Ckp SCN: 1058982 Ckp time: 22-MAY-18 BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 9.64M DISK 00:00:01 22-MAY-18
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20180522T151257
Piece Name: /u01/backup/backup01_0at3horp_1_1
Control File Included: Ckp SCN: 1058982 Ckp time: 22-MAY-18 创建表并指定表空间 SQL> create table REDO_DATA(
2 id number,
3 name varchar2(20)
4 )
5 tablespace REDO_DATA; Table created. SQL> declare
v_count number; begin
for i in 1..1000 loop
insert into redo_data values(i,'name0'||i);
end loop;
end;
/ 2 3 4 5 6 7 8 9 PL/SQL procedure successfully completed. SQL> commit; Commit complete. SQL> select count(*) from REDO_DATA; COUNT(*)
----------
1000 恢复非关键表空间 sql 'alter tablespace redo_data offline';---离线需恢复的表空间 restore tablespace redo_data;---还原表空间
recover tablespace redo_data;---恢复表空间,期间的事务进行应用 sql 'alter tablespace redo_data online';---恢复完成,将表空间在线 删除数据文件
SQL> !rm -rf /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf SQL> select count(*) from REDO_DATA; COUNT(*)
----------
1000 SQL> commit; Commit complete. SQL> declare
v_count number; begin
for i in 1..1000 loop
insert into redo_data values(i,'name0'||i);
end loop;
end;
/ 2 3 4 5 6 7 8 9 PL/SQL procedure successfully completed. SQL> commit; Commit complete. SQL> select count(*) from REDO_DATA; COUNT(*)
----------
2000 SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf
ls: cannot access /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf: No such file or directory SQL> select table_name ,tablespace_name from dba_tables where table_name='REDO_DATA'; TABLE_NAME TABLESPACE_NAME
------------------------------ --------------------
REDO_DATA REDO_DATA SQL> alter system switch logfile; System altered. SQL> alter system checkpoint; System altered. SQL> select count(*) from REDO_DATA; COUNT(*)
----------
2000 SQL> declare
v_count number; begin
for i in 1..1000 loop
insert into redo_data values(i,'name0'||i);
end loop;
end;
/ 2 3 4 5 6 7 8 9 PL/SQL procedure successfully completed. SQL> declare
v_count number; begin
for i in 1..1000 loop
insert into redo_data values(i,'name0'||i);
end loop;
end;
/ 2 3 4 5 6 7 8 9 PL/SQL procedure successfully completed. SQL> declare
v_count number; begin
for i in 1..1000 loop
insert into redo_data values(i,'name0'||i);
end loop;
end;
/ 2 3 4 5 6 7 8 9 PL/SQL procedure successfully completed. SQL> commit; Commit complete. SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf
ls: cannot access /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf: No such file or directory SQL> select count(*) from REDO_DATA;
select count(*) from REDO_DATA
*
ERROR at line 1:
ORA-00376: file 5 cannot be read at this time
ORA-01110: data file 5: '/u01/app/oracle/oradata/xiocpt0/redo_data01.dbf' 开始执行还原/恢复操作 RMAN> sql 'alter tablespace redo_data offline'; sql statement: alter tablespace redo_data offline RMAN>
restore tablespace redo_data;
RMAN> Starting restore at 22-MAY-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 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 00005 to /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/backup01_08t3hoq8_1_1
channel ORA_DISK_1: piece handle=/u01/backup/backup01_08t3hoq8_1_1 tag=TAG20180522T151208
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 22-MAY-18 RMAN> recover tablespace redo_data; Starting recover at 22-MAY-18
using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 74 is already on disk as file /u01/archive/arch_976375926_1_74.arc
archived log for thread 1 with sequence 75 is already on disk as file /u01/archive/arch_976375926_1_75.arc
archived log for thread 1 with sequence 76 is already on disk as file /u01/archive/arch_976375926_1_76.arc
archived log for thread 1 with sequence 77 is already on disk as file /u01/archive/arch_976375926_1_77.arc
archived log for thread 1 with sequence 78 is already on disk as file /u01/archive/arch_976375926_1_78.arc
archived log for thread 1 with sequence 79 is already on disk as file /u01/archive/arch_976375926_1_79.arc
archived log for thread 1 with sequence 80 is already on disk as file /u01/archive/arch_976375926_1_80.arc
archived log for thread 1 with sequence 81 is already on disk as file /u01/archive/arch_976375926_1_81.arc
archived log for thread 1 with sequence 82 is already on disk as file /u01/archive/arch_976375926_1_82.arc
archived log for thread 1 with sequence 83 is already on disk as file /u01/archive/arch_976375926_1_83.arc
archived log for thread 1 with sequence 84 is already on disk as file /u01/archive/arch_976375926_1_84.arc
archived log for thread 1 with sequence 85 is already on disk as file /u01/archive/arch_976375926_1_85.arc
archived log file name=/u01/archive/arch_976375926_1_74.arc thread=1 sequence=74
archived log file name=/u01/archive/arch_976375926_1_75.arc thread=1 sequence=75
archived log file name=/u01/archive/arch_976375926_1_76.arc thread=1 sequence=76
archived log file name=/u01/archive/arch_976375926_1_77.arc thread=1 sequence=77
archived log file name=/u01/archive/arch_976375926_1_78.arc thread=1 sequence=78
archived log file name=/u01/archive/arch_976375926_1_79.arc thread=1 sequence=79
archived log file name=/u01/archive/arch_976375926_1_80.arc thread=1 sequence=80
media recovery complete, elapsed time: 00:00:00
Finished recover at 22-MAY-18 RMAN> sql 'alter tablespace redo_data online'; sql statement: alter tablespace redo_data online SQL> select count(*) from REDO_DATA; COUNT(*)
----------
5000
SQL> set linesize 300
set pagesize 600
col file_name format a50
col tablespace_name format a20
select tablespace_name,file_name from dba_data_files;SQL> SQL> SQL> SQL> TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
USERS /u01/app/oracle/oradata/xiocpt0/users01.dbf
UNDOTBS1 /u01/app/oracle/oradata/xiocpt0/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/xiocpt0/sysaux01.dbf
SYSTEM /u01/app/oracle/oradata/xiocpt0/system01.dbf
REDO_DATA /u01/app/oracle/oradata/xiocpt0/redo_data01.dbf SQL>
SQL> !rm -rf /u01/app/oracle/oradata/xiocpt0/system01.dbf startup mount ---将数据库启动到mount
restore tablespace system;---指定关键表空间进行还原
recover tablespace system;---恢复表空间
sql 'alter database open';---将数据库打开 [oracle@t-xi-oracle01 ~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Tue May 22 15:30:33 2018 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database (not started) RMAN> startup mount Oracle instance started
database mounted Total System Global Area 409194496 bytes Fixed Size 2253744 bytes
Variable Size 322964560 bytes
Database Buffers 79691776 bytes
Redo Buffers 4284416 bytes RMAN> restore tablespace system; Starting restore at 22-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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/xiocpt0/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/backup01_08t3hoq8_1_1
channel ORA_DISK_1: piece handle=/u01/backup/backup01_08t3hoq8_1_1 tag=TAG20180522T151208
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 22-MAY-18 RMAN> recover tablespace system; Starting recover at 22-MAY-18
using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 74 is already on disk as file /u01/archive/arch_976375926_1_74.arc
archived log for thread 1 with sequence 75 is already on disk as file /u01/archive/arch_976375926_1_75.arc
archived log for thread 1 with sequence 76 is already on disk as file /u01/archive/arch_976375926_1_76.arc
archived log for thread 1 with sequence 77 is already on disk as file /u01/archive/arch_976375926_1_77.arc
archived log for thread 1 with sequence 78 is already on disk as file /u01/archive/arch_976375926_1_78.arc
archived log for thread 1 with sequence 79 is already on disk as file /u01/archive/arch_976375926_1_79.arc
archived log for thread 1 with sequence 80 is already on disk as file /u01/archive/arch_976375926_1_80.arc
archived log for thread 1 with sequence 81 is already on disk as file /u01/archive/arch_976375926_1_81.arc
archived log for thread 1 with sequence 82 is already on disk as file /u01/archive/arch_976375926_1_82.arc
archived log for thread 1 with sequence 83 is already on disk as file /u01/archive/arch_976375926_1_83.arc
archived log for thread 1 with sequence 84 is already on disk as file /u01/archive/arch_976375926_1_84.arc
archived log for thread 1 with sequence 85 is already on disk as file /u01/archive/arch_976375926_1_85.arc
archived log for thread 1 with sequence 86 is already on disk as file /u01/archive/arch_976375926_1_86.arc
archived log file name=/u01/archive/arch_976375926_1_74.arc thread=1 sequence=74
archived log file name=/u01/archive/arch_976375926_1_75.arc thread=1 sequence=75
archived log file name=/u01/archive/arch_976375926_1_76.arc thread=1 sequence=76
archived log file name=/u01/archive/arch_976375926_1_77.arc thread=1 sequence=77
archived log file name=/u01/archive/arch_976375926_1_78.arc thread=1 sequence=78
archived log file name=/u01/archive/arch_976375926_1_79.arc thread=1 sequence=79
archived log file name=/u01/archive/arch_976375926_1_80.arc thread=1 sequence=80
archived log file name=/u01/archive/arch_976375926_1_81.arc thread=1 sequence=81
media recovery complete, elapsed time: 00:00:00
Finished recover at 22-MAY-18 RMAN> sql 'alter database open'; sql statement: alter database open
(Les16 执行数据库恢复)-表空间恢复的更多相关文章
- RMAN数据库恢复之恢复表空间和数据文件
执行表空间或数据文件恢复时,数据库既可以是MOUNT状态,也可以是OPEN状态.1.恢复表空间在执行恢复之前,如果被操作的表空间未处理OFFLINE状态,必须首先通过ALTER TABLESPACE… ...
- [20170623]利用传输表空间恢复数据库2.txt
[20170623]利用传输表空间恢复数据库2.txt --//继续上午的测试,测试truncate,是否可行,理论讲应该没有问题.我主要的目的测试是否要切换日志.--//参考链接 : http:// ...
- Oracle 表空间恢复
为啥要写这个呢,因为之前遇到个场景.操作系统为Solaris的,oracle11.2.0.4. 一个运维把一张关键表drop了.然后发现recyclebin是off的,然后..然后好像只能从备份里面找 ...
- [20170627]使用TSPITR恢复表空间.txt
[20170627]使用TSPITR恢复表空间.txt --//RMAN提供了一种实现所谓TSPITR(Tablespace Point-In-Time Recovery)的技术,通过简单的一个语句, ...
- [20170623]利用传输表空间恢复部分数据.txt
[20170623]利用传输表空间恢复部分数据.txt --//昨天我测试使用传输表空间+dblink,上午补充测试发现表空间设置只读才能执行impdp导入原数据,这个也很好理解.--//这样的操作模 ...
- 如何用Dummy实例执行数据库的还原和恢复
今天实验了一下,如何在所有文件,包括数据文件,在线日志文件,控制文件都丢失的情况下,利用RMAN备份恢复和还原数据库.该实验的重点是用到了Dummy实例. 具体步骤如下: 备份数据库 [oracle@ ...
- Oracle 删除用户和表空间////Oracle创建删除用户、角色、表空间、导入导出、...命令总结/////Oracle数据库创建表空间及为用户指定表空间
Oracle 使用时间长了, 新增了许多user 和tablespace. 需要清理一下 对于单个user和tablespace 来说, 可以使用如下命令来完成. 步骤一: 删除user drop ...
- ORACLE RMAN备份及还原 RMAN能够进行增量备份:数据库,表空间,数据文件
ORACLE RMAN备份及还原 RMAN能够进行增量备份:数据库.表空间.数据文件 仅仅有使用过的block能够被备份成backup set 表空间与数据文件相应关系:dba_data_file ...
- orale数据库.实例.表空间.用户.表
近期因为工作原因接触到Oracle数据库.了解到Oracle和mysql的结构上还是有很大的区别的. Oracle数据库---实例---表空间---用户---表 我们将从这5个方面来了解Oracle ...
随机推荐
- JS 变量 命名规范 oDiv aDiv 等
l命名规范及必要性 l可读性--能看懂 l规范性--符合规则 l匈牙利命名法 l类型前缀 类型 前缀 类型 实例 数组 a Array aItems 布尔值 b Boolean bIsComplete ...
- html5 css选择器 井号, 句点的区别
一.理解CSS的样式组成CSS里的样式表是有规则组成的,每条规则有三个部分组成:1.选择器(如下面例子中的:"body"),告诉浏览器文档的哪个部分受规则影响:2.属性(如实例中的 ...
- css多行文本省略号(...)
如果实现单行文本的溢出显示省略号同学们应该都知道用text-overflow:ellipsis属性来,当然还需要加宽度width属来兼容部分浏览. 实现单行文本省略 <!DOCTYPE html ...
- C#-求int数组中连续偶数列的个数
例如:[3, 3, 2, 2, 2, 4, 3, 5, 4, 6, 3]=>2,2,2,4;4,6 结果为2 [3, 3, 2,3, 2, 2, 4, 3, 5, 4, 6, 3]=&g ...
- 一些 Mysql 维护命令
----------------------------------------------------------------------------使用mysql客户端程序------------ ...
- 微信小程序开发7-JavaScript脚本
1.小程序的主要开发语言是 JavaScript ,开发者使用 JavaScript 来开发业务逻辑以及调用小程序的 API 来完成业务需求. 2.ECMAScript 在大部分开发者看来,ECMAS ...
- linux下C语言三种get输入方式
第一种:scanf() #include "stdio.h" #include "string.h" int main() { ]; scanf("% ...
- Spring3实战第一章 Aop 切面 XML配置
刚看spring3实战书籍第一章 切面以前没有关注过 现在看到了 随手试验一下 AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Objec ...
- 外贸电商的ERP有很多
经常有人问我:市面上针对外贸电商的ERP有很多,为什么有的卖家用得风生水起,而我却觉得每款都不合适?一般我都是拒绝回答的,一是因为这种情况大多数跟ERP实施有关,很难用短短几千字就说清楚:二是因为我也 ...
- 常见网络编程面试题答案征集与面试题(收集) ZZ 【网络编程】
http://www.cnblogs.com/wickedboy237/archive/2013/05/12/3074362.html 1:tcp和udp的区别2:流量控制和拥塞控制的实现机制3:滑动 ...