oracle10g11g中的SGA_MAX_SIZE与
SGA_TARGET参数
oracle 10g中的SGA_MAX_SIZE与SGA_TARGET参数
sga_target是⾃动管理内存时使⽤的,这样你就不⽤设置DB_CACHE_SIZE,SHARED_POOL_SIZE等参数,他们会根据需要⾃动的进⾏调整的。SGA_MAX_SIZE是从oracle9i以来⼀直存在﹐是不可动态修改的。
SGA_TARGET是oracle10g中⽤于实现⾃动SGA内存管理⽽新增加的。
SGA_MAX_SIZE指的是可动态分配的最⼤值﹐⽽SGA_TARGET是当前已分配的最⼤sga。
SGA_MAX_SIZE是不可以动态修改的,⽽SGA_TARGET是可动态修改﹐直到SGA_MAX_SIZE的值(当然这是在实例启动前已设定
SGA_MAX_SIZE>SGA_TARGET的情况)
如果在实例启动时﹐ SGA_MAX_SIZE < SGA_TARGET 或SGA_MAX_SIZE没设定﹐则启动后SGA_MAX
_SIZE的值会等于SGA_TARGET的值。可以⽤如下命令查看SGA_MAX_SIZE与SGA_TARGET的值
SQL> show parameter sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 152M
sga_target big integer 152M
可以⽤如下命令修改SGA_MAX_SIZE与SGA_TARGET的值
SQL> alter system set sga_max_size=160M scope=spfile;
SQL> alter system set sga_target=160M scope=spfile;
Oracle 11g新特性:Memory_target与⾃动内存管理
这个新特性算不上惊⼈,但是却是Oracle在内存管理上的⼜⼀重要增强。
如果这个参数设置过⾼,在实例启动时可能会出现如下错误提⽰:
SQL*Plus: Release 11.1.0.5.0 - Beta on Sun Jul 29 08:35:28 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
这⼀提⽰不是指特性不⽀持,⽽是你需要去调整内存设置。
在设置了这个参数后,⾃动内存调整启⽤:
SQL> show parameter memory
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
安装oracle10ghi_shared_memory_address integer 0
memory_max_target big integer 416M
memory_target big integer 416M
shared_memory_address integer 0
类似SGA_MAX_SIZE与SGA_TARGET⼀样,MEMORY_MAX_TARGET与MEMORY_TARGET成对出现,这⼀特性的出现使得
PGA+SGA作为整体内存使⽤被⼀致的纳⼊⾃动管理范畴。
⽽同样与Oracle10g类似,设置了⾃动内存管理之后,PGA_AGGREGATE_TARGET参数不再需要设置,代之发挥作⽤的参数是带有2个下划线的__PGA_AGGREGATE_TARGET参数,我们可以来看⼀下这⼏个参数的解释:
SQL> select ksppinm,ksppdesc from x$ksppi
2 where ksppinm like '%pga%';
KSPPINM KSPPDESC
----------------------- --------------------------------------------------
_pga_large_extent_size PGA large extent size
_use_ism_for_pga Use ISM for allocating large extents
_kdli_sio_pga use PGA allocations for direct IO
_kdli_sio_pga_top PGA allocations come from toplevel PGA heap
pga_aggregate_target Target size for the aggregate PGA memory consumed by the instance
__pga_aggregate_target Current target size for the aggregate PGA memory consumed
_pga_max_size Maximum size of the PGA memory for one process
Oracle 11g sga_target 参数设置
今天在⼀台linux测试机上装了Oracle 11g,安装好以后按照惯例调整sga_target 1G,pga_aggregate_target 200M
(这2个参数在11g⾥⾯默认是0),然后重启数据库
结果报错
ORA-00844: Parameter not taking MEMORY_TARGET into account, see alert log for more information
MEMORY_TARGET?新参数?虽然在安装过程中瞟过⼀眼,但是也没太多注意,后来理解MEMORY_TARGET就是原来10g的
sga_target + pga_aggregate_target的总和,越来越智能了。
再看导致错误原因:
由于设置了Oracle的MEMORY_TARGET参数的值⼩于了SGA_TARGET和PGA_TARGET的总和,因此报错。
但是此时数据库已经启不来了,在数据库不能更改spfile的情况下,我们可以更改pfile,再⽤pfile启动
SQL> create pfile ='/home/a' from spfile;
SQL> !echo '*.memory_target=1024m' >>'/home/a';
将pfile⾥⾯的memory_target设置成1G
报错,再次验证memory_target>= sga_target + pga_aggregate_target
ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 1224M
ORA-01078: failure in processing system parameters
再改
SQL> !echo '*.memory_target=1224m' >>'/home/a';
SQL> !echo '*.sga_target=0' >>'/home/a';
报新错误了⼜
ORA-00845: MEMORY_TARGET not supported on this system
最终启动成功
启动后再改回从spfile启动
SQL>create spfile from pfile = '/home/a';
然后再启动⼀次
SQL> startup
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2151248 bytes
Variable Size 511708336 bytes
Database Buffers 549453824 bytes
Redo Buffers 5623808 bytes
Database mounted.
Database opened.
最后
SQL> show parameter target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 1300M
memory_target big integer 1224M
pga_aggregate_target big integer 0
sga_target big integer 0
Oracle 11g的Linux版本在修改了MEMORY_TARGET或者SGA_TARGET后启动可能会报错:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
这个问题是由于设置SGA的⼤⼩超过了操作系统/dev/shm的⼤⼩:
[root@enterprice64 ~]# df -k /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 4089416 0 4089416 0% /dev/shm
Oracle在metalink的⽂档:Doc ID: Note:460506.1中进⾏了说明。解决这个问题只有两个⽅法,⼀种是修改初始化参数,使得初始化参数中SGA的设置⼩于/dev/shm的⼤⼩,另⼀种⽅法就是调整/dev/shm的⼤⼩。
修改/dev/shm的⼤⼩可以通过修改/etc/fstab来实现:
[root@enterprice64 ~]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
LABEL=/data /data ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
#tmpfs /dev/shm tmpfs defaults 0 0
tmpfs /dev/shm tmpfs defaults,size=10240M 0 0
LABEL=/home /home ext3 defaults 1 2
LABEL=/opt /opt ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=SWAP-sda8 swap swap defaults 0 0
~
~
"/etc/fstab" 13L, 965C written
[root@enterprice64 ~]# umount /dev/shm
[root@enterprice64 ~]# mount /dev/shm
[root@enterprice64 ~]# df -k /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 10485760 0 10485760 0% /dev/shm
[root@enterprice64 ~]# su - oracle
[oracle@enterprice64 ~]$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 23 15:42:42 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 4743446528 bytes
Fixed Size 2143824 bytes
Variable Size 3892316592 bytes
Database Buffers 805306368 bytes
Redo Buffers 43679744 bytes
Database mounted.
Database opened.
修改/etc/fstab,重新mount /dev/shm,然后就可以启动数据库
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论