您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle体系结构及备份(五)sga

2025/5/19 5:05:35发布144次查看
一 什么是sga(参考 oracle内存结构--sga) sga 是一组为系统分配的共享的内存结构,可以包含一个数据库实例的数据或控制信息。如果多个用户连接到同一个数据库实例,在实例的 sga 中,数据可以被多个用户共享。当数据库实例启动时, sga 的内存被自动分配;
一 什么是sga(参考 oracle内存结构--sga) 
        sga是一组为系统分配的共享的内存结构,可以包含一个数据库实例的数据或控制信息。如果多个用户连接到同一个数据库实例,在实例的sga中,数据可以被多个用户共享。当数据库实例启动时,sga的内存被自动分配;当数据库实例关闭时,sga内存被回收。 sga是占用内存最大的一个区域,同时也是影响数据库性能的重要因素。
sga区是可读写的。所有登录到实例的用户都能读取sga中的信息,而在oracle做执行操作时,服务进程会将修改的信息写入sga区。
sga主要包括了以下的数据结构:
数据缓冲(buffer cache)
重做日志缓冲(redo log buffer)
共享池(shared pool)
java池(java pool)
大池(large pool)
流池(streams pool --- 10g以后才有)
数据字典缓存(data dictionary cache)
其他信息(如数据库和实例的状态信息)
the sga is the oracle structure that is located in shared memory. it contains static data structures, locks, and data buffers. sufficient shared memory must be available to each oracle process to address the entire sga.
the maximum size of a single shared memory segment is specified by the shmmax kernel parameter.
the following table shows the recommended value for this parameter, depending on the platform:
if the size of the sga exceeds the maximum size of a shared memory segment (shmmax or shm_max), then oracle database attempts to attach more contiguous segments to fulfill the requested sga size. the shmseg kernel parameter specifies the maximum number of segments that can be attached by any process. set the following initialization parameters to control the size of the sga:
db_cache_size
db_block_size
java_pool_size
large_pool_size
log_buffers
shared_pool_size
alternatively, set the sga_target initialization parameter to enable automatic tuning of the sga size.
use caution when setting values for these parameters. when values are set too high, too much of the physical memory is devoted to shared memory. this results in poor performance.
an oracle database configured with shared server requires a higher setting for the shared_pool_size initialization parameter, or a custom configuration that uses the large_pool_size initialization parameter. if you installed the database with oracle universal installer, then the value of the shared_pool_size parameter is set automatically by oracle database configuration assistant. however, if you created a database manually, then increase the value of the shared_pool_size parameter in the parameter file by 1 kb for each concurrent user.
二 内存管理方式 
        oracle 8i:手动 pga管理
        oracle 9i:自动pga内存管理、手工共享内存管理
        oracle 10g:自动共享内存管理
        oracle 11g:自动内存管理
三 sga的分配 
        sga的管理又三种方式
        8i:sga的总大小由所有内存组件大小之和决定,不能直接定义sga大小。对内部组件大小的修改必须在数据库重启后才能生效,所以叫sga的静态管理。
9i:sga总大小由初始化参数sga_max_size确定,各个内存最贱大小之和不能超过这个参数,在这个大小之下,sga各个内存组件可以在不重启数据库的情况下直接修改大小,所以叫做sga的动态管理。
10g:sga大小既可以像9i一样动态管理,也可以实施sga的自动管理,只需要设置初始化参数sga_target,sga各个内存组件就可以由数据库自动设置大小,设置的数据来源于系统自动收集的统计信息。在9i以后,sga的内部组件大小可以动态调整,也可以由数据库自动管理,在设置内存大小的时候,分配的基本单位是粒度(granule).granule是一段连续的虚拟内存,大小取决于sga_max_size的大小,如果sga_max_size小于128m,granule为4m,否则granule为16m。各个内存组件分配大小必须是granule的整倍数。整个sga最小不小于3个granule大小。
9i中的规则如下
        linux/unix
        sga
        sga > 128m granule 16m
windows
        sga
        sga > 128m granule 8m
10g中的分配规则为
        linux/unix/windows
        sga 为4m,否则为16m
