【异常处理】ORA-27125 unable to create shared memory segment 如何处理

 oerr ora 27125
27125, 00000, “unable to create shared memory segment”
// *Cause: shmget() call failed
// *Action: contact Oracle support

Oracle:ORA-27125: unable to create shared memory segment

问题:
在一个具有128G内存的Centos7.9的系统上,创建多个oracle 12.2.0.1实例时,后面的实例无法启动,报错:

SQL> ORA-27125: unable to create shared memory segment
Linux-x86_64 Error: 28: No space left on device
Additional information: 3822
Additional information: 4278190080

经过使用strace跟踪,发现:
[pid 13722] shmget(IPC_PRIVATE, 4278190080, IPC_CREAT|IPC_EXCL|0600) = -1 ENOSPC (No space left on device)

分析:
经查,该错误是由于无法分配共享内存段引起!!
运行“free -h”,发现系统的可用内存很多; “df -h” 发现tempfs系统相关挂载点 也有很多的空间;
运行“ipcs -l” 发现【

—— Shared Memory Limits ——–
max number of segments = 4096
max seg size (kbytes) = 32780378
max total shared memory (kbytes) = 26224300
min seg size (bytes) = 1

共享内存部分,结合“lpcs -u”发现
—— Shared Memory Status ——–
segments allocated 20
pages allocated 6293514
pages resident 3661252
pages swapped 0
Swap performance: 0 attempts 0 successes

当前linux系统的“kernel.shmall = 6556075”,也就总计最大共享内存限制在24G左右,不符合预期!

解决:
修改/etc/sysctl.conf内的内核参数kernel.shmall = 65560750 (直接增加一个0 :-)
sysctl -p

附注:
1. kernel.shmmax :
是核心参数中最重要的参数之一,用于定义单个共享内存段的最大值。设置应该足够大,能在一个共享内存段下容纳下整个的 SGA , 设置的过低可能会导致需要创建多个共享内存段,这样可能导致系统性能的下降。至于导致系统下降的主要原因为在实例启动以及 ServerProcess 创建的时候,多个小的共享内存段可能会导致当时轻微的系统性能的降低 ( 在启动的时候需要去创建多个虚拟地址段,在进程创建的时候要让进程对多个段进行“识别”,会有一些影响 ) ,但是其他时候都不会有影响。

官方建议值:

32 位 linux 系统:可取最大值为 4GB ( 4294967296bytes ) -1byte ,即 4294967295 。建议值为多于内存的一半,所以如果是 32 为系统,一般可取值为 4294967295 。 32 位系统对 SGA 大小有限制,所以 SGA 肯定可以包含在单个共享内存段中。

64 位 linux 系统:可取的最大值为物理内存值 -1byte ,建议值为多于物理内存的一半,一般取值大于 SGA_MAX_SIZE 即可,可以取物理内存 -1byte 。
内存为 12G 时,该值为 12*1024*1024*1024-1 = 12884901887
内存为 16G 时,该值为 16*1024*1024*1024-1 = 17179869183
内存为 32G 时,该值为 32*1024*1024*1024-1 = 34359738367
内存为 64G 时,该值为 64*1024*1024*1024-1 = 68719476735
内存为 128G 时,该值为 128*1024*1024*1024-1 = 137438953471

2. kernel.shmall :
该参数控制可以使用的共享内存的总页数。 Linux 共享内存页大小为 4KB, 共享内存段的大小都是共享内存页大小的整数倍。

一个共享内存段的最大大小是 16G ,那么需要共享内存页数是 16GB/4KB==4194304 (页),
当内存为 12G 时, kernel.shmall = 3145728
当内存为 16G 时, kernel.shmall = 4194304
当内次为 32G 时, kernel.shmall = 8388608
当内存为 64G 时, kernel.shmall = 16777216
当内存为 128G 时, kernel.shmall = 33554432


数据运维技术 » 【异常处理】ORA-27125 unable to create shared memory segment 如何处理