---
title: "数据库用户不能登录 alert日志报ORA-04031故障分析处理"
author: "剑雨123"
date: "2014-06-16T10:31:47Z"
tags: []
categories: ["数据库"]
slug: "alert-ora-04031"
draft: false
lastmod: "2014-06-16T10:31:47Z"
id: 2080468
url: "https://cuug789.iteye.com/blog/2080468"
---

![](http://dl2.iteye.com/upload/attachment/0098/1392/fddfbdd6-e134-3fea-969d-557e515df3c9.jpg)
现象：
1、在数据库主机sqlplus  / as sysdba都进不去。
 
2、alert日志中报错如下：
 Errors in file /Oracle/admin/dbrac/bdump/dbrac2_q000_1329.trc:
 ORA-22303: type "SYS"."AQ$_HISTORY" not found
 ORA-00604: error occurred at recursive SQL level 1
 ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select user#,type# from user...","sql area","tmp")
 
原因如下：
 1、由于不能在share pool中分配内存导致不能登录
 2、导致share pool不能分配内存的原因是数据库大量使用常量SQL(未使用绑定变量SQL)硬解析导致。
 
此时数据库sqlplus / as sysdba都进不去，怎么办？
 
解决办法：
 1、基于快速恢复数据库原则，首先将pmon进程予以kill，重新拉起数据库
 
2、目前为减少该故障发生的概率，方法如下：
 在自动计划中加入自动刷数据库share pool计划，每天晚上1点刷一次，该操作对业务影响可以忽略，刷share pool的SQL如下：
 alter system flush shared_pool; 
  
 3、为了彻底解决该问题，需应用方将常量SQL(未使用绑定变量SQL)全部修改成使用绑定变量SQL。