签到成功

知道了

CNDBA社区CNDBA社区

Oracle 12c 新参数 PGA_AGGREGATE_LIMIT 限制 PGA 内存总大小

2017-06-06 20:57 10463 0 原创 Oracle 18c
作者: dave

1 PGA_AGGREGATE_TARGET 参数
首先看下一下官网对PGA的描述:
The Program Global Area (PGA) is a private memory region that contains the data and control information for a server process. Only a server process can access the PGA. Oracle Database reads and writes information in the PGA on behalf of the server process. An example of such information is the run-time area of a cursor. Each time a cursor is executed, a new run-time area is created for that cursor in the PGA memory region of the server process executing that cursor.

Note:
Part of the run-time area can be located in the Shared Global Area (SGA) when using shared servers.

For complex queries (such as decision support queries), a big portion of the run-time area is dedicated to work areas allocated by memory intensive operators, including:
1)	Sort-based operators, such as ORDER BY, GROUP BY, ROLLUP, and window functions
2)	Hash-join
3)	Bitmap merge
4)	Bitmap create
5)	Write buffers used by bulk load operations

A sort operator uses a work area (the sort area) to perform the in-memory sorting of a set of rows. Similarly, a hash-join operator uses a work area (the hash area) to build a hash table from its left input.

在Oracle 10g和11g版本中,在AMM的管理下,可以通过配置PGA_AGGREGATE_TARGET参数来限制PGA的大小。 在自动化 PGA 内存管理模式下,Oracle 数据库通过动态控制分配工作区的 PGA 内存数量来尝试遵从PGA_AGGREGATE_TARGET值。
但有时因为某些原因,PGA 的使用量可能会超过 PGA_AGGREGATE_TARGET设置。

比如这个案例:
一次AIX系统swap使用过高的故障解决过程

因此PGA_AGGREGATE_TARGET起到的是目标的作用,而非限制。PGA_AGGREGATE_TARGET仅控制可优化部分内存的分配。
如果出现PGA的使用量大大超过PGA_AGGREGATE_TARGET参数的值,就可能产生SWAP,从而影响整个系统的性能,更进一步导致DB hang 住。 

因此在Oracle 12c中引入了新的参数PGA_AGGREGATE_LIMIT ,其可以限制整体PGA使用量。

PGA_AGGREGATE_TARGET

PGA_AGGREGATE_LIMIT


2 PGA_AGGREGATE_LIMIT参数
PGA_AGGREGATE_LIMIT限制的是实例消耗的 PGA的总量。是一个硬性限制。

PGA_AGGREGATE_LIMIT 参数是动态参数;修改该参数不需要重新实例。设置 PGA_AGGREGATE_LIMIT 的值时也不需要关心是否使用了自动内存管理。

该参数的默认值配置规则如下:
1) 如果设置了MEMORY_TARGET参数 ,那么PGA_AGGREGATE_LIMIT等于MEMORY_MAX_TARGET的值。
2) 如果没有设置MEMORY_TARGET参数,那么PGA_AGGREGATE_LIMIT 参数值是PGA_AGGREGATE_TARGET的2倍。
3) 如果MEMORY_TARGET参数没有设置,但PGA_AGGREGATE_TARGET参数被设置为0. 那么PGA_AGGREGATE_LIMIT值=90%* 物理内存 - SGA内存。

在所有的情况下,PGA_AGGREGATE_LIMIT参数值至少为2G,或者 3MB * PROCESSES参数值

如果PGA的使用量超过了 PGA_AGGREGATE_LIMIT 值,那么Oracle 按照以下顺序,中断使用了最多的不可优化 PGA 内存的会话或进程:
1) 中断使用最多不可优化 PGA 内存的会话调用(Calls)。
2) 如果 PGA 内存使用量仍超过 PGA_AGGREGATE_LIMIT,则终止使用最多不可优化 PGA 内存的会话(sessions)和进程(processes)。

注意:
1)这2个是不同的,一个是call,另一个是session和process。
2)在决定终止会话和进程时,并行查询将作为一个单元进行处理。。

除了Job 队列进程外的SYS 进程和后台进程不会受到限制的影响。相反,如果它们使用了最多的不可优化内存,则会定期将其 PGA 使用信息的摘要写入到跟踪文件中。

后台进程CKPT每三秒检查一次内存用量是否超过了 PGA_AGGREGATE_LIMIT 初始化参数的值。如果达到或超过了限制,则此进程中断使用最多不可优化 PGA 内存的会话调用。如果这些会话仍没有释放足够内存,则终止它们。

如果达到了 PGA_AGGREGATE_LIMIT 值,则将报告如下错误。
ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT
Cause: Private memory across the instance exceeded the limit specified in the PGA_AGGREGATE_LIMIT initialization parameter. The largest sessions using Program Global Area (PGA) memory were interrupted to get under the limit.
Action: Increase the PGA_AGGREGATE_LIMIT initialization parameter or reduce memory usage.

CKPT 跟踪日志中的信息:
PGA LIMIT: pid 317111 is ineligible for an ORA-4036 interrupt
System processes and most background processes cannot receive ORA-4036
interrupts. When they are contributing to the instance exceeding
PGA_AGGREGATE_LIMIT, they will periodically dump their PGA usage.
PGA LIMIT: pid 317124 is a top contributor to going over PGA_AGGREGATE_LIMIT
PGA LIMIT: pid 317124 is ineligible for an ORA-4036 interrupt
PGA LIMIT: pid 317120 is a top contributor to going over PGA_AGGREGATE_LIMIT
PGA LIMIT: pid 317120 is ineligible for an ORA-4036 interrupt

新特性往往伴随着bug,该参数也不例外:

 
其中Bug 25773856 : PGA_AGGREGATE_LIMIT EXCEEDED IN JAVAVM_MAIN LABELS 还是12.2.0.2 版本中的。 所以新版的还是要谨慎一点。

关于该参数的更多说明参考MOS文档:
Limiting process size with database parameter PGA_AGGREGATE_LIMIT (文档 ID 1520324.1)


3 示例修改

--在CDB中修改:
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Apr 17 05:29:27 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 DAVE 			  READ WRITE NO
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> show parameter pga

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit		     big integer 2G
pga_aggregate_target		     big integer 0
SQL> alter system set pga_aggregate_limit=3g;

System altered.

SQL> show parameter pga

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit		     big integer 3G
pga_aggregate_target		     big integer 0
SQL>   

--在PDB中修改:
[[email protected] admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_CNDBA =
  (ADDRESS = (PROTOCOL = TCP)(HOST = single)(PORT = 1521))


CNDBA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = single)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = cndba)
    )
  )
dave =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = single)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dave)
    )
  )

[[email protected] admin]$ sqlplus [email protected]

SQL*Plus: Release 12.2.0.1.0 Production on Mon Apr 17 05:38:02 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show con_name

CON_NAME
------------------------------
DAVE
SQL>
SQL> show parameter pga

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit		     big integer 3G
pga_aggregate_target		     big integer 0
SQL> alter system set pga_aggregate_limit=2g;

System altered.

SQL> show parameter pga

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit		     big integer 2G
pga_aggregate_target		     big integer 0
SQL>

--此时查看CDB中的参数,还是3G:
SQL>  show parameter pga

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit		     big integer 3G
pga_aggregate_target		     big integer 0
SQL>


http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952
http://www.cndba.cn/dave/article/1952
http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952 http://www.cndba.cn/dave/article/1952

版权声明:本文为博主原创文章,未经博主允许不得转载。

Oracle 12c 新参数 PGA_AGGREGATE_LIMIT 限制 PGA 内存总大小

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7972260次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