日期:2014-05-16  浏览次数:20381 次

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.