ORA-04031错误导致宕机案例分析
今天遇到一起ORACLE数据库宕机案例,下面是对这起数据库宕机案例的原因进行分析、解读。分析过程中顺便记录一下这个案例的前因后果,攒点经验值,培养一下分析、解决问题的能力。
案例环境:
操作系统 :Oracle Linux Server release 5.7 64 bit
数据库版本:Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
案例分析:
收到告警去检查数据库时,发现实例已经宕机。检查告警日志,发现下面错误信息:
- ORA-00604: error occurred at recursive SQL level 1
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select count(*) from sys.job...","sql area","tmp")
- Mon Nov 2 11:43:00 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_cjq0_6571.trc:
- ORA-00604: error occurred at recursive SQL level 1
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select job, nvl2(last_date, ...","sql area","tmp")
- Mon Nov 2 11:43:00 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_cjq0_6571.trc:
- ORA-00604: error occurred at recursive SQL level 1
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select count(*) from sys.job...","sql area","tmp")
- Mon Nov 2 11:43:05 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_cjq0_6571.trc:
- ORA-00604: error occurred at recursive SQL level 1
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select job, nvl2(last_date, ...","sql area","tmp")
- Mon Nov 2 11:43:05 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_cjq0_6571.trc:
- ORA-00604: error occurred at recursive SQL level 1
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select count(*) from sys.job...","sql area","tmp")
- Mon Nov 2 11:43:08 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_reco_6569.trc:
- ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select host,userid,password,...","sql area","tmp")
- Mon Nov 2 11:43:08 2015
- RECO: terminating instance due to error 4031
- Mon Nov 2 11:43:08 2015
- Errors in file /u01/app/oracle/admin/SCM2/bdump/scm2_pmon_6555.trc:
- ORA-04031: unable to allocate bytes of shared memory ("","","","")
- Instance terminated by RECO, pid = 6569
从告警日志我们可以看到ORA-00604与ORA-04031错误导致了这次宕机事故(RECO: terminating instance due to error 4031):
$ oerr ora 4031
04031, 00000, "unable to allocate %s bytes of shared memory (\"%s\",\"%s\",\"%s\",\"%s\")"
// *Cause: More shared memory is needed than was allocated in the shared
// pool.
// *Action: If the shared pool is out of memory, either use the
// dbms_shared_pool package to pin large packages,
// reduce your use of shared memory, or increase the amount of
// available shared memory by increasing the value of the
// INIT.ORA parameters "shared_pool_reserved_size" and
// "shared_pool_size".
// If the large pool is out of memory, increase the INIT.ORA
// parameter "large_pool_size".
一般出现ORA-04031错误可能由两个原因引起:
1:内存中存在大量碎片,导致在分配内存的时候,没有连续的内存可存放,此问题一般是需要在开发的角度上入手,比如增加绑定变量,减少硬解析来改善和避免;
2.内存容量不足,需要扩大内存。
这台机器分配的物理内存为8G,结果检查发现SGA只分配了1168M,不到2G,瞬时碉堡了。此时真是很无语。ASH Report分析宕机前后的Buffer Cache和Shared Pool大小如下所示。
查看跟踪文件,可以看到SGA: allocation forcing component growth等待事件,可以确认的是由于SGA无法增长导致,也就是SGA被撑爆了,结合ASH Report我们可以看到当时Shared Pool的大小已经接近SGA的69.6%大小。
- SO: 0xa617d9c0, type: 4, owner: 0xa8a26c68, flag: INIT/-/-/0x00
- (session) sid: 932 trans: (nil), creator: 0xa8a26c68, flag: (51) USR/- BSY/-/-/-/-/-
- DID: 0001-000A-00000003, short-term DID: 0000-0000-00000000
- txn branch: (nil)
- oct: 0, prv: 0, sql: (nil), psql: (nil), user: 0/SYS
- last wait for 'SGA: allocation forcing component growth' blocking sess=0x(nil) seq=51324 wait_time=10714 seconds since wait started=0
- =0, =0, =0
- Dumping Session Wait History
- for 'SGA: allocation forcing component growth' count=1 wait_time=10714
- =0, =0, =0
- for 'SGA: allocation forcing component growth' count=1 wait_time=10512
- =0, =0, =0
- for 'latch: shared pool' count=1 wait_time=892
- address=600e7320, number=d6, tries=0
- for 'latch: shared pool' count=1 wait_time=28
- address=600e7320, number=d6, tries=0
- for 'latch: shared pool' count=1 wait_time=51
- address=600e7320, number=d6, tries=0
- for 'latch: shared pool' count=1 wait_time=114
- address=600e7320, number=d6, tries=0
- for 'latch: shared pool' count=1 wait_time=120
- address=600e7320, number=d6, tries=0
- for 'latch: library cache' count=1 wait_time=33
- address=a3fa46e8, number=d7, tries=1
结合上面的一些分析,可以断定SGA的不合理设置导致shared pool的内存被全部耗尽,SGA被撑爆了。于是调整SGA的参数才是解决问题的正确对策。另外考虑到这个数据库也正常运行了较长一段时间,也分析了一下awr、addm报告,发现系统的硬解析相当严重。另外通过下面脚本观察了一段时间shared pool的变化,发现其收缩、增长较频繁。
- SELECT start_time,
- component,
- oper_type,
- oper_mode,
- initial_size / 1024 / 1024 "INITIAL",
- final_size / 1024 / 1024 "FINAL",
- end_time
- FROM v$sga_resize_ops
- WHERE component IN ( 'DEFAULT buffer cache', 'shared pool' )
- AND status = 'COMPLETE'
- ORDER BY start_time,
- component;
这个可以通过设置数据库参数SHARED_POOL_SIZE,保证SHARED_POOL_SIZE大小不会由于内存紧张而低于这个大小,另外可以设置SGA resize的时间间隔
- ALTER SYSTEM SET “_memory_broker_stat_interval”=n SCOPE=SPFILE;
问题虽然解决了,但是真正需要反思的是为什么这个SGA_MAX_SIZE设置为1168M大小的事情!而且没有在巡检当中被发现。
参考资料:
http://blog.csdn.net/wenzhongyan/article/details/29866845
http://blog.chinaunix.net/uid-20802110-id-4188357.html
ORA-04031错误导致宕机案例分析的更多相关文章
- Linux服务器宕机案例一则
案例环境 操作系统 :Oracle Linux Server release 5.7 64bit 虚拟机 硬件配置 : 物理机型号为DELL R720 资源配置 :RAM 8G Intel(R) Xe ...
- Solr4.8.0源码分析(26)之Recovery失败造成的宕机原因分析
最近在公司做SolrCloud的容灾测试,刚好碰到了一个比较蛋疼的问题,跟SolrCloud的Recovery和leader选举有关,正好拿出来分析下. 现象是这样的:比如我有一台3个shard的So ...
- Centos7.5调试/etc/sysctl.conf文件导致宕机
今天安装greenplus数据库,需要调试一个核心文件/etc/sysctl.conf文件,结果导致系统异常宕机,出现的问题就是使用任何命令都不能输出正确的结果,只有这个显示: 不知道是什么原因,ls ...
- Hadoop 服务SYS CPU过高导致宕机问题
最近某hadoop集群多次出现机器宕机,现象为瞬间机器的sys cpu增长至100%,机器无法登录.只能硬件重启,ganglia cpu信息如下: 首先怀疑有用户启动了比较奇葩的job,导致不合理的系 ...
- rac库grid目录权限(6751)导致数据库宕机案例 此方法仅用于紧急救助
问题: 我的rac环境不小心通过chown命令改变了/u01目录及其子目录的权限,导致rac节点2数据库宕掉,sqlplus下打开数据库报错如下: [oracle@node2 ~]$ sqlplus ...
- MySQL Bug导致异常宕机的分析流程
原文链接:http://click.aliyun.com/m/42521/ 摘要: 本文主要通过一个bug来记录一下如何分析一个MySQL bug的崩溃信息. 版本:Percona 5.7.17-11 ...
- Linux服务器宕机案例第二则
邮件告警发现海外工厂一Linux服务器连接不上,DPA(Database Performance Analyzer)系统也发现其出现问题,ping这台服务器发现网络不通,联系不到当地系统管理员,邮件咨 ...
- pt-osc改表导致数据不一致案例分析
2016-06-10 李丹 dba流浪猫 我们平时除了解决自己问题外,有时候也会协助圈内人士,进行一些故障排查,此案例就是帮某公司DBA进行的故障分析,因为比较典型,特分享一下,但仅仅是分享发生的过程 ...
- AZURE云上 mkfs.ext4 /dev/sdc 导致宕机问题解决纪实
)开机启动挂载配置 [root@pldb2 ~]# vim /etc/fstab You have new mail in /var/spool/mail/root [root@pldb2 ~]# m ...
随机推荐
- jquery分隔Url的param方法
最近需要分隔url的querystring,用到了特意记录一下.方法: //获取url中的paramsvar search = location.search.substring(1);//param ...
- 【Java每日一题】20161124
package Nov2016; public class Ques1124 { public static void main(String[] args) { Parent p = new Sub ...
- 第 11 章 进度条媒体对象和 Well 组件
学习要点: 1.Well 组件 2.进度条组件 3.媒体对象组件 主讲教师:李炎恢 本节课我们主要学习一下 Bootstrap 的三个组件功能:Well 组件.进度条组件.媒体对象组件. 一.Well ...
- HDU 1131 Count the Trees 大数计算
题目是说给出一个数字,然后以1到这个数为序号当做二叉树的结点,问总共有几种组成二叉树的方式.这个题就是用卡特兰数算出个数,然后因为有编号,不同的编号对应不同的方式,所以结果是卡特兰数乘这个数的阶乘种方 ...
- 【Effective Java】6、使用复合优先于使用继承
这个,不管是什么书都会这样说,因为常常我们并不需要继承,而只是想把类进行一定的扩展,而我们想扩展的属性或方法对应的类都有,这个时候如果两者是is a的关系,这种关系是确实存在的,那么就可以使用继承,不 ...
- Node.JS文件系统解析
1.Node.js 文件系统 var fs = require("fs") 2.异步和同步 读取文件内容的函数有异步的 fs.readFile() 和同步的 fs.readFile ...
- 在 Windows 上遇到非常多 TIME_WAIT 連線時應如何處理
我們公司所代管的網站裡,有幾個流量是非常大的,在尖峰的時刻同時上線人數可能高達數千到數萬人,而在這個時候如果使用 netstat 或 TCPView 查看所有 TCP 連線時就會看到非常多處於 ...
- flex的用途
一.可以利用flex来布局一个div在另一个div里面水平垂直居中 如:html代码: <div class="container"> <div class=&q ...
- 带给你灵感:30个超棒的 SVG 动画展示【上篇】
前端开发人员和设计师一般使用 CSS 来创建 HTML 元素动画.然而,由于 HTML 在创建图案,形状,和其他方面的局限性,它们自然的转向了 SVG,它提供了更多更有趣的能力.借助SVG,我们有更多 ...
- 使用js实现带有停顿效果的图片滚动(按钮控制)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...