ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux 内核参数 和 Oracle相关参数调整

Linux 内核参数 和 Oracle相关参数调整

原创 Linux操作系统 作者:roominess 时间:2012-03-31 15:51:50 0 删除 编辑

Linux 内核参数的大小和Oracle 有很大的关闭,比如ORA-27102的错误,就是因为内核参数的大小不当造成。具体参考Blog

       Upon startup of Linux database get ORA-27102: out of memory Linux-X86_64 Error: 28: No space left on device

       

Upon startup of Linux database get ORA-27102: out of memory Linux-X86_64 Error: 28: No space left on device [ID 301830.1]

 

Applies to:

Oracle Server - Enterprise Edition - Version: 9.2.0.4 to 11.2.0.2 - Release: 9.2 to 11.2
Red Hat Enterprise Linux Advanced Server x86-64 (AMD Opteron Architecture)
x86 64 bit (for Enterprise Linux only)
SUSE / UnitedLinux x86-64

Symptoms

When trying to increase the SGA to approach half available RAM with an Oracle 64bit version on a Linux 64bit operating system, even though shmmax is set to match half the amount of RAM, you get the following error when trying to start the instance:

SQL> startup nomount 
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device

Changes

shmall is too small, most likely is set to the default setting of 2097152

$ cat /proc/sys/kernel/shmall
2097152

Cause

shmall is the total amount of shared memory, in pages, that the system can use at one time.

Solution

Set shmall equal to the sum of all the SGAs on the system, divided by the page size.

The page size can be determined using the following command:

$ getconf PAGE_SIZE 
4096

For example, if the sum of all the SGAs on the system is 16Gb and the result of '$ getconf PAGE_SIZE' is 4096 (4Kb) then set shmall to 4194304 pages

As the root user set the shmall to 4194304 in the /etc/sysctl.conf file:

kernel.shmall = 4194304

then run the following command:

# sysctl -p
# cat /proc/sys/kernel/shmall
4194304

NOTE:

The above command loads the new value and a reboot is not necessary

Switch back to being the oracle user and retry the startup command.

 

Oracle 11gR2 里也有一个类似的问题:

       Oracle 11gR2 RAC ORA-00845 MEMORY_TARGET not supported on this system 解决方法

       公司刚上线一套Oracle 11gR2 RAC MEMORY_TARGET内存设置为12G后,启动的时候报了错误:

       ORA-00845: MEMORY_TARGET not supported on this system

 

 

00845, 00000, "MEMORY_TARGET not supported on this system"

// *Cause: The MEMORY_TARGET parameter was not supported on this operating system or /dev/shm was not sized correctly on Linux.

// *Action: Refer to documentation for a list of supported operating systems. Or, size /dev/shm to be at least the SGA_MAX_SIZE on each Oracle instance running on the system.

 

 

Oracle 11g里,通过MEMORY_TARGET参数自动管理SGAPGA 但是在Oracle 11gR2 里如果MEMORY_TARGET参数值设定的过大,可能就会出现这个错误。

 

 

解决方法:增加/dev/shm, /dev/shm通常用做共享内存。

 

 /dev/shm是一个临时文件系统(tmpfs) 。 从/etc/fstab中mount支持标准的参数"size",可以用size来增加或者减少在/dev/shm上的tmpfs大小.如果没有设置size,它的大小大于MEMORY_TARGET。

 

如果想立即生效,方法如下:

# umount tmpfs

# mount -t tmpfs shmfs -o size=14G /dev/shm

 

让以后每次重启OS 都自动mount,修改文件 /etc/fstab 将tmpfs 修改成以下值:

 tmpfs            /dev/shm        tmpfs  defaults,size=14G        0 0

 

如果直接修改/etc/fstab,通过重启OS 也可以让参数生效。

 

注意:这个size 的大小需要设置为整数。

 

df -h 在查查修改后的/dev/shm的大小

 

文件系统              容量  已用 可用 已用挂载点

/dev/mapper/vg00-lv_root

                       20G   11G  7.7G  59% /

/dev/mapper/vg00-lv_home

                       97G  6.8G   86G   8% /home

/dev/sda1              97M   13M   80M  14% /boot

tmpfs                  14G     0   14G   0% /dev/shm

 

 

 

 

 

Oracle 官网的说明:

 

 

