ORACLE 11g 自动内存管理(原创)

Overview

在oracle 11g中,使用一个参数memory_target就能够实现SGA和PGA组件依据工作负荷进行自动内存分配。oracle推荐使用自动内存管理简化内存分配。
oracle 11g依然支持手工内存分配:
1:oracle 11g使用memory_target来支持内存自动分配。
2:使用sga_target和pga_target参数来设置SGA和PGA,数据库会在这两个组件中自我优化。
3:你也可以手工设置SGA中的各个组件。比如db_cache_size,shared_pool_size等组件。
oracle 11g中新的内存初始化参数:
有两个新的关键的内存初始化参数memory_target(动态参数,设置分配给实例的内存数)和memory_max_size(静态参数,这个参数是可选的,设置实例能够分配的最大内存,设置的是memory_target的上限值)。

注意:虽然memory_target是一个动态参数,但是当数据库运行时,你不能从非自动内存管理交换到自动内存管理。必须重启数据库将参数应用到实例启动过程才行。

When you upgrade to Oracle Database 11g using the DBUA (Database Upgrade Assistant), by default, the memory_target parameter is set to zero, meaning automatic memory management is disabled by default. However, when you create a new database using the DBCA (Database Creation Assistant), you can specify automatic memory management. You specify your choice in the Initialization Parameters page by clicking the Memory tab on that page. Following are two options offered on that page:

  • The Typical option lets you configure memory for a new database with minimal input and is ideal for most environments. Just enter a value in the Memory Size field and check the Use Automatic Memory Management option in the Typical section of the page to institute automatic memory management for the new database.
  • The Custom option provides you more control over the allocation of memory to the database. You can select the Automatic option to allocate specific amounts of memory to the SGA and PGA components of database memory. You can select the Manual option to set specific memory allocations for SGA subcomponents such as the buffer pool and the shared pool.

参数配置策略
MEMORY_TARGET 设置为非零值时:

  1. If you also set the sga_target and the pga_aggregate_target parameters, the database will consider them the minimum values for the SGA and PGA allocations of memory. The memory_target parameter can take a value anywhere between the sum of SGA and PGA to the high value set by the memory_max_target parameter.
  2. 如果设置了 SGA_TARGET 但未设置PGA_AGGREGATE_TARGET,则仍会自动优化这两个参数。PGA_AGGREGATE_TARGET 将初始化为以下值:(MEMORY_TARGET -SGA_TARGET)。
  3. 如 果设置了 PGA_AGGREGATE_TARGET 但未设置 SGA_TARGET,则仍会自动优化这两个参数。SGA_TARGET 将初始化为值 min(MEMORY_TARGET -PGA_AGGREGATE_TARGET, SGA_MAX_SIZE(如果用户已设置)),系统将自动优化子组件。
  4. 如果未设置任何参数,则无需最小值或默认值即可自动优化这两个参数。 有这样一个策略:在初始化过程中,将服务器的总内存按固定比率分配给SGA 和 PGA。该策略将在启动时分配 60% 的内存给SGA,40% 的内存给 PGA。
  5. If you set the memory_target parameter in the initialization parameter file but leave out the memory_max_size parameter, the database sets the memory_max_size parameter’s value to that of the memory_target_size parameter.

如果未设置 MEMORY_TARGET,或者将其显式设置为 0(11g 中的默认值为 0)时:

  1. If you set neither the pga_aggregate_target nor the sga_target parameters, SGA is not automatically tuned, but the PGA is.
  2. If only the sga_target parameter is set, the database automatically tunes only the subcomponents of the SGA. PGA is auto-tuned whether you set it or not.
  3. If you set the memory_max_target parameter in an initialization parameter file (init.ora) but not the memory_target parameter, the database will set the memory_target parameter’s size to its default value of zero. That is,automatic memory management will be disabled.

Monitoring Automatic Memory Management

Use the V$MEMORY_DYNAMIC_COMPONENTS view to monitor the current sizes of all dynamically tuned memory components, as shown here:

SQL> select component, current_size, user_specified_size
   2  from v$memory_dynamic_components
   3* where current_size!=0;
COMPONENT              CURRENT_SIZE      USER_SPECIFIED_SIZE
-------------------    --------------    -------------------
shared pool            109051904         0
large pool             4194304           0
java pool              12582912          0
SGA Target             134217728         0
DEFAULT buffer cache   4194304           0
PGA Target             130023424         0
6 rows selected.
As you can see, the query also shows the current total size of the SGA and the PGA components. The V$MEMORY_RESIZE_OPS view contains a circular buffer of the 800 most recent completed memory resizing operations. You can find the current memory resize operations that are in progress by querying the V$MEMORY_ CURRENT_RESIZE_OPS view.

ORA-00845

SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
这是因为/dev/shm没有设置正确的值,确保这个值至少等于sga_max_size参数值。
[oracle@node1 dbs]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       14G  9.4G  3.2G  75% /
/dev/sda1              99M   14M   81M  15% /boot
none                  2.0G  702M  1.4G  35% /dev/shm
可以看到该值为2G。
可以通过/etc/fstab来更改该值:
默认情况下该文件相关内容如下:
[oracle@node1 dbs]$ cat /etc/fstab |grep shm
none                    /dev/shm                tmpfs   defaults       0 0
可以将该值修改为如下:
none                    /dev/shm                tmpfs   defaults,size=2G        0 0
然后重启系统即可解决问题。

参考至:《McGraw.Hill.OCP.Oracle.Database.11g.New.Features.for.Administrators.Exam.Guide.Apr.2008》http://blog.chinaunix.net/uid-16728139-id-3172139.html

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:[email protected]

参考至:《McGraw.Hill.OCP.Oracle.Database.11g.New.Features.for.Administrators.Exam.Guide.Apr.2008》http://blog.chinaunix.net/uid-16728139-id-3172139.html

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:[email protected]

猜你喜欢

转载自czmmiao.iteye.com/blog/1962524