广告
返回顶部
首页 > 资讯 > 数据库 >Oracle 学习之RMAN(十三)恢复实战--数据块修复
  • 582
分享到

Oracle 学习之RMAN(十三)恢复实战--数据块修复

2024-04-02 19:04:59 582人浏览 安东尼
摘要

  在很多情况下,数据库只是某个数据文件的些许数据块发生损坏。这种情况,我们当然可是使用数据库恢复或者数据文件恢复的方式来解决问题。但是有点高射炮打蚊子的感觉。幸好RMAN提供了块级别的恢复。下面

  在很多情况下,数据库只是某个数据文件的些许数据块发生损坏。这种情况,我们当然可是使用数据库恢复或者数据文件恢复的方式来解决问题。但是有点高射炮打蚊子的感觉。幸好RMAN提供了块级别的恢复。下面我们来演示一下。

 1. 创建一个表空间,大小小一点。


sql> conn / as sysdba
Connected.
SQL> create tablespace tbs_blkerr datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf' size 128K;

Tablespace created.

 2. 在这个表空间上创建一个表,并且装满数据。

SQL> create table emp_blk tablespace tbs_blkerr as select * from scott.emp;

Table created.

SQL> insert into emp_blk select * from scott.emp;

14 rows created.

SQL> /

14 rows created.

。。。。

SQL> insert into emp_blk select * from scott.emp;
insert into emp_blk select * from scott.emp
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.EMP_BLK by 8 in tablespace TBS_BLKERR


SQL> commit;

Commit complete.

SQL> select count(*) from emp_blk;

  COUNT(*)
----------
       686

SQL>

3. 备份该表空间或者数据文件。

RMAN> backup datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf';

Starting backup at 2015/07/09 10:30:11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/devdb/blkerr01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/09 10:30:11
channel ORA_DISK_1: finished piece 1 at 2015/07/09 10:30:12
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/09 10:30:12

4. 使用vi编辑数据文件blkerr01.dbf,对文件尾部做稍微的修改

  

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  839282688 bytes
Fixed Size		    2233000 bytes
Variable Size		  553651544 bytes
Database Buffers	  281018368 bytes
Redo Buffers		    2379776 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oracle/oradata/devdb/blkerr01.dbf'
RMAN> restore datafile 7;

Starting restore at 2015/07/09 10:36:25
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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 00007 to /u01/app/oracle/oradata/devdb/blkerr01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2015/07/09 10:36:27

RMAN> recover datafile 7;

Starting recover at 2015/07/09 10:36:40
using channel ORA_DISK_1

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

Finished recover at 2015/07/09 10:36:41

此次修改破坏了文件的头部,发生了意外。(也可能是编辑datafile时,没有关闭数据库)我们先恢复数据文件。再次编辑文件。

此实验始终没有做成功,后续有时间再研究。

恢复的方法如下:

RMAN TARGET / 
BLOCKRECOVER DATAFILE 12 BLOCK 12;


您可能感兴趣的文档:

--结束END--

本文标题: Oracle 学习之RMAN(十三)恢复实战--数据块修复

本文链接: https://www.lsjlt.com/news/44729.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作