【只读表空间--恢复-1】

1>只读 ---备份只读  故障 只读  还原有故障的数据文件

2>只读 ---备份只读  可写 故障  还原备份数据文件,重做recover

3>只读 ---备份可写  只读 故障  还原备份数据文件,recover

1>

进入rman,确保是否有备份的文件:

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 09:44:08 2014

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

connected to target database: JADL10G (DBID=2011508104)

RMAN> list backup of tablespace users;

using target database control file instead of recovery catalog

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

1       Full    609.23M    DISK        00:00:38     06-NOV-14

BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20141106T063059

Piece Name: /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T063059_b5o994hx_.bkp

List of Datafiles in backup set 1

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

4       Full 422818     06-NOV-14 /u01/oracle/oradata/jadl10g/users01.dbf

修改表空间为只读表空间:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 09:45:35 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> alter tablespace users read only;

Tablespace altered.

进入rman,重新备份数据库,删除以前备份的可以节省空间使用delete backup命令可以删除;

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 09:50:29 2014

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

connected to target database: JADL10G (DBID=2011508104)

RMAN> backup database;  --备份数据库

Starting backup at 06-NOV-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/oracle/oradata/jadl10g/system01.dbf

input datafile fno=00003 name=/u01/oracle/oradata/jadl10g/sysaux01.dbf

input datafile fno=00005 name=/u01/oracle/oradata/jadl10g/example01.dbf

input datafile fno=00002 name=/u01/oracle/oradata/jadl10g/undotbs01.dbf

input datafile fno=00004 name=/u01/oracle/oradata/jadl10g/users01.dbf

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T095036_b5onzdz1_.bkp tag=TAG20141106T095036 comment=NONE

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

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T095036_b5oo15kf_.bkp tag=TAG20141106T095036 comment=NONE

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

Finished backup at 06-NOV-14

RMAN> exit

Recovery Manager complete.

删除users表空间(只读的文件)

[[email protected] ~]$ rm /u01/oracle/oradata/jadl10g/users01.dbf

连接到DB,执行查询发现报错:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 09:52:33 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> select * from scott.dept;

select * from scott.dept

*

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4: ‘/u01/oracle/oradata/jadl10g/users01.dbf‘

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

连接到rman:

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 09:53:40 2014

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

connected to target database: JADL10G (DBID=2011508104)

RMAN> sql ‘alter database datafile 4 offline ‘; --数据文件脱机

using target database control file instead of recovery catalog

sql statement: alter database datafile 4 offline

RMAN> restore datafile 4; --恢复数据文件,此处可以是文件的路径 restore datafile ‘/u01/oracle/oradata/jadl10g/users01.dbf‘;

Starting restore at 06-NOV-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=136 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00004 to /u01/oracle/oradata/jadl10g/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T095036_b5onzdz1_.bkp

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T095036_b5onzdz1_.bkp tag=TAG20141106T095036

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

Finished restore at 06-NOV-14

RMAN> sql ‘alter database datafile 4 online ‘; ---连接数据文件

sql statement: alter database datafile 4 online

RMAN> exit

Recovery Manager complete.

连接到DB,执行查询发现可以查询到结果:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 09:55:00 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> select * from scott.dept;

DEPTNO DNAME          LOC

---------- -------------- -------------

10 ACCOUNTING     NEW YORK

20 RESEARCH       DALLAS

30 SALES          CHICAGO

40 OPERATIONS     BOSTON

2>

连接DB,修改表空间为可写:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:04:27 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> alter tablespace users read write;

Tablespace altered.

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

删除users表空间(可写的表空间):

[[email protected] ~]$ rm /u01/oracle/oradata/jadl10g/users01.dbf

连接到DB,执行查询发现报错:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:05:32 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> select * from scott.dept;

select * from scott.dept

*

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4: ‘/u01/oracle/oradata/jadl10g/users01.dbf‘

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

连接到rman:

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 10:06:31 2014

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

connected to target database: JADL10G (DBID=2011508104)

RMAN> sql ‘alter database datafile 4 offline ‘;

using target database control file instead of recovery catalog

sql statement: alter database datafile 4 offline

RMAN> restore datafile 4;

Starting restore at 06-NOV-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00004 to /u01/oracle/oradata/jadl10g/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T095036_b5onzdz1_.bkp

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T095036_b5onzdz1_.bkp tag=TAG20141106T095036

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 06-NOV-14

RMAN> recover datafile 4;

Starting recover at 06-NOV-14

using channel ORA_DISK_1

starting media recovery

media recovery complete, elapsed time: 00:00:03

Finished recover at 06-NOV-14

RMAN> sql ‘alter database datafile 4 online ‘;

sql statement: alter database datafile 4 online

RMAN> exit

Recovery Manager complete.

连接到DB,执行查询发现可以查询到结果:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:08:18 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> select * from scott.dept;

DEPTNO DNAME          LOC

---------- -------------- -------------

10 ACCOUNTING     NEW YORK

20 RESEARCH       DALLAS

30 SALES          CHICAGO

40 OPERATIONS     BOSTON

时间: 2024-10-05 04:58:49

【只读表空间--恢复-1】的相关文章

18_Oracle_Admin_只读表空间和离线表空间

