重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
文章参考:ORACLE 11g官方文档[Managing Memory]
创新互联客户idc服务中心,提供成都移动云计算中心、成都服务器、成都主机托管、成都双线服务器等业务的一站式服务。通过各地的服务中心,我们向成都用户提供优质廉价的产品以及开放、透明、稳定、高性价比的服务,资深网络工程师在机房提供7*24小时标准级技术保障。
前言:之前搭建数据库集群环境后,现场的维护人员不知何时改为了手动内存管理,且参数设置存在不合理,导致客户plsql执行报错,如下所示:
查看数据库日志,有如下提示:
Wed Mar 15 00:15:08 2017
Errors in file /app/oracle/diag/rdbms/resdb/resdb1/trace/resdb1_ora_12320832.trc (incident=441054):
ORA-04031: unable to allocate 56 bytes of shared memory ("streams pool","unknown object","streams pool","fixed allocation
callback")
Incident details in: /app/oracle/diag/rdbms/resdb/resdb1/incident/incdir_441054/resdb1_ora_12320832_i441054.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Wed Mar 15 16:11:30 2017
Errors in file /app/oracle/diag/rdbms/resdb/resdb1/trace/resdb1_ora_8126806.trc (incident=440838):
ORA-04031: ?·¨·??2 ????2Э?′?"shared pool","SELECT TRIGGER_NAME, TRIGGER...","SQLA","tmp")
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Errors in file /app/oracle/diag/rdbms/resdb/resdb1/trace/resdb1_m000_10879616.trc (incident=442639):
ORA-04031: unable to allocate 536 bytes of shared memory ("shared pool","select /*+ rule */ bucket, e...","SQLA^bbcee4f7"
,"qerixs : rixalo")
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Wed Mar 15 16:11:31 2017
Dumping diagnostic data in directory=[cdmp_20170315161131], requested by (instance=1, osid=10879616 (M000)), summary=[inc
ident=442638].
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Wed Mar 15 16:11:32 2017
Sweep [inc][442639]: completed
查看数据库内存参数设置,并未是自动内存管理,设置自动内存管理模式处理。
问题处理过程
内存管理:自动内存管理、手动内存管理
自动内存管理:oracle 11g后支持PGA和SGA的自动内存管理,只需设置实例的总内存大小,根据需要自动分配PGA和SGA大小;
手动内存管理:如果想要手动管理内存设置,这个就需要DBA根据环境需要进行适当设置了。
自动内存管理设置:只需修改初始化参数设置MEMORY_TARGET和可选参数设置MEMORY_MAX_TARGET
设置自动内存管理步骤:
1.以sysdba权限的用户登录数据库
查看当前数据库SGA_TARGET和PGA_AGGREGATE_TARGET的参数设置
SQL> show parameter sga_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_target big integer 0
SQL> show parameter pga_aggregate_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target big integer 160000M
执行如下SQL查询语句,确认实例启动时分配PGA的最大值
SQL> select value from v$pgastat where name='maximum PGA allocated';
VALUE
----------
4620300288
根据如下公式计算其参数值:
memory_target = sga_target + max(pga_aggregate_target, maximum PGA allocated)
2.初始化参数MEMORY_MAX_TARGET
首先查看当前数据库中MEMORY_MAX_TARGET参数
SQL> show parameter MEMORY_MAX_TARGET ;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 0
SQL> ALTER SYSTEM SET MEMORY_MAX_TARGET = 160000M SCOPE = SPFILE SID='*';
ALTER SYSTEM SET MEMORY_TARGET = 160000M SCOPE = SPFILE SID='*';
ALTER SYSTEM SET PGA_AGGREGATE_TARGET = 0 SCOPE = SPFILE SID='*';
3.重启数据库
4.自动内存管理监控
The dynamic performance view V$MEMORY_DYNAMIC_COMPONENTS
shows the current sizes of all dynamically tuned memory components, including the total sizes of the SGA and instance PGA.
SQL> select * from v$memory_target_advice order by memory_size;