其他分享
首页 > 其他分享> > ORA-4031诊断分析

ORA-4031诊断分析

作者:互联网

1.Environment
11.2.0.4 RAC

2.Symptoms
rac的一节点alert日志一直刷ORA-4031报错,提示shared pool不足,二节点并没有此报错

Sat Oct 09 09:53:30 2021
Errors in file /data1/app/oracle/diag/rdbms/orcl/orcl1/trace/orcl1_smon_7537104.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","update sys.mon_mods$ set ins...","sga heap(1,0)","kglsim object batch")
Errors in file /data1/app/oracle/diag/rdbms/orcl/orcl1/trace/orcl1_smon_7537104.trc:
ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","select ts#,file#,block#,cols...","sga heap(2,0)","kglsim object batch")

XXX:/data1/app/oracle$ 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 or Streams 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
// initialization parameters SHARED_POOL_RESERVED_SIZE and
// SHARED_POOL_SIZE.
// If the large pool is out of memory, increase the initialization
// parameter LARGE_POOL_SIZE.
// If the error is issued from an Oracle Streams or XStream process,
// increase the initialization parameter STREAMS_POOL_SIZE or increase
// the capture or apply parameter MAX_SGA_SIZE.
XXXX:/data1/app/oracle$

3.Changes
巡检时发现

4.Cause
sys@PES1DB2>show spparameter sga

SID NAME TYPE VALUE
-------- ----------------------------- ---------------------- ----------------------------
* lock_sga boolean
* pre_page_sga boolean
* sga_max_size big integer 3G
orcl1 sga_target big integer 1472M
* sga_target big integer 3G

两节点sga设置不一致,正常情况下,sga的设置所有节点生效,默认是*,此环境指定实例,指定实例的参数优先级更高,虽然*的设置为3G,但是实际上1G的参数生效。
规范的做法是删除指定实例的sga参数,需要重启。为了缩小影响,且sga_target参数为动态参数,故重新设置为3G即可。

5.Solution
ALTER SYSTEM SET sga_target='3G' SCOPE=BOTH SID='orcl1';

sys@PES1DB2>show spparameter sga

SID NAME TYPE VALUE
-------- ----------------------------- ---------------------- ----------------------------
* lock_sga boolean
* pre_page_sga boolean
* sga_max_size big integer 3G
orcl1 sga_target big integer 3G
* sga_target big integer 3G
sys@PES1DB2>

延续:主机收到告警
告警描述:#(系统+计算)内存使用率持续10分钟超过95%,内存使用中会发生换页空间切换,影响实际数据调用,可综合考虑是否扩容
告警时间:2021.10.09 11:21:12


---------
orcl1:/data1/app/oracle$ ps aux | head -1 ; ps aux | sort -rn +3 | head -10
查看确实是数据库相关的进程占用内存,进一步分析
8G主机内存,SGA 3G,PGA 1G,调整sga为2G,主机内存(nmon->m)从96%降为86%。

sys@PES1DB1>show parameter pga

NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
pga_aggregate_target big integer 1000M

sys@PES1DB1>show parameter process

NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
aq_tm_processes integer 1
cell_offload_processing boolean TRUE
db_writer_processes integer 4
gcs_server_processes integer 3
global_txn_processes integer 1
job_queue_processes integer 1000
log_archive_max_processes integer 4
processes integer 1000
processor_group_name string
sys@PES1DB1>show parameter session

NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
session_cached_cursors integer 50
session_max_open_files integer 10
sessions integer 1536
shared_server_sessions integer


6.References
Diagnosing and Resolving Error ORA-04031 on the Shared Pool or Other Memory Pools (Doc ID 146599.1)
参考中还有更加详细的解释和介绍。
http://blog.itpub.net/26736162/viewspace-2137064/

 

标签:target,big,memory,4031,诊断,integer,sga,shared,ORA
来源: https://www.cnblogs.com/annez/p/15386825.html