Feb 8, 2021 No Comments Oracle 10g 如何调整 sga_max_size 与 sga_target sga_max_size是相对于操作系统来讲的,当启动oracle时,一次性分配给oracle实例的sga不会超过sga_max_size值;而sga_target是相对于oracle这个正在运行的应用软件来说的,在系统已经分配了sga_max_size值的内存给oracle的前提下,对sga_target值进修改。对sga_max_size修改时,scope只对spfile生效。 第一次启动oracle时,sga_target与sga_max_size数值一样。 ``` SQL> show parameter sga; NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 892M sga_target big integer 892M ``` 一、对sga_max_size提高、降低的限制 1、用户调高sga_max_size,不对sga_target进行修改,重启oracle时,sga_max_size会相应变化 ``` SQL> alter system set sga_max_size=1024mscope=spfile; System altered. SQL> show parameter sga; NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 892M sga_target big integer 892M SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2026296 bytes Variable Size 377488584 bytes Database Buffers 687865856 bytes Redo Buffers 6361088 bytes Database mounted. Database opened. SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 1G sga_target big integer 892M ``` 2、当用户调整sga_max_size的大小,使其小于sga_target,重新启动oracle的时候,系统分配给sga_max_size将参照sga_target值 ``` SQL> alter system set sga_max_size=520mscope=spfile; System altered. SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 1G sga_target big integer 892M SQL> shutdown immediate startup Database closed. Database dismounted. ORACLE instance shut down. SQL> ORACLE instance started. Total System Global Area 935329792 bytes Fixed Size 2025168 bytes Variable Size 243271984 bytes Database Buffers 683671552 bytes Redo Buffers 6361088 bytes Database mounted. Database opened. SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 892M sga_target big integer 892M ``` 二、对sga_target提高、降低的限制 3、想提高sga_target值使其大于sga_max_size,需先提高sga_max_size值,重启oracle后才能修改并提高sga_target值 ``` SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 892M sga_target big integer 892M SQL> alter system set sga_target=1024mscope=both; alter system set sga_target=1024m scope=both * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value isinvalid ORA-00823: Specified value of sga_target greater thansga_max_size SQL> alter system set sga_max_size=1024mscope=spfile; System altered. SQL> alter system set sga_target=1024mscope=both; alter system set sga_target=1024m scope=both * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value isinvalid ORA-00823: Specified value of sga_target greater thansga_max_size SQL> shutdown immediate startup Database closed. Database dismounted. ORACLE instance shut down. SQL> ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2026296 bytes Variable Size 385877192 bytes Database Buffers 679477248 bytes Redo Buffers 6361088 bytes Database mounted. Database opened. SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 1G sga_target big integer 892M SQL> alter system set sga_target=1gscope=both; System altered. SQL> show parameter sga NAME TYPE VALUE ------------------------------------ --------------------------------------------- lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 1G sga_target big integer 1G ``` 总结:1、sga_max_size值调大、调小不受sga_target的限制,但若要让sga_max_size调小后的值生效,则必须先降低sga_target的大小,然后再修改sga_max_size,重启使其生效; 2、sga_target调高,必须在sga_max_size范围内,调小不受sga_max_size的限制。 最后更新于 2021-02-08 01:04:13 并被添加「」标签,已有 3182 位童鞋阅读过。 本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
此处评论已关闭