一.只读表空间 只读的表空间只能进行select操作,设定只读表空间的命令为: ALTER TABLESPACE userdata READ ONLY; 设定只读表空间会触发checkpoint,将缓存中的数据写入data file:但是尽管设定了只读属性,依然可以对这个表空间进行drop操作(比如drop table),因为drop操作并没有改变表空间的结构,只是更改了数据字典里的值,而数据字典是存储在SYSTEM TABLESPACE里的,SYSTEM TABLESPACE是不可以设定为RE

Oracle 读写-只读表空间回复详解

(一) 使用备份时的控制文件进行恢复,如下图,即使用备份位置的控制文件进行恢复 1) 创建测试表空间ts1及相关测试表(表空间为ts1) [email protected]>create tablespace ts1 datafile '/u01/app/oracle/oradata/ORCL/ts1.dbf' size 10m; Tablespace created. [email protected]>create table scott.t(x int) tablespace ts1;

[20170623]利用传输表空间恢复部分数据.txt

--//昨天我测试使用传输表空间+dblink,上午补充测试发现表空间设置只读才能执行impdp导入原数据,这个也很好理解.--//这样的操作模式仅仅减少expdp生成原数据的过程. --//我想一下,rman也支持建立传输表空间的命令.我仔细看了以前的笔记,发现这样最大的有点不用设置只读,实际上它是通过建立辅组实--//例来建立传输文件,理论讲可以恢复到特定的scn,这样可以利用它解决一些误操作的问题,还是通过例子来说明问题. 1.环境:--//前面的测试有点乱,我使用冷备份恢复数据库. [e

表空间恢复数据库

第1章 故障背景 1.1 环境 硬件及软件环境: 联想服务器(IBM) 磁盘500G 没有raid centos 6.8 mysql 5.6.33 innodb引擎 独立表空间 备份没有,日志也没开 为什么没有备份和日志没有开? 因为是开发用户专用库(由开发人员自己维护) jira(bug追踪),confluence(内部知识库) 1.2 故障现象 因为是开发库,所以开发人员自己在维护,有一天,突然断电了,数据库起不来,开发人员处理了2天还没有处理好,最后就把这个问题丢给我了 我接手以后,已经是

(Les16 执行数据库恢复)-表空间恢复

NOARCHIVELOG模式下丢失了数据文件 数据库处于NOARCHIVELOG模式时,如果丢失任何数据文件,执行以下步骤 1.如果实例尚未关闭,请关闭实例 2.从备份还原整个数据库,包括所有数据文件和控制文件 3.打开数据库 4.让用户重新输入自上次备份以来所做的所有更改 ARCHIVELOG模式下丢失了非关键性数据文件(SYSTEM,UNDO除外) 仅仅恢复当前数据文件不用整库恢复,不需要停机 1.数据文件离线 2.restore数据文件,介质恢复 3.recover事务 4.数据文件联机

oracle表空间恢复

如果误删除了一个表空间中test的数据文件test.dbf,然后下次重新启动数据库的时候发       数据库不能打开了(open), 老是报错:SQL> alter database open; alter database open* ERROR at line 1: ORA-01157: cannot identify/lock data file 6 - see DBWRtrace file ORA-01110: data file 6:'/u01/app/oracle/oradata/

[转]Oracle DB 执行表空间时间点恢复

• 列出在执行表空间时间点恢复(TSPITR) 时会发生的操作 • 阐释TSPITR 使用的术语的定义 • 确定适合将TSPITR 用作解决方案的情况 • 确定时间点恢复的正确目标时间 • 确定不能使用TSPITR 的情况以及解决方法 • 执行自动TSPITR 表空间时间点恢复(TSPITR):概念 • 通过执行TSPITR 可将一个或多个表空间快速恢复到以前的某个时间. • 执行TSPITR 不会影响数据库中其它表空间或对象的状态. 使用RMAN 自动表空间时间点恢复(TSPITR) 可将Or

Oracle之表空间、索引、管理权限及角色

Oracle表空间 表空间是数据库的逻辑组成部分,从物理上讲,数据库数据存放在数据文件中 从逻辑上讲,数据库则是存放在表空间中,表空间由一个或多个数据文件组成 数据库的逻辑结构 oracle中逻辑结构包括表空间.段.区和块 说明一下数据库由表空间构成,而表空间又是由段构成,而段又是由区构成,而 区又是由oracle块构成的这样的一种结构,可以提高数据的效率 表空间用于从逻辑上组织数据库的数据.数据库逻辑上是由一个或是多个表空间组成的 通过表空间可以达到以下作用: 1.控制数据库占用的磁盘空间 2

表空间叙述

管理表空间和数据文件 介绍 表空间是数据库的逻辑组成部分 从物理上将:数据库数据存放在数据文件中 从逻辑上将:数据库则是存放在表空间中 表空间由一个或是多个数据文件组成 数据库的逻辑结构 介绍: Oracle中逻辑结构包括表空间.段.区.块 说明: 数据库由表空间构成 而表空间又是由段构成 而段又是由区构成 而区又是由Oracle块构成 这样的一种结果,可以提高数据库的效率 表空间 介绍: 表空间用于从逻辑上组织数据库的数据 数据库逻辑上是由一个或是多个表空间组成的 表空间的作用: 1.控制数据