pdb的引入,大家共享一个实例,有时候需要弄清除到底谁的会话导致占用内存高呢?
以下几板斧,看个清楚。
-
set linesize 150
-
set pagesize 3000
-
set numwidth 15
-
-
col parameter format a30
-
col component format a28
-
column default_attr format a7
-
column owner format a15
-
column object_name format a15
-
column all_containers format a3
-
column container_name format a10
-
column con_id format 999
-
column pdb_name format a20
-
column memory format a25
-
column spid heading 'ospid' format a8
-
column pid heading 'orapid' format 999999
-
column sid heading 'sess id' format 99999
-
column serial# heading 'serial#' format 999999
-
column status heading 'status' format a8
-
column pga_alloc_mem heading 'pga alloc' format 999,999,999
-
column pga_used_mem heading 'pga used' format 999,999,999
-
column pga_max_mem heading 'pga max' format 999,999,999
-
column username heading 'oracleuser' format a12
-
column osuser heading 'os user' format a12
-
column program heading 'program' format a24
-
column mbytes heading 'mbytes' format 999,999,999
-
column name format a22
-
-
alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
-
--确认当前是否是cdb
-
select name, cdb, con_id from v$database;
-
--查询每个pdb状态
-
-
--查询大于20m内存的会话
-
rem v$sesstat pga memory over 20mb size
-
select name, con_id, open_mode, restricted, dbid, con_uid, guid from v$containers order by con_id;
-
-
break on spid skip 1
-
-
select p.spid, s.sid, p.con_id, substr(n.name,1,25) memory, round(s.value/1024/1024) as mbytes
-
from v$sesstat s, v$statname n, v$process p, v$session vs
-
where s.statistic# = n.statistic#
-
and n.name like '%pga memory%'
-
and s.sid=vs.sid
-
and vs.paddr=p.addr
-
and s.value > 20000000 /* --remove this line to view all process size */
-
order by spid,memory;
-
-
break on off
-
-- 某些进程最大占用内存
-
select pid, spid, con_id, substr(username,1,13) username, program, round(pga_used_mem/1024/1024) pga_used, round(pga_alloc_mem/1024/1024) pga_alloc, round(pga_freeable_mem/1024/1024) pga_freeable, round(pga_max_mem/1024/1024) pga_max
-
from v$process
-
where pga_alloc_mem = (select max(pga_alloc_mem)
-
from v$process
-
where program not like '%lgwr%');
-
--所有pga合计
-
select round(sum(pga_alloc_mem)/1024/1024) as "mbytes allocated", round(sum(pga_used_mem)/1024/1024) as "mbytes used"
-
from v$process;
-
--各pdb占用内存
-
compute sum of "mbytes allocated" on report
-
break on report
-
select con_id, round(sum(pga_alloc_mem)/1024/1024) as "mbytes allocated", round(sum(pga_used_mem)/1024/1024) as "mbytes used"
-
from v$process
-
group by con_id
-
order by con_id;
-
-
break on off
-
--合计当前内存
-
select round(sum(value)/1024/1024) as mbytes
-
from v$sesstat s, v$statname n
-
where n.statistic# = s.statistic#
-
and n.name = 'session pga memory';
-
--各pdb当前内存汇总
-
compute sum of mbytes on report
-
break on report
-
select con_id, round(sum(bytes)/1024/1024) as mbytes from (select p.con_id, s.value as bytes
-
from v$sesstat s, v$statname n, v$process p, v$session vs
-
where s.statistic# = n.statistic#
-
and n.name = 'session pga memory'
-
and s.sid=vs.sid
-
and vs.paddr=p.addr)
-
group by con_id
-
order by con_id;
-
-
break on off
-
--实例启动以来,最大pga分配
-
col name for a50
-
select name, round(value/1024/1024) as mbytes from v$pgastat
-
where name in ('maximum pga allocated','aggregate pga target parameter','aggregate pga auto target');
-
-- pga分配历史最高前10
-
-
select * from (select name,snap_id, round(value/1024/1024) mbytes from cdb_hist_pgastat
-
where name='maximum pga allocated'
-
order by mbytes desc,snap_id desc)
-
where rownum <11;
-
--查看当前各今晨分配内存情况
-
break on con_id skip 4
-
compute sum of pga_alloc_mem on con_id
-
select p.con_id,
-
p.spid,
-
p.pid,
-
s.sid,
-
s.serial#,
-
s.status,
-
round(p.pga_alloc_mem/1024/1024) as pga_alloc_mem,
-
round(p.pga_used_mem/1024/1024) as pga_used_mem,
-
round(p.pga_max_mem/1024/1024) as pga_max_mem,
-
s.username,
-
s.osuser,
-
s.program
-
from v$process p, v$session s
-
where s.paddr( ) = p.addr
-
--and p.background is null /* remove prevent listing background processes */
-
order by con_id,pga_alloc_mem;
-
-
break on off
-
-- sga pga设置
-
-
select con_id, name as parameter, value/1024/1024 as mbytes from v$parameter
-
where name in ('pga_aggregate_target','memory_target','memory_max_target','sga_max_size','sga_target','pga_aggregate_limit')
-
order by name;
-
--显示动态组件的当前值
-
select con_id, component, round(user_specified_size/1024/1024) as mbytes, oper_count, last_oper_time as "last op time", round(current_size/1024/1024) as mbytes from v$memory_dynamic_components
-
order by component;
-
--通过数据库视图显示 sga 内存使用情况
-
select name, round(bytes/1024/1024) as mbytes from v$sgainfo;
-
-显示可用来扩展 sga_target 的可用空闲 sga 内存
-
select round(current_size/1024/1024) mbytes from v$sga_dynamic_free_memory;
-
--只显示超过 10m 的内存分配
-
break on con_id skip 4
-
select con_id, pool, name, round(bytes/1024/1024,1) as mbytes from v$sgastat
-
where bytes/1024/1024 > 10 --alter to see smaller/larger allocations
-
order by con_id;
-
break on off
参考:
在可插拔数据库上如何监控进程内存的使用 (doc id 1985042.1)
如何监控可插拔数据库(pdb)的 sga 内存使用情况 (doc id 2248684.1)
阅读(1158) | 评论(0) | 转发(0) |