oracle 記憶體監控

2024-03-04 工作雜記 Oracle 系統調校

透過 v$sgastatv$pgastat 檢測 SGA PGA 空間使用狀況

select name,used,free, pctused, max_allocated , sysdate opdt from (
select name,total,round(total-free,2) used, round(free,2) free,round((total-free)/total*100,2) pctused, round(MAX_ALLOCATED,2) MAX_ALLOCATED from
(
select 'SGA' name,(select sum(value/1024/1024) from v$sga) total,
(SELECT SUM (bytes/1024/1024)  FROM V$SGAINFO WHERE NAME='Maximum SGA Size') MAX_ALLOCATED ,
(select sum(bytes/1024/1024) from v$sgastat where name='free memory')free 
from dual
)
union
select name,total,round(used,2)used,round(total-used,2)free,round(used/total*100,2) pctused,round(MAX_ALLOCATED,2)   from (
select 'PGA' name,(select value/1024/1024 total from v$pgastat where name='aggregate PGA target parameter')total,
(SELECT (value/1024/1024)  FROM V$PGASTAT WHERE NAME = 'maximum PGA allocated') MAX_ALLOCATED,
(select value/1024/1024 used from v$pgastat where name='total PGA allocated')used 
from dual
)
);
sqlplus / as sysdba << EOF
@/home/oracle/check-health-script/check-memory.sql
exit
EOF

awrrpt

sqlplus / as sysdba << EOF
@/u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/awrrpt.sql
exit
EOF

參考資料

Database Reference-8.121 V$PGASTAT