search
HomeDatabaseMysql Tutorialoracle三对内存参数间关系之3AMM启动和关闭两种情况下ASMM机制涉

ASMM机制涉及的一对参数为: SGA_TARGET和SGA_MAX_SIZE 。 SGA_TARGET Default value 0 (SGA autotuning is disabled for DEFERRED mode autotuning requests, but allowed for IMMEDIATE mode autotuning requests) Modifiable ALTER SYSTEM (即表示该参数

ASMM机制涉及的一对参数为:SGA_TARGET和SGA_MAX_SIZE

SGA_TARGET

Default value 0 (SGA autotuning is disabled forDEFERRED mode autotuning requests, but allowed forIMMEDIATE mode autotuning requests)
Modifiable ALTER SYSTEM<code>(即表示该参数为动态参数)
Range of values 64 MB to operating system-dependent

参见:http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams236.htm#I1010256


SGA_MAX_SIZE



Default value Initial size of SGA at startup, dependent on the sizes of different pools in the SGA, such as buffer cache, shared pool, large pool, and so on.
Modifiable No(即表示该参数为静态参数)
Range of values 0 to operating system-dependent

On 64-bit platforms and non-Windows 32-bit platforms, when either MEMORY_TARGET orMEMORY_MAX_TARGET is specified, the default value ofSGA_MAX_SIZE is set to the larger of the two parameters. This causes more address space to be reserved for expansion of the SGA.

On Windows 32-bit platforms, the default value of SGA_MAX_SIZE is the largest of the following values:

  • 60% of MEMORY_TARGET, if specified

  • 60% of MEMORY_MAX_TARGET, if specified

  • 25% of the total available virtual address space

参见:http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams235.htm



上述描述可知,

1、当SGA_TARGET=非0时,SGA_TARGET要在64 MB to operating system-dependent这个范围内,确切说是,SGA_TARGET要在64 MB to<span>SGA_MAX_SIZE</span>。

2、

由于SGA_TARGET始终SGA_MAX_SIZE,所以

SGA_TARGET=0时,<span>SGA_MAX_SIZE</span>取值范围为0 to<span>SGA_MAX_SIZE</span>。

SGA_TARGET=非0时,SGA_TARGET要在64 MB to<span>SGA_MAX_SIZE</span>这个范围内,故而<span>SGA_MAX_SIZE</span>取值范围为64 MB to operating system-dependent。



说明了SGA_TARGET要SGA_MAX_SIZE的例子,参见下文一大点里1.2的例子。


这里还有一点要知道,sga_max_size可以自动来变动的(sga_max_size自动变动值,无论在实例启动时,还是实例运行期间,都可以;而alter system setsga_max_size只能在实例启动时起效,因为sga_max_size是静态参数),当sga的内存组件的和小于sga_max_size的时候,sga_max_size不会改变,还是维持自己的值,如果超过了这个和,sga_max_size的就会自动变动成和的值,这个你可以自己试试。例如,

我现在想调整database buffer的值到1G,我只需要设置db_cache_size到1G,而不设置sga_max_size,这时由于各组件值大于sga_max_size目前值,所以sga_max_size自动变化:

 

SQL>alter system set db_cache_size=1000Mscope=spfile;

 

SQL> shutdown immediate;

 

SQL> startup;

 

看看现在的内存信息

 

Total System Global Area 1301357848 bytes

 

Fixed Size                   455960 bytes

 

Variable Size             251658240 bytes

 

Database Buffers         1048576000 bytes

 

Redo Buffers                 667648 bytes

 

发现sga_max_size已经自动变化

 

SQL> show parameters sga_

 

NAME                                 TYPE                              VALUE

 

———————————— ——————————— ———

 

sga_max_size                         big integer                       130135784

 

也已经变化叻。

 【

参见:  

http://blog.csdn.net/haiross/article/details/41696485

为什么会出现这样的问题叻,是因为在32位的机器上Oracle的内存有限制,内存最大4G,32位留50%给操作系统,window是单线程的,不能超过1.7G。out of memory也就出来叻。

SGA不能超过1.7G的限制

在Windows上调整SGA大小遭遇ORA-27100、ORA-27102错误的处理方法


当实例启动前的参数里sga_max_size=0,sga_target=0时,实例启动后sga_max_size值也会自动调整,详见下文一大点里的2.2例子。


那么sga_max_size值自动调整时,该参数的值具体为多少,是什么决定呢?

是由sga_max_size的默认值:


Default value  :Initial size of SGA at startup, dependent on the sizes of different pools in the SGA, such as buffer cache, shared pool, large pool, and so on。也就是说

SGA_MAX_SIZE 的 Default value     为Initial size of SGA at startup,所以说SGA_MAX_SIZE是一个没有初始化值的变量。故而在ASMM启动时,SGA_MAX_SIZE 的 Default value 是将SGA_target的值赋值给SGA_MAX_SIZE的,在ASMM关闭时,SGA_MAX_SIZE 的 Default value 是将sga各个组件的参数值如shared_pool_size相加的值赋值给SGA_MAX_SIZE的。

具体的说是,

On 64-bit platforms and non-Windows 32-bit platforms, when either MEMORY_TARGET orMEMORY_MAX_TARGET is specified, the default value ofSGA_MAX_SIZE is set to the larger of the two parameters. This causes more address space to be reserved for expansion of the SGA.

On Windows 32-bit platforms, the default value of SGA_MAX_SIZE is the largest of the following values:

  • 60% of MEMORY_TARGET, if specified

  • 60% of MEMORY_MAX_TARGET, if specified

  • 25% of the total available virtual address space

实例运行期间的SGA_MAX_SIZE都是一个非0值,因为SGA_MAX_SIZE是一个静态参数,所以实例运行期间将SGA_MAX_SIZE置为0,但是修改后的值不会立马起效,只有待下一次实例启动时才起效,而待下一次实例启动时如上所说实例启动时SGA_MAX_SIZE还是会从0被调整为一个非0值详见下文一大点里的2.2例子。

注释:

参数默认值不一定就是参数的初始化值:

SGA_MAX_SIZE  Default value     为Initial size of SGA at startup,所以说SGA_MAX_SIZE是一个没有初始化值的变量。故而在ASMM启动时,SGA_MAX_SIZE 的 Default value 是将SGA_target的值赋值给SGA_MAX_SIZE的,在ASMM关闭时,SGA_MAX_SIZE 的 Default value 是将sga各个组件的参数值如shared_pool_size相加的值赋值给SGA_MAX_SIZE的。

参见盖国强  《深入解析oracle》 第二章  参数分类




SGA_TARGET和SGA_MAX_SIZE两者关系为

0、SGA_TARGET始终SGA_MAX_SIZE。

否则,会提示

ORA-00823: Specified value ofsga_target greater than sga_max_size。


一、


当AMM启动时,即memory_target=非0

If Automatic Memory Management is enabled (MEMORY_TARGET is set to a positive value) andSGA_TARGET is also set to a positive value, theSGA_TARGET value acts as the minimum value for the size of the SGA.


以下实验时参数文件里MEMORY_TARGET=非0,MEMORY_MAX_TARGET=非0

1、当SGA_TARGET=非0时(即ASMM启动时)

1.1

当参数文件里SGA_TARGET=非0,<span>SGA_MAX_SIZE</span>=非0时,实例启动成功。

1.2

当参数文件里SGA_TARGET=非0,<span>SGA_MAX_SIZE</span>=0时,实例启动不成功。

下面是具体实验来证明:

参数文件里:

*.memory_max_target= 700M

*.memory_target=700M

*.sga_max_size=0

*.sga_target=400M

*.pga_aggregate_target=100M

 

SQL>shutdown immediate

数据库已经关闭。

已经卸载数据库。

ORACLE例程已经关闭。

SQL>startup pfile=E:\app\hc\product\11.2.0\dbhome_1\database\INITmonkey.ORA

ORA-00823: Specified value of sga_target greater than sga_max_size

ORA-01078:处理系统参数失败

SQL>

注释:

对比memory_max_target和memory_target关系不同点在于:

MEMORY_TARGET=0MEMORY_MAX_TARGET=0时,启动实例后MEMORY_MAX_TARGET=MEMORY_TARGET值。

2、当SGA_TARGET=0时(即ASMM关闭时)

2.1

当参数文件里SGA_TARGET=0,<span>SGA_MAX_SIZE</span>=非0时,实例启动成功。

注释:

memory_target=0时sga_ target可以为0是因为memory_target=0时sga_ target为0,表示sga为手动管理,即由shared_pool_size参数等之和为sga大小。


2.2

当参数文件里SGA_TARGET=0,<span>SGA_MAX_SIZE</span>=0时,实例启动成功。

启动实例成功后,查看SGA_TARGET和<span>SGA_MAX_SIZE</span>(使用showparameters  sga或是select * from  v$parameter where name like '%sga%';),发现<span>SGA_MAX_SIZE</span>被调整为一个非0值。

下面是具体实验来证明:

以如下参数文件来启动实例:

memory_target=0memory_max_target=1400M

pga_aggregate_target 0workarea_size_policy=manual

sga_max_size=0,sga_target=0

则可以启动实例成功。

SQL> select name,value from  v$parameter where name like '%target%' orname like

 '%sga%';

 

NAME                                              VALUE

------------------------                      --------------------------------------------------------

 sga_max_size                         150994944

 

pre_page_sga                           FALSE

 

lock_sga                                     FALSE

 

sga_target                                 0

 

memory_target                        0

 

memory_max_target             1468006400

 

archive_lag_target                   0

 

fast_start_io_target                  0

 

fast_start_mttr_target              0

 

db_flashback_retention_target           1440

 

pga_aggregate_target            0

 

parallel_servers_target            32

 

已选择12行。

注释:

为什么启动实例时SGA_MAX_SIZE会从0被调整为一个非0值呢?

因为

sga_max_size可以自动来变动的(sga_max_size自动变动值,无论在实例启动时,还是实例运行期间,都可以;而alter system setsga_max_size只能在实例启动时起效,因为sga_max_size是静态参数),当sga的内存组件的和小于sga_max_size的时候,sga_max_size不会改变,还是维持自己的值,如果超过了这个和,sga_max_size的就会自动变动成和的值。

那么sga_max_size值自动调整时,该参数的值具体为多少,是什么决定呢?

是由sga_max_size的默认值

SGA_MAX_SIZE  Default value     为Initial size of SGA at startup,所以说SGA_MAX_SIZE是一个没有初始化值的变量。故而在ASMM启动时,SGA_MAX_SIZE 的 Default value 是将SGA_target的值赋值给SGA_MAX_SIZE的,在ASMM关闭时,SGA_MAX_SIZE 的 Default value 是将sga各个组件的参数值如shared_pool_size相加的值赋值给SGA_MAX_SIZE的。


所以,实例启动前的参数文件即使设置了SGA_MAX_SIZE=0,实例启动时SGA_MAX_SIZE也会从0被调整为一个非0值。

故而我们可以知道实例运行期间的SGA_MAX_SIZE都是一个非0值,因为SGA_MAX_SIZE是一个静态参数,所以实例运行期间将SGA_MAX_SIZE置为0,但是修改后的值不会立马起效,只有待下一次实例启动时才起效,而待下一次实例启动时如上所说实例启动时SGA_MAX_SIZE还是会从0被调整为一个非0值

二、

当AMM关闭时,即memory_target=0


2、当MEMORY_TARGET=0时(即AMM关闭时)

2.1

当参数文件里MEMORY_TARGET=0,MEMORY_MAX_TARGET=非0时,实例启动成功。

实例启动后,查看MEMORY_TARGET和MEMORY_MAX_TARGET都为原值(使用showparameters  mem或是select * from  v$parameter where name like '%mem%';)。即

If you omit the line for MEMORY_TARGET and include a value forMEMORY_MAX_TARGET, theMEMORY_TARGET parameter defaults to zero. After startup, you can then dynamically changeMEMORY_TARGET to a nonzero value, provided that it does not exceed the value ofMEMORY_MAX_TARGET.(文章详解)

2.2

当参数文件里MEMORY_TARGET=0,MEMORY_MAX_TARGET=0时,实例启动成功。

实例启动后,查看MEMORY_TARGET和MEMORY_MAX_TARGET(使用showparameters  mem或是select * from  v$parameter where name like '%mem%';),发现MEMORY_MAX_TARGET被调整为一个非0值。

下面是具体实验来证明:



三、

AMM关闭时(即memory_target=0),才会出现ORA-00849:SGA_TARGET 524288000 cannot be set to more than MEMORY_MAX_TARGET 0.无论是sga_target>memory_max_target还是sga_max_size>memory_max_target。当sga_max_size>memory_max_target时,即使此时sga_target也>memory_max_target,ORA-00849里的SGA_TARGET值还是来自sga_max_size

附加

sga_max_size是静态参数,所以它即使在实例运行期间修改的值也要在下次启动时起作用,故而不用试验sga_max_size静态参数在实例运行期间修改对sga_target影响。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment