linux oracle 内核参数优化,Linux 内核参数优化(for Oracle)

4、参数SHMMAX

a、参数描述(From meatlink [ID 15566.1])

Shared memory allocation

========================

Oracle has 3 different possible models for the SGA - one-segment,

contiguous multi-segment, and non-contiguous multi-segment.

When attempting to allocate and attach shared memory for the SGA, it

will attempt each one, in the above order, until one succeeds or raises

an ORA error.  On other, non-fatal, errors, Oracle simply cleans up and

tries again using the next memory model.  The entire SGA must fit into

shared memory, so the total amount of shared memory allocated under any

model will be equal to the size of the SGA.  This calculated value will

be referred to below as SGASIZE.

The one-segment model is the simplest and first model tried. In this

model, the SGA resides in only one shared memory segment.  Oracle attempts

to allocate and attach one shared memory segement of size equal to total

size of the SGA.  However, if the SGASIZE is larger than the configured

SHMMAX, this will obviously fail (with EINVAL).  In this case, the SGA will

need to be placed in multiple shared memory segments, and Oracle proceeds

to the next memory model for the SGA.  If an error other than EINVAL occurs

when allocating the shared memory with shmget(), Oracle will raise an

ORA-7306.  If the segment was received (i.e. if SHMMAX > SGASIZE), Oracle

attempts to attach it at the start address defined in ksms.o.  An error

on the attach will raise an ORA-7307.

With multiple segments there are two possibilities.  The segments

can be attached contiguously, so that it appears to be one large

shared memory segment, or non-contiguously, with gaps between the

segments.  The former wastes less space that could be used for the stack

or heap, but depending on alignment requirements for shared memory

(defined by SHMLBA in the kernel), it may not be possible.

At this point, Oracle needs to determine SHMMAX so it can determine how many

segments will be required.  This is done via a binary search

algorithm over the range [1...SGASIZE] (since Oracle is trying this

model and not the one segment model it must be that SHMMAX

The value of SHMMAX calculated will then be rounded to an even page size

(on some machines, possibly to an even 2 or 4 page block).

In the contiguous segment model, Oracle simply divides the SGA into

SGASIZE/SHMMAX (rounded down) segments of size SHMMAX plus another segment

of size SGASIZE modulo SHMMAX.  If more than SS_SEG_MAX segments are

required total, an ORA-7329 is raised.  It then allocates and attaches

one segment at a time, attaching the first segment at the start address

defined in "ksms.o".  Subsequent segments are attached at an address equal

to the previous segment's attach address plus the size of the previous

segment so that they are contiguous in memory.

For example, if SHMMAX is 2M, SGASIZE is 5M, and the start address is

0xd0000000, there would be 3 segments, 2 of 2M and 1 of 1M.  They would be

attached at 0xd0000000, 0xd0000800 (0xd0000000+2M), and 0xd0001000

(0xd0000800+2M).  If Oracle receives an error allocating a shared memory

segment, an ORA-7336 is raised.

If an error is raised on attaching a shared memory segement, Oracle checks

the system error returned.  If it is EINVAL, the attach address used is most

likely badly aligned (not a mulitple of SHMLBA).  In this case, Oracle tries

the next model for SGA allocation, non-contiguous segments.  Otherwise, an

ORA-7337 is raised.

The last model Oracle will try is the non-contiguous model.  Here,

things become a bit more complicated.  After calculating SHMMAX, Oracle

first checks to see if it can put the fixed and variable portion into

one shared memory segment just large enough to hold the two portions

If it can, it allocates a segment just big enough to hold both portions.

If it cannot, it will put them each into their own seperate segment just

large enough to hold each portion.  If the fixed portion is larger than

SHMMAX, an ORA-7330 will be raised.  If the variable portion is larger

than SHMMAX, an ORA-7331 will be raised.  Then Oracle computes the number

of redo block buffers it can fit in a segment (rounded down to an

integral number of buffers - buffers cannot overlap segments).  An ORA-7332

is raised is SHMMAX is smaller than the size of a redo block.

Similarly, the number of db block buffers per segment is calculated, with an

ORA-7333 raised if SHMMAX is too small to hold one db block.  Then Oracle can

compute the total number of segments required for both the redo and database

block buffers. This will be buffers/buffers per segment (rounded down) segments

and one (if necessary) of buffers modulo buffers per segment size, calculated

seperately for both the redo and db block buffers.  These segments will be

of a size just large enough to hold the buffers (so no space is wasted).

The total number of segments allocated will then be the number needed for

the fixed and variable portions (1 or 2) plus the number needed for the

redo block buffers plus the number of segments needed for the database block

buffers.  If this requires more than SS_SEG_MAX segments, an ORA-7334 is

raised.

Once the number of segments and their sizes is determined, Oracle

then allocates and attaches the segments one at a time; first the fixed

and variable portion segment(s), then the redo block buffer segment(s),

then the db block buffer segment(s).  They will be attached non-contiguously,

with the first segment attached at the start address in "ksms.o" and following

segments being attached at the address equal to the attach address of the

previous segment plus the size of the previous segment, rounded up to a

mulitple of SHMBLA.

If Oracle receives an error allocating a shared memory segment, an ORA-7336 is

raised.  If an error is raised on attaching a shared memory segement, Oracle

checks the system error returned.  If it is EINVAL, normally another model

would be tried, but as there are no more models to try, an ORA-7310 is raised.

Other attach errors raise an ORA-7337.

At this point, we have either attached the entire SGA or returned an

ORA error.  The total size of segments attached is exactly SGASIZE;

no space is wasted.  Once Oracle has the shared memory attached, Oracle

proceeds to allocating the semaphores it requires.

该参数定义了一个linux进程能分配虚拟地址空间的单个共享内存段的大小(字节为单位)。

从上面的描述可知对于Oracle而言,SHMMAX主要用于控制和分配sga,且使用3种不同的模式可供选择来分配sga size

SHMMAX > SGASIZE : 分配一个单独的共享内存段给sga(首选方式)

SHMMAX < SGASIZE : 分配多个连续或不连续的共享内存段给sga

由上可知应当设置为大于当前服务器上运行实例的最大的SGA的大小。

如该值设置太小或者小于最大sga的大小,则sga无法在一个单独的共享内存段hold住整个sga,而需要分配多个不同的共享内存段来完成。

对于32-bit操作系统,通常设置为4GB-1byte,而64-bit,则可以设置为大于4GB

b、查看参数文件值

# cat /proc/sys/kernel/shmmax

2147483648

c、修改参数值

如果当前最大sga的大小为3g,则至少为shmmax设置下面的值

# echo 3221225472 > /proc/sys/kernel/shmmax

# sysctl -w kernel.shmmax=3221225472

    # echo "kernel.shmmax=3221225472" >> /etc/sysctl.conf0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值