Durante a execução de um backup rman full o ambiente estava apresentando ORA-19566, que sinaliza a existência de bloco corrompido.
Consultando o alertlog é possível identificar o file_id e o numero do bloco do datafile que apresentou corrupção.
Hex dump of (file 83, block 1189949) in trace file /oracle/diag/rdbms/teste/teste/trace/teste_ora_44349.trc Corrupt block relative dba: 0x14d2283d (file 83, block 1189949) Fractured block found during backing up datafile Data in bad block: type: 6 format: 2 rdba: 0x14d2283d last change scn: 0x0008.99c1d8d5 seq: 0x1 flg: 0x06 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x08d60601 check value in block header: 0x688d computed block checksum: 0xd003 Reread of blocknum=1189949, file=/u02/oracle/oradata/teste/dbf/teste_index30.dbf. found same corrupt data
Executando um dbv no datafile que apresentou corrupção é possível confirmar que o mesmo possuí 2 blocos corrompidos
dbv file=/u02/oracle/oradata/teste/dbf/teste_index30.dbf DBVERIFY: Release 11.2.0.3.0 - Production on Thu Nov 14 14:35:17 2013 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u02/oracle/oradata/teste/dbf/teste_index30.dbf Page 1189949 is influx - most likely media corrupt Corrupt block relative dba: 0x14d2283d (file 83, block 1189949) Fractured block found during dbv: Data in bad block: type: 6 format: 2 rdba: 0x14d2283d last change scn: 0x0008.99c1d8d5 seq: 0x1 flg: 0x06 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x08d60601 check value in block header: 0x688d computed block checksum: 0xd003 Page 1189955 is influx - most likely media corrupt Corrupt block relative dba: 0x14d22843 (file 83, block 1189955) Fractured block found during dbv: Data in bad block: type: 6 format: 2 rdba: 0x14d22843 last change scn: 0x000e.d020f484 seq: 0x1 flg: 0x06 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x24870601 check value in block header: 0x23e computed block checksum: 0xd003 DBVERIFY - Verification complete Total Pages Examined : 1280000 Total Pages Processed (Data) : 1024 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 1274522 Total Pages Failing (Index): 0 Total Pages Processed (Other): 3606 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 846 Total Pages Marked Corrupt : 2 Total Pages Influx : 2 Total Pages Encrypted : 0 Highest block SCN : 1996079124 (16.1996079124)
Agora, irei verificar se o bloco que apresentou corrupção está sendo utilizado por algum objeto.
select segment_name, segment_type, owner</pre> from dba_extents where file_id = 83 and 1189949 between block_id and block_id + blocks -1; no rows selected
Tendo em vista que o bloco corrompido não está associado a nenhum objeto, estarei formatando o mesmo. O processo de formatação consiste basicamente em utilizar o bloco corrompido. Para isso, criarei uma tabela, alocando espaço apenas datafile com bloco corrompido e irei inserir dados até que o bloco seja utilizado
A tabela será criado abaixo do owner scott para realizar o processo. Essa tabela deverá ter como default tablespace, a tablespace que apresentou corrupção no datafile.
connect scott/tiger create table s ( n number, c varchar2(4000) ) nologging tablespace TESTE_INDEX;
Após criada a tabela, estarei alterando o pactfree da mesma para 95%, assim reduzirei a quantidade de inserções necessárias para alocar o bloco.
ALTER TABLE S PCTFREE 95
Também criarei uma trigger para que informe quando o bloco corrompido for preenchido. Deve ser colocado o file_id e o numero do bloco corrompido na trigger abaixo.
conn sys/senha CREATE OR REPLACE TRIGGER corrupt_trigger AFTER INSERT ON scott.s REFERENCING OLD AS p_old NEW AS new_p FOR EACH ROW DECLARE corrupt EXCEPTION; BEGIN IF (dbms_rowid.rowid_block_number(:new_p.rowid)=&blocknumber) and (dbms_rowid.rowid_relative_fno(:new_p.rowid)=&filenumber) THEN RAISE corrupt; END IF; EXCEPTION WHEN corrupt THEN RAISE_APPLICATION_ERROR(-20000, 'Corrupt block has been formatted'); END; /
Após criar a trigger, será alocado espaço para a tabela criada, no datafile afetado. Para isso será necessário identificar primeiro o extend size do datafile e depois alocar espaço na tabela.
Select BYTES from dba_free_space where file_id=<Absolute file number> and <corrupt block number> between block_id and block_id + blocks -1; BYTES ---------- 9437184
Alocar espaço no datafile afetado com o comando abaixo:
BEGIN for i in 1..1000000 loop EXECUTE IMMEDIATE 'alter table scott.s allocate extent (DATAFILE '||'''/u02/oracle/oradata/teste/dbf/teste_index30.dbf''' ||'SIZE 8K) '; end loop; end ; /
Agora serão inseridos dados na tabela até que o bloco corrompido seja preenchido.
Begin FOR i IN 1..1000000000 loop for j IN 1..1000 loop Insert into scott.s VALUES(i,'x'); end loop; commit; END LOOP; END; Begin * ERROR at line 1: ORA-20000: Corrupt block has been formatted ORA-06512: at "SYS.CORRUPT_TRIGGER", line 10 ORA-04088: error during execution of trigger 'SYS.CORRUPT_TRIGGER' ORA-06512: at line 4
Após a execução do processo, rodando um novo dbv é possível constatar que não existe mais corrupção.
dbv file=/u02/oracle/oradata/TASY/dbf/tasy_index30.dbf DBVERIFY: Release 11.2.0.3.0 - Production on Thu Nov 14 16:42:23 2013 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u02/oracle/oradata/TASY/dbf/tasy_index30.dbf DBVERIFY - Verification complete Total Pages Examined : 1280000 Total Pages Processed (Data) : 838227 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 436835 Total Pages Failing (Index): 0 Total Pages Processed (Other): 4092 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 846 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 2008040755 (16.2008040755)
Fonte: https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=66983570965143&id=336133.1&_afrWindowMode=0&_adf.ctrl-state=vmrpe4j2a_4
Autor: Jhonata Lamim
MBA em Banco de Dados Oracle, formado pelo Centro Universitário de Araraquara (UNIARA), graduado em Sistemas de Informação pelo Centro Universitário de Brusque (UNIFEBE).
Atua com Banco de Dados Oracle desde Junho de 2010. Atualmente é DBA Senior na Exímio Soluções em TI (www.eximioti.com.br)
Principais atividade:
Implementação, migração, gerenciamento e suporte a produtos Oracle (10g, 11g, 12c, RAC), multiplataforma;
Monitoramento de ambientes 24×7;
Backup e Recovery;
Performance e Tuning;
Alta disponibilidade (HA);
EM database/grid/cloud control 12c/13c;
Conversão de databases;
Standby database / Oracle Data Guard;
Migração de dados para Oracle;
Experiência:
DBA Oracle Teiko Soluções em TI – Jun/2010 – Abr/2018
DBA Oracle, Outsourcing – Marfrig Group – Set/2013 – Abr/2018
DBA Oracle, Outsourcing – Grupo Notre Dame – Intermédica – Mar/2017 – Abr/2018
DBA Oralce, Outsourcing – Hospital Beneficiência Portuguesa de São Paulo – Set/2015 – Abr/2018
DBA Oracle, Outsourcing – Fundação São Francisco Xavier – Set/2015 – Fev/2017
DBA Oracle, Outsourcing – Unimed Grande Florianopolis – Set/2014 – Jul/2016
DBA Oracle, Outsourcing – Hospital Moinhos de Vento – Set/2014 – Set/2015
DBA Oracle, Outsourcing – Santa Casa de Misericórdia de Porto Alegre – 2013
Certificações:
OCS 12C – Oracle Real Application Clusters 12c Certified Implementation Specialist
OCS 12C – Oracle Database 12c Certified Implementation Specialist
OCE 11G – Oracle Database 11g: Performance Tuning
OCA 11G – Oracle Certified Associate Administrator
OCP 11G/12C – Oracle Certified Professional Administrator
OCS 11G – Oracle Certified Specialist
OPNCS 11G – Oracle Partner Network Certified Specialist
OCS – Oracle Linux 6 Implementation Essentials
Linkedin: https://www.linkedin.com/in/jhonata-lamim-dba-oracle-61366484/