oracle 服务内存告警

来源:这里教程网 时间:2026-03-03 21:27:03 作者:

查看整体PGA\SGA使用情况 select name,total,round(total-free,2) used, round(free,2) free,round((total-free)/total*100,2) pctused from (select 'SGA' name,(select sum(value/1024/1024) from v$sga) total, (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 from ( select 'PGA' name,(select value/1024/1024 total from v$pgastat where name='aggregate PGA target parameter')total, (select value/1024/1024 used from v$pgastat where name='total PGA allocated')used from dual); 查看占用PGA进程 /*select pid,spid,substr(username,1,20) "USER" ,program,PGA_USED_MEM,PGA_ALLOC_MEM,PGA_FREEABLE_MEM,PGA_MAX_MEM from v$process  where pga_alloc_mem=(select max(pga_alloc_mem) from v$process where  program not like '%LGWR%');*/ select pid,spid,substr(username,1,20) "USER" ,program,PGA_USED_MEM,PGA_ALLOC_MEM,PGA_FREEABLE_MEM,PGA_MAX_MEM from v$process  where pga_alloc_mem=(select max(pga_alloc_mem) from v$process); OS层查看占用SWAP的进程 for file in /proc/*/status ; do awk '/VmSwap|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 3 -n -r | head -20 for file in /proc/*/status ; do awk '/VmSwap|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 3 -n -r | head -20 |grep -i oracle 查看具体的SQL(比较慢) select sql_text from v$sqlarea where address in  (select sql_address from v$session where paddr in (select addr from v$process where spid = 5789)); 查看服务器内存使用情况 free -g               total        used        free      shared  buff/cache   available Mem:            125          67           2          25          56          28 Swap:            63           1          62 zabbix监控memory,为物理内存,触发器90% swap 也有监控,此次swap长时间使用18gb,后系统卡死,数据库卡死。未出现swap不足。 1.      针对服务器设定OS限制参数(APM(岁修)时设定),确保数据库不会因为内存耗尽无法连线 2.      设定长时间占用(1小时)硬碟警报,确保第一时间响应 3.      设定监控找到问题SQL,针对问题SQL确认单点 or 惯犯,单点人工删除,惯犯于当日做出短解改正2日内完成长解改正  4. 增加内存 5. 盘点并清理数据看内数据保存过长或是无意义的数据 cat /etc/sysctl.conf vm.min_free_kbytes = 512000 vm.zone_reclaim_mode = 1 256GB设置为2GB: 2048000 vm.min_free_kbytes = 2048000 #vm.zone_reclaim_mode = 1 vm.min_free_kbytes 建议每32G内存分配1G vm.min_free_kbytes,单位是KB 推荐值:vm.min_free_kbytes = <内存值>*2% (上限5G) 推荐值:vm.zone_reclaim_mode = 1 (在内存分配不足,且内存需求较多,建议关闭,加速cache回收!) 对于线上128G的内存的机器,可以考虑将min设置为512M左右。因为,太大了,可能会导致内存的浪费;当然如果只有40G的物理机,更不要考虑把min设置超过1G了,这样会导致频繁的触发内存回收;具体优化也要根据业务来看 swap:https://www.sohu.com/a/797151090_374240https://www.modb.pro/db/1780155186081763328https://blog.51cto.com/u_11529070/9181060https://www.cnblogs.com/zphj1987/p/13639801.htmlhttps://mp.weixin.qq.com/s?__biz=MzI2NzM1OTM4OA==&mid=2247513326&idx=1&sn=3fbe7e57b1cfb839a15dfd2ec2fcaf4b&chksm=ebad86313a5c7f3b837c816c35922a218907146f3fa455c35db39946a049a752790638ad7576&scene=27

相关推荐