Table of Contents
3.模拟产生一个坏块:我这里使用了VI来删除数据文件中一些内容方法
4.进入RMAN,修复坏块
6.在SQLPLUS中查询表
Home Database Mysql Tutorial ORACLE模拟一个数据文件坏块并使用RMAN备份来恢复

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

Jun 07, 2016 pm 03:50 PM
oracle use data document simulation

1.创建一个实验用的表空间并在此表空间上创建表 create tablespace blocktest datafile '/u01/oradata/bys1/blocktest.dbf' size 1m; col name for a40 select file#,name from v$datafile; FILE# NAME ---------- ----------------------------------------


1.创建一个实验用的表空间并在此表空间上创建表

create tablespace blocktest datafile '/u01/oradata/bys1/blocktest.dbf' size 1m;

col name for a40
select file#,name from v$datafile;
     FILE# NAME
---------- ----------------------------------------
         1 /u01/oradata/bys1/system01.dbf
         2 /u01/oradata/bys1/sysaux01.dbf
         3 /u01/oradata/bys1/undotbs01.dbf
         4 /u01/oradata/bys1/users01.dbf
         5 /u01/oradata/bys1/example01.dbf
         6 /u01/oradata/bys1/blocktest.dbf

BYS@bys1>create table test9 tablespace blocktest as select * from scott.emp;
Table created.
BYS@bys1>select count(*) from test9;
  COUNT(*)
----------
      14

2.使用RMAN对数据库进行备份,这里为了快速实验我只备份了准备制造坏块的数据文件。

[oracle@bys001 ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 13 13:28:36 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: BYS1 (DBID=3957527513)

RMAN> backup datafile 6;

Starting backup at 13-SEP-13
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=00006 name=/u01/oradata/bys1/blocktest.dbf
channel ORA_DISK_1: starting piece 1 at 13-SEP-13
channel ORA_DISK_1: finished piece 1 at 13-SEP-13
piece handle=/u01/flash_recovery_area/BYS1/backupset/2013_09_13/o1_mf_nnndf_TAG20130913T150457_935g8s7w_.bkp tag=TAG20130913T150457 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-SEP-13

RMAN> list backupset 7;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    1.02M      DISK        00:00:00     13-SEP-13      
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130913T150457
        Piece Name: /u01/flash_recovery_area/BYS1/backupset/2013_09_13/o1_mf_nnndf_TAG20130913T150457_935g8s7w_.bkp
  List of Datafiles in backup set 7
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  6       Full 1910363    13-SEP-13 /u01/oradata/bys1/blocktest.dbf

3.模拟产生一个坏块:我这里使用了VI来删除数据文件中一些内容方法

[oracle@bys001 bys1]$ vi blocktest.dbf   打开后都是乱码,随便删除点中间的数据就可以,有时候 需要多次删除才会有坏块。我第一次实验一下就制造出坏块,后来都是通过多次才行。然后进入数据库查询建立在blocktest.表空间上的TEST9表,报错并给出了坏块的提示:文件号是6,坏块是10:

[oracle@bys001 bys1]$ sqlplus bys/bys
BYS@bys1>select * from test9;
select * from test9
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 10)
ORA-01110: data file 6: '/u01/oradata/bys1/blocktest.dbf'


4.进入RMAN,修复坏块

《《《可选:--我未做

RMAN> backup validate datafile 6;      这条命令是对文件做一次校验,也可以发现坏块。
然后从SQLPLUS中查询:select  * from  v$database_block_corruption;

直接使用RMAN指定恢复的文件及BLOCK号》》》

执行以下 命令来修复坏块:

RMAN> blockrecover datafile 6 block 10 from backupset;
RMAN> exit

6.在SQLPLUS中查询表

BYS@bys1>select count(*) from test9;
  COUNT(*)
----------
      14

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How long will Oracle database logs be kept? How long will Oracle database logs be kept? May 10, 2024 am 03:27 AM

How long will Oracle database logs be kept?

The order of the oracle database startup steps is The order of the oracle database startup steps is May 10, 2024 am 01:48 AM

The order of the oracle database startup steps is

Oracle database server hardware configuration requirements Oracle database server hardware configuration requirements May 10, 2024 am 04:00 AM

Oracle database server hardware configuration requirements

How to see the number of occurrences of a certain character in Oracle How to see the number of occurrences of a certain character in Oracle May 09, 2024 pm 09:33 PM

How to see the number of occurrences of a certain character in Oracle

How much memory does oracle require? How much memory does oracle require? May 10, 2024 am 04:12 AM

How much memory does oracle require?

How much memory is needed to use oracle database How much memory is needed to use oracle database May 10, 2024 am 03:42 AM

How much memory is needed to use oracle database

Oracle scheduled tasks execute the creation step once a day Oracle scheduled tasks execute the creation step once a day May 10, 2024 am 03:03 AM

Oracle scheduled tasks execute the creation step once a day

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI 70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI Jun 13, 2024 pm 03:47 PM

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI

See all articles