memory management in oracle 11G R2
When we talking about memory management in Oracle, we are refering to SGA and PGA. The management methold including below.
- automatic mangement
- Enable automatic memory management
- monitor and tune automatic memory management
- manual management
- Automatic shared memory management - for the SGA
- Manual shared memory management - for the SGA
- Automatic PGA memory management - for the instance PGA
- Manual PGA memory management - for the instance PGA
automatic management
In oracle 11g r2, the SGA and PGA are managed together. So to enable the automatic memory management, you can just set the a target memory size initialization parameter (MEMORY_TARGET
) and optionally a maximum memory size initialization parameter (MEMORY_MAX_TARGET
).The total memory that the instance uses remains relatively constant, based on the value of MEMORY_TARGET
,(Here it said the memory will be remain relatively constant. Is it possible that the memory--the sum of PGA and SGA will exceed the current setting of memory_target? ) and the instance automatically distributes memory between the system global area (SGA) and the instance program global area (instance PGA). As memory requirements change, the instance dynamically redistributes memory between the SGA and instance PGA.
MEMORY_TARGET
initialization parameter is dynamic, you can change MEMORY_TARGET
at any time without restarting the database.MEMORY_MAX_TARGET
, which is not dynamic, serves as an upper limit so that you cannot accidentally set MEMORY_TARGET
too high, and so that enough memory is set aside for the database instance in case you do want to increase total instance memory in the future. Because certain SGA components either cannot easily shrink or must remain at a minimum size, the instance also prevents you from setting MEMORY_TARGET
too low.
enable automatic memory management
If you didnt enable automatic memory management during the database creation time, you can enable it at any time. This will include a shutdown and restart of the database.
1. connect to database by sys
2. compute the mininum value for memory_target.
Determine the current sizes of SGA_TARGET and PGA_AGGREGATE_TARGET by entering the following SQL*Plus command:
SHOW PARAMETER TARGET NAME TYPE VALUE
------------------------------------ ----------- ----------------
archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 0
memory_target big integer 0
parallel_servers_target integer 16
pga_aggregate_target big integer 90M
sga_target big integer 272M
Run the following query to determine the maximum instance PGA allocated since the database was started:
select value from v$pgastat where name='maximum PGA allocated';
Compute the maximum value(Here using the max(pga_aggrgate_target,maximum PGA allocated). So it means the PGA allocated can exceed the pga_aggregate_target? Then how about the sga_target and SGA allocated? Memory_target and memory totally allocated?)
memory_target = sga_target + max(pga_aggregate_target, maximum PGA allocated)
3. For the MEMORY_MAX_TARGET
initialization parameter, decide on a maximum amount of memory that you would want to allocate to the database for the foreseeable future. That is, determine the maximum value for the sum of the SGA and instance PGA sizes. This number can be larger than or the same as the MEMORY_TARGET
value that you chose in the previous step.
4. Now do the following.
If you are using text initialization parameter file. Then you can manually edit the file as below.
memory_max_target = nM
memory_target = mM
Then restart the database.
If you are using server parameter file. Then you can set the memory_max_target first.
ALTER SYSTEM SET MEMORY_MAX_TARGET = nM SCOPE = SPFILE;
This parameter is not dynamic so you have to specify the scope = spfile.
Then restart your database. After the database is up.
ALTER SYSTEM SET MEMORY_TARGET = nM;
ALTER SYSTEM SET SGA_TARGET = 0;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET = 0;
Here you need to know that the preceding steps instruct you to set SGA_TARGET
and PGA_AGGREGATE_TARGET
to zero so that the sizes of the SGA and instance PGA are tuned up and down as required, without restrictions. You can omit the statements that set these parameter values to zero and leave either or both of the values as positive numbers. In this case, the values act as minimum values for the sizes of the SGA or instance PGA.
Monitor and tune automatic memory management
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.
The view V$MEMORY_TARGET_ADVICE
provides tuning advice for the MEMORY_TARGET
initialization parameter.
SQL> select * from v$memory_target_advice order by memory_size; MEMORY_SIZE MEMORY_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR VERSION
----------- ------------------ ------------ ------------------- ----------
180 .5 458 1.344 0
270 .75 367 1.0761 0
360 1 341 1 0
450 1.25 335 .9817 0
540 1.5 335 .9817 0
630 1.75 335 .9817 0
720 2 335 .9817 0
The row with the MEMORY_SIZE_FACTOR
of 1 shows the current size of memory, as set by the MEMORY_TARGET
initialization parameter, and the amount of DB time required to complete the current workload. In previous and subsequent rows, the results show several alternative MEMORY_TARGET
sizes. For each alternative size, the database shows the size factor (the multiple of the current size), and the estimated DB time to complete the current workload if theMEMORY_TARGET
parameter were changed to the alternative size. Notice that for a total memory size smaller than the current MEMORY_TARGET
size, estimated DB time increases. Notice also that in this example, there is nothing to be gained by increasing total memory size beyond 450MB. However, this situation might change if a complete workload has not yet been run.
manual memory management
Automatic shared memory management
This paragraph including below topics.
About Automatic Shared Memory Management
Components and Granules in the SGA
Setting Maximum SGA Size
Setting SGA Target Size
About Automatic Shared Memory Management
Automatic Shared Memory Management simplifies SGA memory management. You specify the total amount of SGA memory available to an instance using theSGA_TARGET
initialization parameter and Oracle Database automatically distributes this memory among the various SGA components to ensure the most effective memory utilization.
Components and Granules in the SGA
We already know that Automatic SGA management means the SGA components can be resized automatically based on requirements. The memory unites used in the allocation and deallocation is called Granules here.The granule size is determined by the amount of SGA memory requested when the instance starts. Specifically, the granule size is based on the value of the SGA_MAX_SIZE
initialization parameter.
Setting maxium SGA size
The SGA_MAX_SIZE
initialization parameter specifies the maximum size of the System Global Area for the lifetime of the instance(So it means that the SGA size will never exceed the SGA_MAX_SIZE? Unlike the PGA_AGGREGATE_SIZE may be exceeded?). You can dynamically alter the initialization parameters affecting the size of the buffer caches, shared pool, large pool, Java pool, and streams pool but only to the extent that the sum of these sizes and the sizes of the other components of the SGA (fixed SGA, variable SGA, and redo log buffers) does not exceed the value specified bySGA_MAX_SIZE
.
If you do not specify SGA_MAX_SIZE
, then Oracle Database selects a default value that is the sum of all components specified or defaulted at initialization time. If you do specify SGA_MAX_SIZE
, and at the time the database is initialized the value is less than the sum of the memory allocated for all components, either explicitly in the parameter file or by default, then the database ignores the setting for SGA_MAX_SIZE
and chooses a correct value for this parameter.
Seting SGA_TARGET
One important thing you should know. The STATISTICS_LEVEL
initialization parameter must be set to TYPICAL
(the default) or ALL
for automatic shared memory management to function.
When you set SGA target, some components can be automatically based on the sga_target. Listed below
The shared pool SHARED_POOL_SIZE
The large pool LARGE_POOL_SIZE
The Java pool JAVA_POOL_SIZE
The buffer cache DB_CACHE_SIZE
The Streams pool STREAMS_POOL_SIZE
Some components need to be manually set, if they are set, they will take some space from the SGA_TARGET and the rest space will be allocated to the components above.
The log buffer LOG_BUFFER
The keep and recycle buffer caches DB_KEEP_CACHE_SIZE/DB_RECYCLE_CACHE_SIZE
Nonstandard block size buffer caches DB_nK_CACHE_SIZE
After setting the SGA_TARGET you can choose to set the componenet corresponding parameter to zero or not. If you set these parameters to zero, they are fully automatica management. If you set those values to non-zero values, these values will be the mininum value for these component
Monitoring and Tuning SGA Target Size
The V$SGAINFO
view provides information on the current tuned sizes of various SGA components.
The V$SGA_TARGET_ADVICE
view provides information that helps you decide on a value for SGA_TARGET
.
SQL> select * from v$sga_target_advice order by sga_size; SGA_SIZE SGA_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR ESTD_PHYSICAL_READS
---------- --------------- ------------ ------------------- -------------------
. 1.6578
. 1.2552 1.25 .
1.5 .
1.75 .
.
Manual shared memory management
Do not need to care
Automatic PGA management
By default, Oracle Database automatically and globally manages the total amount of memory dedicated to the instance PGA. You can control this amount by setting the initialization parameter PGA_AGGREGATE_TARGET
. Oracle Database then tries to ensure that the total amount of PGA memory allocated across all database server processes and background processes never(Here said never. Actually it could exceed. So very interesting here. What is the point for this parameter? ) exceeds this target.
With automatic PGA memory management, sizing of SQL work areas for all dedicated server sessions is automatic and all *_AREA_SIZE
initialization parameters are ignored for these sessions. At any given time, the total amount of PGA memory available to active work areas on the instance is automatically derived from the parameter PGA_AGGREGATE_TARGET
. This amount is set to the value of PGA_AGGREGATE_TARGET
minus the PGA memory allocated for other purposes (for example, session memory). The resulting PGA memory is then allotted to individual active work areas based on their specific memory requirements.
There are dynamic performance views that provide PGA memory use statistics. Most of these statistics are enabled when PGA_AGGREGATE_TARGET
is set.
Statistics on allocation and use of work area memory can be viewed in the following dynamic performance views:
V$SYSSTAT
V$SESSTAT
V$PGASTAT
V$SQL_WORKAREA
V$SQL_WORKAREA_ACTIVE
The following three columns in the
V$PROCESS
view report the PGA memory allocated and used by an Oracle Database process:
PGA_USED_MEM
PGA_ALLOC_MEM
PGA_MAX_MEM
Manual PGA management
Don`t need to care.
memory management in oracle 11G R2的更多相关文章
- RedHat 6.7 Enterprise x64环境下使用RHCS部署Oracle 11g R2双机双实例HA
环境 软硬件环境 硬件环境: 浪潮英信服务器NF570M3两台,华为OceanStor 18500存储一台,以太网交换机两台,光纤交换机两台. 软件环境: 操作系统:Redhat Enterpris ...
- RedHat 6.7 Enterprise x64环境下使用RHCS部署Oracle 11g R2双机HA
环境 软硬件环境 硬件环境: 浪潮英信服务器NF570M3两台,华为OceanStor 18500存储一台,以太网交换机两台,光纤交换机两台. 软件环境: 操作系统:Redhat Enterprise ...
- Oracle Linux 6.3下安装Oracle 11g R2(11.2.0.3)
本文主要描写叙述了在Oracle Linux 6.3下安装Oracle 11gR2(11.2.0.3).从Oracle 11g開始,Oracle官方站点不再提供其Patch的下载链接,须要使用Meat ...
- Oracle 11g R2创建数据库之手工建库方式
在之前的博文当中梳理了关于DBCA静默方式创建数据库的过程,本文就手工通过SQL*PLUS客户端采用CREATE DATABASE语句创建数据库.这种建库方式就是完全使用手工SQL语句创建数据库,通常 ...
- centos 安装oracle 11g r2(一)-----软件安装
centos 安装oracle 11g r2(一)-----软件安装 1.进入管理员权限 [anzerong@localhost ~]# su - root password [root@localh ...
- centos 安装oracle 11g r2(三)-----表空间创建
centos 安装oracle 11g r2(三)-----表空间创建 创建表空间前要保证监听与数据库实例已经启动 1.启动监听 [oracle@localhost ~]$ lsnrctl start ...
- Oracle 11G R2 RAC中的scan ip 的用途和基本原理【转】
Oracle 11G R2 RAC增加了scan ip功能,在11.2之前,client链接数据库的时候要用vip,假如你的cluster有4个节点,那么客户端的tnsnames.ora中就对应有四个 ...
- oracle 11g r2 rac到单实例的dg
oracle 11g r2 rac到单实例的dg 1 主备环境说明 rac环境--primary CentOS release 6.5 (Final)hostname rac1 rac2ip 10.* ...
- Oracle 11g R2(11.2.0.4) RAC 数据文件路径错误解决--ORA-01157 ORA-01110: 数据文件
Oracle 11g R2(11.2.0.1) RAC 数据文件路径错误解决--ORA-01157 ORA-01110: 数据文件 oracle 11g R2(11.2.0.4) rac--scan ...
随机推荐
- epoll IO多路复用(异步阻塞AIO)
epoll的异步阻塞(AIO): 用户线程创建epoll后,其实是内核线程负责扫描 fd 列表(在网络服务器上可以是socket,socket在创建后返回的也是文件描述符),并填充事件链表.但是,并不 ...
- 22 C#中的异常处理入门 try catch throw
软件运行过程中,如果出现了软件正常运行不应该出现的情况,软件就出现了异常.这时候我们需要去处理这些异常.或者让程序终止,避免出现更严重的错误.或者提示用户进行某些更改让程序可以继续运行下去. C#编程 ...
- CF811C Vladik and Memorable Trip
思路: 令dp[i]表示前i个的最大舒适度.则如果区间[j, i](1 < j <= i)满足条件,有如下转移:dp[i] = max(dp[i], dp[j - 1] + cur).其中 ...
- 42使用NanoPiM1Plus在Android4.4.2下的录音测试
42使用NanoPiM1Plus在Android4.4.2下的录音测试 大文实验室/大文哥壹捌陆捌零陆捌捌陆捌贰21504965 AT qq.com完成时间:2017/12/5 17:51版本:V1. ...
- 安装ipython notebook及基本命令(快捷键)
转载自:http://121.42.47.99/yuenshome/wordpress/?p=2622 目前基本上是Pycharm和ipython notebook结合起来做东西,ipython no ...
- 调用微信扫一扫功能,踩坑'invalid signature'
在vue项目中,调用微信扫一扫功能,在安卓系统下完全正常,ios系统下却报错'invalid signature'的错误,这可能令许多小伙伴困惑,经过查询大量博客相关资料,才找到了解决的方法. 原因: ...
- 实战:tcp链接rst场景tcpdump分析
RST为重置报文段,它会导致TCP连接的快速拆迁,且不需要ack进行确认. 1.针对不存在的端口的连请求 客户端: #include <unistd.h> #include <sys ...
- 带返回值的线程Callable
- org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: xxxxxxx 原因是 ...
- HDU - 2050 - 折线分割平面(数学 + dp)
题意: 我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目.比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分 思路: 记住结论.. ...