ORA-00845 When Starting Up An 11g Instance With AMM Configured. [ID 460506.1]


 

Modified 18-FEB-2010     Type PROBLEM     Status PUBLISHED

 

In this Document
  Symptoms
  Changes
  Cause
  Solution
  References


Applies to:

Oracle Server - Enterprise Edition - Version: 11.1.0.6 to 11.2.0.2.0 - Release: 11.1 to 11.2
Linux x86
Linux x86-64

Symptoms


On a Linux system, trying to start up an 11g instance could fail with the following error:

ORA-845: MEMORY_TARGET not supported on this system

In the alert log, you could or could not see the below messages:

ORA-04031 errors 

OR

Starting ORACLE instance (normal)
WARNING: You are trying to use the MEMORY_TARGET feature.
This feature requires the /dev/shm file system to be mounted for at
Least bytes.The /dev/shm is either not mounted or is mounted
With available space less than this size.
Please fix this so that MEMORY_TARGET can work as expected.
Current available is and used is bytes.memory_target needs larger /dev/shm 

If ORA-04031 is seen in the alert log, sometimes you can not establish new connections due to this problem.

Changes

Installed 11g, or created a new database on 11g and is starting to use the AMM (Automatic Memory Management) feature.

Cause

This feature requires the /dev/shm file system to be mounted for at least %llu bytes.
/dev/shm is either not mounted or is mounted with available space less than this size.

Explanation:

AMM (Automatic Memory Management) is a new feature in 11 which manages both SGA and PGA.

MEMORY_TARGET is used instead of SGA_TARGET and MEMORY_MAX_TARGET is used instead of SGA_MAX_SIZE (defaults to MEMORY_TARGET ).

It uses /dev/shm on Linux. If max_target set over /dev/shm size, you get the error messages.

Solution

1. If you are installing Oracle 11g on a Linux system, note that Memory Size (SGA and PGA), which sets 
the initialization parameter MEMORY_TARGET or MEMORY_MAX_TARGET, cannot be greater than the shared memory filesystem (/dev/shm) on your operating system. To resolve the current error, increase the /dev/shm file size. For example:

# mount -t tmpfs shmfs -o size=7g /dev/shm

Also, to make this change persistent across system restarts, add an entry in /etc/fstab similar to the following:

shmfs /dev/shm tmpfs size=7g 0

2. This error may also occur if /dev/shm is not properly mounted. Make sure your df output is similar to the following:

$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
...
shmfs 6291456 832356 5459100 14% /dev/shm

3. If configuring AMM is not possible due to lack of space on /dev/shm mount point, you can configure ASMM instead of AMM, i.e. set SGA_TARGET, SGA_MAX_SIZE and PGA_AGGREGATE_TARGET instead of MEMORY_TARGET.

 

 

 

 

HugePages and Oracle Database 11g Automatic Memory Management (AMM) on Linux [ID 749851.1]


 

Modified 05-NOV-2010     Type BULLETIN     Status PUBLISHED

 

In this Document
  Purpose
  Scope and Application
  HugePages and Oracle Database 11g Automatic Memory Management (AMM) on Linux
  References


Applies to:

Oracle Server - Enterprise Edition - Version: 11.1.0.6 and later   [Release: 11.1 and later ]
Linux OS - Version: 2.6 and later ]
Linux x86
IBM: Linux on System z
IBM: Linux on POWER Systems
IBM S/390 Based Linux (31-bit)
Linux x86-64
Linux Itanium

Purpose

This document discusses the interoperability of the Automatic Memory Management (AMM) feature introduced by Oracle DB 11g and the HugePages (HugeTLB) feature of the Linux OS kernel.

Scope and Application

This document is to be used by Linux system administrators and Oracle database administrators that work with Oracle Database Server 11g on Linux Operating System.

HugePages and Oracle Database 11g Automatic Memory Management (AMM) on Linux

The 11g AMM feature is enabled by the MEMORY_TARGET / MEMORY_MAX_TARGET instance initialization parameters (see Note 460506.1 for further information). That is also the case with a default database instance created using Database Configuration Assistant (DBCA).

With AMM all SGA memory is allocated by creating files under /dev/shm. When Oracle DB does SGA allocations that way HugePages are not reserved/used. The use of AMM is absolutely incompatible with HugePages.

