Linux 内核参数优化(for Oracle)


Oracle 不同平台的数据库安装指导为我们部署Oracle提供了一些系统参数设置的建议值,然而建议值是在通用的情况下得出的结论,并非能完全满足不同的需求。使用不同的操作系统内核参数将使得数据库性能相差甚远。本文描述了linux下几个主要内核参数的设置,供参考。


1、Linux共享内存
  共享内存是在系统内核分配的一块缓冲区,多个进程都可以访问该缓冲区。
  由于进程可以直接读写内存,避免了在内核空间与用户空间的切换,所以共享内存读写效率很高。
  当一个进程改变了这块地址中的内容的时候,其它进程都会察觉到这个更改。共享内存类似与windows环境编程中的内存映像文件。

  Linux的IPC(Interprocess Communication)通信机制:是指多个进程之间相互通信,交换信息的方法。
  通过使用共享内存允许两个或多个进程共享一定的存储区,因为不需要拷贝数据。
  Oracle SGA即是基于此方式来实现Oracle进程之间数据共享。因此SGA的合理设置对Oracle性能有重大的影响。
  可以通过ipcs -lm来查看所有的共享内存设置。

 

2、参数修改的方式
  由于Linux的内核参数信息都存在内存中,因此可以通过命令直接修改,并且修改后直接生效。
    但是,当系统重新启动后,原来设置的参数值就会丢失,而系统每次启动时都会自动去/etc/sysctl.conf文件中读取内核参数。
  如果是临时修改,则可以采用echo或sysctl -w方式,如果永久修改,建议修改sysctl.conf文件
  下面是几种参数修改方式的描述
  a、echo 方式
    echo <value> > <file_name> 
    将值输出到文件,该方式使得内核参数修改立即生效,无需重启系统,但重启后失效(以sysctl.conf永久配置文件为准)
  b、sysctl 命令方式   
    sysctl -w <parameter_name>=<value>
    使用sysctl 命令行方式是修改的运行时的内核参数,参数值当重启后失效,同上
  c、永久性更改
    vi /etc/sysctl.conf  #直接修改对应参数的值,然后执行命令使更改立即生效# sysctl -p
    echo "kernel.shmmax=2147483648" >> /etc/sysctl.conf  #不太建议该方式,这样子同一参数会有多个值出现在sysctl.conf

 

3、sysctl.conf配置文件
  几乎所有的重要参数都保持在sysctl.conf配置文件中,因此对于永久性修改,直接修改该文件是最简单不过的方式了
  下面是基于x86_64 RHEL5 下Oracle 给出的参数建议值

  Oracle10gR2 On RHEL 5/OEL 5 (x86_64) [ID 421308.1]
    kernel.shmall = physical RAM size / pagesize
      For most systems, this will be the value 2097152. See Note 301830.1 for more information.
    kernel.shmmax = 1/2 of physical RAM.
      This would be the value 2147483648 for a system with 4Gb of physical RAM. See Note 567506.1 for more information.
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    fs.file-max = 512 x processes (for example 65536 for 128 processes)
    Development recommends a minimum of 327679 for active systems.
    net.ipv4.ip_local_port_range = 9000 65500
    (The runInstaller (OUI) checks may expect this to be the old guidance of 1024 65000.
    The new guidance from Oracle development is 9000 65500.
    Please allow the runInstaller (OUI) to proceed with the new guidance from Oracle development.)
    net.core.rmem_default = 262144
    net.core.rmem_max = 2097152
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576
 
  Oralce 11g R2 on RHEL (and OEL) 5 on AMD64/EM64T [ID 880989.1]   
    kernel.shmall = physical RAM size / pagesize
      For most systems, this will be the value 2097152. See Note 301830.1 for more information.
      kernel.shmmax = 1/2 of physical RAM.
        This would be the value 2147483648 for a system with 4Gb of physical RAM.
      kernel.shmmni = 4096
      kernel.sem = 250 32000 100 128
      fs.file-max = 512 x processes (for example 6815744 for 13312 processes)
      fs.aio-max-nr = 1048576
      net.ipv4.ip_local_port_range = 9000 65500
      net.core.rmem_default = 262144
      net.core.rmem_max = 4194304
      net.core.wmem_default = 262144
      net.core.wmem_max = 1048576
 
  对于Oracle 11g,Oracle建议如果系统当前设置的值大于上述列出的值,则无需修改,保留原值。
  从上面可知,sysctl.conf包含了所有的内核参数文件,且以kernel开头,下面对这几个重要参数进行逐一描述。

  • 1
  • 2
  • 3
  • 4
  • 5
  • 下一页

相关内容