坏块分为物理坏块和逻辑坏块,前者是硬件问题产生,后者是oracle内部数据有问题,本次实验针对后者。
给数据库开启归档模式
[oracle@cancer ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 15 17:09:40 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> archive log lst
SP2-0718: illegal ARCHIVE LOG option
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Current log sequence 6
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 515903032 bytes
Database Buffers 264241152 bytes
Redo Buffers 2596864 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
1.创建实验所需的表空间、用户、表和相关实验数据
1.1创建相关表空间和用户
--创建一个大小为1m的表空间
create tablespace test
datafile '/u01/oracle/oradata/orcl/test01.dbf' size 1m;
--创建test用户
create user test identified by test default tablespace test temporary tablespace temp profile DEFAULT;
--授予相关的测试权限
grant connect,dba,resource,unlimited tablespace to test;
1.2创建表和模拟数据
SQL> create table test tablespace test as select * from scott.emp;
Table created.
SQL> insert into test select * from test;
14 rows created.
SQL> insert into test select * from test;
28 rows created.
.....
3584 rows created.
SQL> insert into test select * from test;
7168 rows created.
SQL> commit;
Commit complete.
SQL> insert into test select * from test;
insert into test select * from test
*
ERROR at line 1:
ORA-01653: unable to extend table TEST.TEST by 8 in tablespace TEST
SQL> select count(*) from test;
COUNT(*)
----------
14336
给表增加索引
SQL> create index idx_test on test(ename);
Index created
切换检查点,将数据写入数据文件
SQL> alter system checkpoint;
System altered.
2.破坏前先用rman备份表空间,得到可以修复的备份
[oracle@cancer ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 15 18:0