Please also note that ramfs (instead of tmpfs mount over /dev/shm) is not supported for AMM at all. With AMM the Oracle database needs to grow and reduce the size of SGA dynamically. This is not possible with ramfs where it possible and supported with tmpfs (which is the default for the OS installation).

If you want to use HugePages make sure that both MEMORY_TARGET / MEMORY_MAX_TARGET initialization parameters are disabled (set to 0) for the database instance.(See also Oracle
 Database Administrator's Guide 11g)

References

NOTE:460506.1 - ORA-00845 When Starting Up An 11g Instance With AMM Configured.

Related


Products


  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Server - Enterprise Edition
  • Unbreakable Linux and Virtualization > Unbreakable Linux > Operating System > Linux OS

Keywords


HUGETLB; HUGEPAGES; DATABASE CONFIGURATION ASSISTANT; DBCA

 

       安装Oracle的时候,可以参考Oracle 的安装文档,来设置相关的值,但是有些参数的值还是需要根据我们自己的情况来进行调整。

 

 

1.  Linux 系统下的核心参数

# vi /etc/sysctl.conf

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 65536

net.ipv4.ip_local_port_range = 9000 65000

net.core.rmem_default = 4194304

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 262144

 

该参数保存在/etc/sysctl.conf 下,修改该文件不需要重启OS,只需要使用如下命令:

# /sbin/sysctl -p

 

就可以让修改的参数生效。

 

 

2.  kernel.shmmax 参数

2.1 说明

       SHMMAX Available physical memory Defines the maximum allowable size of one shared memory segment. The SHMMAX setting should be large enough to hold the entire SGA in one shared memory segment. A low setting can cause creation of multiple shared memory segments which may lead to performance degradation.

 

       Shmmax 是核心参数中最重要的参数之一,用于定义单个共享内存段的最大值,shmmax 设置应该足够大,能在一个共享内存段下容纳下整个的SGA ,设置的过低可能会导致需要创建多个共享内存段,这样可能导致系统性能的下降 。

       SHMMAX 仅仅是在共享内存段被创建的时候用来比较的一个数字,当共享内存段被一个进程(Process)创建,操作系统检查是否被要求的共享内存段的值大于shmmax 的值 ,如果是,那么将会抛出一个错误。这个时候系统会创建另外的一个或多个共享内存段满足进程的需求 。一般来说,共享内存段个数和系统性能没有太直接的关系,也不会对性能产生太大的影响。

 

       在实例启动以及Server Process 创建的时候,多个小的共享内存段可能会导致当时轻微的系统性能的降低(在启动的时候 需要去创建多个虚拟地址段,在进程创建的时候要让进程对多个段进行“识别”,会有一些影响),但是其他时候都不会有影响。这意味着如果你的程序不是经常Create Processes(以及Destroy Them,性能方面就不是考虑的问题。

 

     Oralce 建议 SHMMAX > SGA(SGA_MAX_SIZE),这样在任何时候都不会有甚至轻微的性能下降的隐患。

 

2.2 示例

       在上节说了,如果shmmax 小与SGAOracle 会创建多个共享内存段,我们可以使用Ipcs -sa 查看看到共享内存段个数。

 

1)查看

[root@rac01 ~]# cat /etc/sysctl.conf | grep kernel.shmmax
kernel.shmmax = 20971520
[root@rac01 ~]# ipcs -sa

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status 
0x00000000 65537 oracle 640 4194304 27 
0x00000000 98306 oracle 640 20971520 27 
0x00000000 131075 oracle 640 20971520 27 
0x00000000 163844 oracle 640 20971520 27 
0x00000000 196613 oracle 640 20971520 27 
0x00000000 229382 oracle 640 20971520 27 
0x00000000 262151 oracle 640 20971520 27 
0x00000000 294920 oracle 640 20971520 27 
0xd2776b04 327689 oracle 640 20971520 27 

------ Semaphore Arrays --------
key semid owner perms nsems 
0xfafd7074 360449 oracle 640 104 

------ Message Queues --------
key msqid owner perms used-bytes messages

因为kernel.shmmax设置过小,导致分配了多个共享内存段。


下边改大一些:
[root@rac01 ~]# cat /etc/sysctl.conf | grep kernel.shmmax
kernel.shmmax = 2147483648
[root@rac01 ~]# sysctl -p
[root@rac01 ~]# su - oracle
[oracle@rac01 ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 16 05:50:00 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Oracle Label Security, OLAP
and Data Mining Scoring Engine options

SQL> startup force
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 104859892 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Oracle Label Security, OLAP
and Data Mining Scoring Engine options

再看一下:
[root@rac01 ~]# ipcs -sa

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status 
0xd2776b04 360449 oracle 640 171966464 27 

------ Semaphore Arrays --------
key semid owner perms nsems 
0xfafd7074 491521 oracle 640 104 

------ Message Queues --------
key msqid owner perms used-bytes messages
只有一个内存段分配了

 

3.  kernel.shmall

 

       kernel.shmall 参数是控制共享内存页数。该参数大小为物理内存除以pagesize;

 

查看os系统页的大小

#getconf PAGESIZE

4096

 

       这里显示的pagesize 4k假设一个共享内存段的最大大小是16G,那么需要共享内存页数是 16GB/4KB=16777216KB/4KB=4194304 (页),也就是64Bit 系统下16GB 物理内存,设置 kernel.shmall = 4194304 才符合要求,几乎是原来设置2097152的两倍。

 

 

4. kernel.shmmni 参数

       shmmni 内核参数是共享内存段的最大数量(注意这个参数不是 shmmin,

shmmni, shmmin 表示内存段最小大小 )。shmmni 缺省值 4096 ,一般肯定是够用了。

 

 

5. fs.file-max 参数

       fs.file-max512 乘以 processes

       128process,则file-max=512*128=65536

 

 

6.  Oracle 下需要做调整的参数

 

       Oracle 10g 中引入了一个非常重要的参数:SGA_TARGET这也是Oracle 10g的一个新特性。自动共享内存管理(Automatic Shared Memory Management ASMM),控制这一特性的,就仅仅是这个参数SGA_TARGE。设置这个参数后,你就不需要为每个内存区来指定大小了。SGA_TARGET 指定了SGA 可以使用的最大内存大小,而SGA 中各个内存的大小由Oracle 自行控制,不需要人为指定。

       Oracle 可以随时调节各个区域的大小,使之达到系统性能最佳状态的个最合理大小,并且控制他们之和在SGA_TARGET 指定的值之内。一旦给SGA_TARGET 指定值后(默认为0,即没有启动ASMM),就自动启动了ASMM

特性。

 

       10g 下设置 SGA_TARGET 之后启动ASSM 特性之后, 只有以下的这些区的内存大小动态共享起来:

* Buffer cache (DB_CACHE_SIZE)

* Shared pool (SHARED_POOL_SIZE)

* Large pool (LARGE_POOL_SIZE)

* Java pool (JAVA_POOL_SIZE)

* Streams pool (STREAMS_POOL_SIZE)

 

       SGA 中的其他区域的内存大小仍然是固定不共享的。它的含义和SGA_MAX_SIZE 的一样,也表示SGA 最大的大小,于是它也就有了一个限制,那就是它的大小不能大于SGA_MAX_SIZE 的大小。

       Oracle10g 下, SGA_MAX_SIZE 仍然表示SGA 的大小的上限值,而SGA_TARGET SGA 的所有组件的大小的最大值之和,即当SGA_TARGET< SGA_MAX_SIZE 的时候,oracle 就会忽略SGA_MAX_SIZE 的值,SGA_TARGET 也就成了SGA 的在此实例中的上限制,它能动态改变大小,但是不能够大于SGA_MAX_SIZE 的值。

 

       SGA_TARGET< SGA_MAX_SIZE 时,实例重启以后SGA_MAX_SIZE 就变成SGA_TARGET 的大小了。

 

       11g 中,这个SGA_TARGET 只能设置是等于SGA_MAX_SIZE 的大小了,设置比它小,oracle 会自动帮你调整,设置比它大,那还是出错。现在可以自己想想,oracleSGA_TARGET 的大小处理在往正确的简单的方向前进中。

 

       SGA_TARGET 带来一个重要的好处就是,能使SGA 的利用率达到最佳,从而节省内存成本。因为ASMM 启动后,Oracle 会自动根据需要调整各个区域的大小,大大减少了某些区域内存紧张,而某些区域又有内存空闲的矛盾情况出现。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15880878/viewspace-720056/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-24

  • 博文量
    118
  • 访问量
    186209