Oracle如何调整SGA的大小2009-08-27 16:07Oracle 10G开始支持使用SGA_TARGET参数进行SGA自动管理,Oracle可自动调节共享池和数据缓冲池的大小,以下是OS:RH AS4 U7 64bit环境 Oracle 10.2.0.1版本的一个测试,先查看现在已有的SGA设置:
SQL> show parameter sga;
NAME TYPE VALUE
----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 2G
sga_target big integer 2G
更改SGA大小:
SQL> alter system set sga_max_size=4096M scope=spfile;
System altered.
SQL> alter system set sga_target=4096M scope=spfile;
System altered.
如果是RAC环境,需要这样增加sid='*':
alter system set sga_target=20G scope=spfile sid='*';
重启使更改生效:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 4294967296 bytes
Fixed Size 2026296 bytes
Variable Size 805307592 bytes
Database Buffers 3472883712 bytes
Redo Buffers 14749696 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 4G
sga_target big integer 4G
如果更改spfile导致数据库无法启动,可以在pfile后填加附加参数,现在一般的pfile都是一行SPFILE='spfileSID.ora',在后边加参数会覆盖spfile的已有参数:
SQL> alter system set lock_sga=true scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
[oracle@erpdevdb dbs]$ vi initerpstudydb.ora
SPFILE='+DGSTUDY/erpstudydb/spfileerpstudydb.ora'
lock_sga=false
SQL> startup
ORACLE instance started.
启动后,可以重新设置scope=spfile的参数,再删除pfile里后加的信息即可。
注意:SGA_MAX_SIZE最好不要超过你总内存的60%。
适当调大隐含参数“_kgl_large_heap_warning_threshold”的值,或将其设置为“0”。
1)将_kgl_large_heap_warning_threshold参数大小调整为50M
sys@orcl> alter system set "_kgl_large_heap_warning_threshold"=52428800 scope=spfile;
System altered.
2)重启数据库
SQL> shutdown immediate
SQL> startup
OK,该问题到此已得到有效处理