Recriando o repositório do AWR manualmente
Autor: ORACLE Place | Publicado: 2013-11-18T16:50:00-08:00



O
repositório do AWR (Automatic Workload Repository) é gerado automaticamente durante
a criação do banco de dados, porém algumas vezes o DBA pode ter a necessidade
de recriá-lo, neste artigo a demonstraremos os passos necessários.

&nbsp;

<!--[if !supportLists]-->1.&nbsp;&nbsp; <!--[endif]-->Conectar-se
no SQL*Plus

&nbsp;

$ sqlplus / as sysdba

&nbsp;

SQL*Plus: Release 11.2.0.1.0
Production on Mon Nov 4 10:43:53 2013

Copyright (c) 1982, 2009,
Oracle.&nbsp; All rights reserved.

Connected to:

Oracle Database 11g Enterprise
Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real
Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application
Testing options

&nbsp;

SQL&gt;

&nbsp;

<!--[if !supportLists]-->2.&nbsp;&nbsp; <!--[endif]-->Verificar
os seguintes parâmetros (cluster_database, statistics_level, sga_target),

&nbsp;

SQL&gt; show parameter cluster_database;



NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE

------------------------------------ -----------
------------------------------

cluster_database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
boolean&nbsp;&nbsp;&nbsp;&nbsp; TRUE

cluster_database_instances &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;integer&nbsp;&nbsp;&nbsp;&nbsp; 2



SQL&gt; show parameter statistics_level



NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE

------------------------------------ -----------
------------------------------

statistics_level&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPICAL 



SQL&gt; show parameter sga_target



NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALUE

------------------------------------
----------- ------------------------------

sga_target&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; big integer 8000M 





Importante: Caso os valores sejam diferentes dos apresentados
acima, deve-se alterar para os valores propostos para que o AWR funcione
corretamente.



<!--[if !supportLists]-->3.&nbsp;&nbsp;
<!--[endif]-->“Restartar”
o banco de dados em modo restrito.



SQL&gt; shutdown immediate;



Database closed.

Database dismounted.

ORACLE instance shutdown.



SQL&gt; startup restrict;



ORACLE instance started.



<!--[if !supportLists]-->4.&nbsp;&nbsp;
<!--[endif]-->Para
remover o catálogo do AWR executar o script abaixo:



SQL&gt; @$ORACLE_HOME/rdbms/admin/catnoawr.sql



<!--[if !supportLists]-->5.&nbsp;&nbsp;
<!--[endif]-->Para
recriar o catálogo do AWR executar.



SQL&gt; alter system flush shared_pool;



System altered.



SQL&gt; @$ORACLE_HOME/rdbms/admin/catawrtb.sql

SQL&gt; @$ORACLE_HOME/rdbms/admin/utlrp.sql

SQL&gt; @$ORACLE_HOME/rdbms/admin/execsvrm.sql



<!--[if !supportLists]-->6.&nbsp;&nbsp;
<!--[endif]-->“Restartar”
o banco de dados.



SQL&gt; shutdown immediate;



Database closed.

Database dismounted.

ORACLE instance shutdown.



SQL&gt; startup;



ORACLE instance started.



<!--[if !supportLists]-->7.&nbsp;&nbsp;
<!--[endif]-->Verificar
objetos inválidos no banco de dados, caso você encontre deve-se recompilar os
objetos.



SQL&gt; @$ORACLE_HOME/rdbms/admin/utlrp.sql



<!--[if !supportLists]-->8.&nbsp;&nbsp;
<!--[endif]-->Verificar
os “status” dos componentes do banco de dados, executar a consulta abaixo:



SQL&gt; SET PAGESIZE 500

SQL&gt; SET LINESIZE 100

SQL&gt; SELECT
SUBSTR(COMP_NAME,1,40) COMP_NAME, STATUS, SUBSTR(VERSION,1,10) VERSION

&nbsp;FROM DBA_REGISTRY

ORDER BY COMP_NAME;



COMP_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STATUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VERSION

----------------------------------------
----------- ----------

JServer JAVA Virtual
Machine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Database Catalog
Views&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Database Java
Packages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Database Packages
and Types&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Enterprise
Manager&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Expression
Filter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Real Application
Clusters&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VALID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.2.0.1.0

Oracle Rules Manager&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;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;ORDER BY OWNER, OBJECT_TYPE;



no rows selected&nbsp;



SQL&gt; SELECT OWNER,OBJECT_TYPE,COUNT(*)


&nbsp; FROM DBA_OBJECTS 

&nbsp;WHERE STATUS='INVALID' 

&nbsp;GROUP BY OWNER,OBJECT_TYPE 

&nbsp;ORDER BY OWNER,OBJECT_TYPE;



no rows selected



Importante: Caso algum componente ou objeto esteja inválido no
banco de dados, deve-se providenciar a validação para o funcionamento adequado
do AWR.



<!--[if !supportLists]-->9.&nbsp;&nbsp; <!--[endif]-->Gerar o primeiro “snapshot” no AWR, usar:



SQL&gt; exec
dbms_workload_repository.create_snapshot;



PL/SQL procedure successfully
completed.



Com o
primeiro “snapshot” as tabelas do AWR irão armazenar as estatísticas do banco
de dados.



<!--[if !supportLists]-->10. <!--[endif]-->Verificar a
periodicidade de atualização do AWR, executar a consulta abaixo:



SQL&gt; SET
LINES 200

SQL&gt; COL
SNAP_INTERVAL FOR A20

SQL&gt; COL
RETENTION &nbsp;&nbsp;&nbsp;&nbsp;FOR A20

SQL&gt;

SQL&gt;
SELECT * FROM DBA_HIST_WR_CONTROL;



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBID SNAP_INTERVAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETENTION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TOPNSQL

----------
-------------------- -------------------- ----------

9999000001 +00000 01:00:00.0&nbsp;&nbsp;&nbsp; +00020 00:00:00.0&nbsp;&nbsp;&nbsp; DEFAULT



O resultado da consulta mostra que
o AWR será executado em intervalos de uma hora e a retenção dos dados é de
vinte dias (em vermelho).





Referências: Oracle®
Database Performance Tuning Guide 11gR2 (11.2)

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Oracle®
Database Concepts 11gR2 (11.2)









MSc.
Rubens Oliveira

DBA Oracle Consultor

olivert.dba@consultant.com