问题描述:
查看bdump目录下alter
***
Corrupt block relative dba: ……
Bad check value found during backing up datafile
Data in bad block -
type: 6 format: 2 rdba: ……
last change scn: ….. seq: … flg: …
consistency value in tail: ……
check value in block header: ……, computed block checksum: ……
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
Reread of blocknum=……, file=……. found same corrupt data
……
Errors in file .trc:
ORA-27037: unable to obtain file status
Linux-ia64 Error: 2: No such file or directory
Additional information: 4
其中,file和block参数说明了坏块存在的位置。这里采用移植索引的办法处理,新建表空间,将原表空间下所有的索引,重建到新的表空间中。
执行步骤
1. 建立新的表空间,参考:
CREATE TABLESPACE DATAFILE
' extent management local uniform. size 1M segment space management auto;
ALTER TABLESPACE
ALTER DATABASE DATAFILE ' |
2. 重建原表空间中的索引;
1) 生成执行脚本
对于索引:user_indexes包含所有索引信息,使用如下语句重建:
alter index
| select 'alter index '||index_name||' rebuild tablespace from dba_indexes where tablespace_name = ' order by table_name,num_rows desc; |
对于分区索引:user_ind_partitions包含所有分区索引信息,使用如下语句重建:
alter index
2) 执行
执行 sqlplus
执行之后,查看rebuild_index.log,对于busy,未重建成功的索引,重新执行rebuild语句,直到提示“Index altered”,完成重建。
3. 分析重建索引
也可以在上一步中,增加compute statistics子句,但是这样可能会造成执行计划的改变;
1) 生成执行脚本
对于索引,语法:analyze index
| select 'analyze
index '||index_name||' compute statistics;' from user_indexes where tablespace_name = ' |
对于分区索引,语法:analyze index
按照上面的语法,建立分析脚本。
2) 执行
同样存成脚本文件,使用sqlplus
查看re_analyze.log日志文件。
4. 将索引改为归档模式
1) 生成执行脚本
对于索引,语法: alter index
| select 'alter index '||index_name||' logging;' from user_indexes where logging = 'NO'; |
对于分区索引,语法:alter index
| select 'alter
index '||index_name||' MODIFY partition '||partition_name||' logging;' from user_ind_partitions where logging = 'NO'; |
2) 执行
sqlplus
删除原表空间
执行下面脚本,判断原表空间是否还在使用:
select * from dba_extents where
tablespace_name = '
若返回为空行,则删除表空间:
drop tablespace
在操作系统下删除文件:
rm
对于某些主键索引的列宽超过3215,需要停掉应用,重新建立。
步骤如下:
1. 停掉应用;
执行ps fax |grep LOCAL=NO 查看没有外部应用;
2. 备份建立索引的脚本;
3. 删除该主键及其索引
4. 修改脚本中tablespace 子句的值,指定新表空间;
5. 对新建的索引进行分析;
6. 重建成功,重启应用;
本次操作的脚本包括:
Ø 建立表空间,及其执行日志:
create_tableSpace.log
create_tableSpace.sql
Ø 生成DDL脚本
generate_script_RebuiltIndex.sql
generate_script_Analyze.sql
generate_script_Log.sql
Ø 用于执行的DDL脚本
exe_rebuild_index.sql
exe_analyze.sql
exe_logging.sql
Ø 执行结果日志
rebuild_index.log
analyze.log
logging.log
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4248/viewspace-624827/ ,如需转载,请注明出处,否则将追究法律责任。