一次SYSAUX表空间的索引坏块处理

1.ALERT日志中显示有坏块,检查数据库,未开归档,无RMAN备份。
开始校验全库坏块情况:

使用RMAN命令校验:
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
RMAN> backup validate check logical database;
查看坏块校验结果:
SYS@test>select * from v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         2      70922          1                  0 ALL ZERO
         2      70959          1                  0 ALL ZERO

2.查看坏块对应的表空间及SEGMENT信息

SYS@test>select name from v$dbfile where file#=2;
NAME
--------------------------------------------
+DG_DATA/ipcc/datafile/sysaux.257.928776297

SELECT * FROM dba_extents WHERE file_id = 2
and 70922 between block_id AND block_id + blocks - 1;

OWNER
------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------
PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME
------------------------------ ------------------ ------------------------------
 EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
---------- ---------- ---------- ---------- ---------- ------------
SYS
WRH$_SQL_PLAN_PK
                               INDEX              SYSAUX
         6          2      70920      65536          8            2
         
SELECT * FROM dba_extents WHERE file_id = 2
and 70959 between block_id AND block_id + blocks - 1;

OWNER
------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------
PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME
------------------------------ ------------------ ------------------------------
 EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
---------- ---------- ---------- ---------- ---------- ------------
SYS
WRH$_SYSMETRIC_HISTORY_INDEX
                               INDEX              SYSAUX
         3          2      70952      65536          8            2

3.对于坏块处于索引类型,直接重建索引即可
参照:处理 Oracle7/8/8i/9i/10g/11g 中的 Oracle 块损坏 (文档 ID 1526911.1)文档中处理方法,
对索引需要用ONLINE,不会从旧索引段中构建新索引,可以从表中读取数据。
==其实删除索引,再重建也可以,可以提前用dbms_metadata.get_ddl获取创建索引语句。
ALTER INDEX "SYS"."WRH$_SYSMETRIC_HISTORY_INDEX" REBUILD ONLINE;
ALTER INDEX "SYS"."WRH$_SQL_PLAN_PK" REBUILD ONLINE; 
如果是分区索引则用:ALTER INDEX "用户名"."表名" REBUILD PARTITION "分区名";

ALTER INDEX "SYS"."WRH$_SYSMETRIC_HISTORY_INDEX" REBUILD ONLINE;
ALTER INDEX "SYS"."WRH$_SQL_PLAN_PK" REBUILD ONLINE; 
如果是分区索引则用:ALTER INDEX "用户名"."表名" REBUILD PARTITION "分区名";

SYS@test>SELECT dbms_metadata.get_ddl('INDEX', 'WRH$_SYSMETRIC_HISTORY_INDEX','SYS') FROM dual;  

DBMS_METADATA.GET_DDL('INDEX','WRH$_SYSMETRIC_HISTORY_INDEX','SYS')
--------------------------------------------------------------------------------

  CREATE INDEX "SYS"."WRH$_SYSMETRIC_HISTORY_INDEX" ON "SYS"."WRH$_SYSMETRIC_HISTORY" ("DBID", "SNAP_ID", "INSTANCE_NUMBER", "GROUP_ID", "METRIC_ID", "BEGIN_TIM
E") **
  TABLESPACE "SYSAUX"

4.重建索引后,检查坏块

RMAN> backup validate check logical datafile 2;
已经正常:
SYS@test>select * from v$database_block_corruption;

no rows selected

上一篇:python-- sys 模块


下一篇:Python常用模块