ITPub博客

首页 > 数据库 > Oracle > Linux 内核参数 和 Oracle相关参数调整

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

Oracle 作者:General_715 时间:2014-12-05 16:52:06 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

       http://blog.csdn.net/tianlesoftware/archive/2011/05/16/6424945.aspx

 

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

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

       http://blog.csdn.net/tianlesoftware/archive/2010/11/17/6013777.aspx

 

       安装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 小与SGA,Oracle 会创建多个共享内存段,我们可以使用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-max为512 乘以 processes。

       如128个process,则file-max=512*128=65536。

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

下一篇: SGA_TARGET
请登录后发表评论 登录
全部评论

注册时间:2013-12-08

  • 博文量
    41
  • 访问量
    132419