sga的各个组件大小是可以动态调整的,总大小不超过参数sga_max_size或者sga_target的大小。
四 操作示例
sql> select name, bytes/1024/1024 mb, resizeable from v$sgainfo;name mb res-------------------------------- ---------- ---granule size 4 no-------------------------------- ---------- ---sql> show parameter sga_max_size;name type value------------------------------------ ----------- ------------------------------sga_max_size big integer 160msql> alter system set sga_max_size=1025m scope=spfile;system altered.sql> startup force;oracle instance started.total system global area 1090519040 bytesfixed size 1218944 bytesvariable size 1056966272 bytesdatabase buffers 16777216 bytesredo buffers 15556608 bytesdatabase mounted.database opened.sql> show parameter sga_max_size;name type value------------------------------------ ----------- ------------------------------sga_max_size big integer 1040m--因各个内存组件分配大小必须是granule的整倍数,右1025隔1040最近,所以此处为1040m。sql> select name, bytes/1024/1024 mb, resizeable from v$sgainfo;name mb res-------------------------------- ---------- ---granule size 16 no-------------------------------- ---------- ---sql> desc v$sgainfo; name null? type ----------------------------------------- -------- ---------------------------- name varchar2(32) bytes number resizeable varchar2(3)sql> select * from v$sgainfo;name bytes res-------------------------------- ---------- ---fixed sga size 1218316 noredo buffers 2973696 nobuffer cache size 92274688 yesshared pool size 62914560 yeslarge pool size 4194304 yesjava pool size 4194304 yesstreams pool size 0 yesgranule size 4194304 nomaximum sga size 167772160 nostartup overhead in shared pool 37748736 nofree sga memory available 011 rows selected.sql> select name, bytes/1024/1024 mb, resizeable from v$sgainfo;name mb res-------------------------------- ---------- ---fixed sga size 1.16187668 noredo buffers 2.8359375 nobuffer cache size 88 yesshared pool size 60 yeslarge pool size 4 yesjava pool size 4 yesstreams pool size 0 yesgranule size 4 nomaximum sga size 160 nostartup overhead in shared pool 36 nofree sga memory available 011 rows selected.sql> show parameter sga_max_size;name type value------------------------------------ ----------- ------------------------------sga_max_size big integer 160msql> alter system set sga_max_size=1025m scope=spfile;system altered.sql> startup force;oracle instance started.total system global area 1090519040 bytesfixed size 1218944 bytesvariable size 1056966272 bytesdatabase buffers 16777216 bytesredo buffers 15556608 bytesdatabase mounted.database opened.sql> show parameter sga_max_size;name type value------------------------------------ ----------- ------------------------------sga_max_size big integer 1040msql> select name, bytes/1024/1024 mb, resizeable from v$sgainfo;name mb res-------------------------------- ---------- ---fixed sga size 1.16247559 noredo buffers 14.8359375 nobuffer cache size 16 yesshared pool size 96 yeslarge pool size 16 yesjava pool size 16 yesstreams pool size 0 yesgranule size 16 nomaximum sga size 1040 nostartup overhead in shared pool 32 nofree sga memory available 88011 rows selected.sql> show parameter shared_p;name type value------------------------------------ ----------- ------------------------------shared_pool_reserved_size big integer 4mshared_pool_size big integer 0sql> alter system set shared_pool_size=10m;system altered.sql> alter system set sga_max_size=800m scope=spfile; system altered.sql> startup force;oracle instance started.total system global area 838860800 bytesfixed size 1222192 bytesvariable size 734005712 bytesdatabase buffers 100663296 bytesredo buffers 2969600 bytesdatabase mounted.database opened.sql> alter system set shared_pool_size=10m;system altered.sql> show parameter shared_p;name type value------------------------------------ ----------- ------------------------------shared_pool_reserved_size big integer 838860shared_pool_size big integer 12msql> show parameter sga_max_size;name type value------------------------------------ ----------- ------------------------------sga_max_size big integer 800msql> show parameter sga_target;name type value------------------------------------ ----------- ------------------------------sga_target big integer 160msql> show parameter shared_pool_size;name type value------------------------------------ ----------- ------------------------------shared_pool_size big integer 12msql> show parameter large_pool_size;name type value------------------------------------ ----------- ------------------------------large_pool_size big integer 0sql> show parameter java_pool_size;name type value------------------------------------ ----------- ------------------------------java_pool_size big integer 0sql> show parameter streams_pool_size; name type value------------------------------------ ----------- ------------------------------streams_pool_size big integer 0sql> show parameter db_cache_size;name type value------------------------------------ ----------- ------------------------------db_cache_size big integer 0sql> show parameter sga_target;name type value------------------------------------ ----------- ------------------------------sga_target big integer 160msql>
五 总结 
        1. sga是一组为系统分配的共享的内存结构,可以包含一个数据库实例的数据或控制信息。
2. sga主要包括了以下的数据结构:数据缓冲(buffer cache)、重做日志缓冲(redo log buffer)、共享池(shared pool)、java池(java pool)、大池(large pool)、流池(streams pool --- 10g以后才有)、数据字典缓存(data dictionary cache)、其他信息(如数据库和实例的状态信息);
3.可以通过v$sgainfo视图查看sga相关信息。
我的邮箱:wgbno27@163.com 新浪微博:@wentasy27 微信公众平台:justoracle(微信号:justoracle) it交流群:336882565(加群时验证 from csdn xxx) oracle交流讨论组:https://groups.google.com/d/forum/justoracle by larry wen
@wentasy
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product