zoukankan      html  css  js  c++  java
  • linux7.4开启hugepages

    环境检查

    数据库内存超过4G时,使用dbca建库默认选项AMM是关闭的,内存超过8G时,oracle推荐使用hugepages,它可以将部分数据锁定在内存中,处理效率比较高、性能好。

    确认服务器物理内存已经超过8G,是大内存

    确认数据库实例没有使用AMMhugepagesAMM不同时使用

    Memlock

    如果/etc/security/limits.d/*.conf中没有关于memlock参数的设置,那么

    memlock的值介于SGA与物理内存之间,比SGA大,比物理内存小

    推荐值SGA+PGA为物理内存80%memlock为物理内存90%

    Memlock = 物理内存*90%*1024*1024

    vim /etc/security/limits.conf

    oracle soft memlock 237363200

    oracle hard memlock 237363200

    # su - oracle

    $ ulimit -l

    237363200

    脚本获取推荐值

    chmod +x hugepages_settings.sh

    [root@crcsn1 scripts]# ./hugepages_settings.sh

    This script is provided by Doc ID 401749.1 from My Oracle Support

    (http://support.oracle.com) where it is intended to compute values for

    the recommended HugePages/HugeTLB configuration for the current shared

    memory segments on Oracle Linux. Before proceeding with the execution please note following:

     * For ASM instance, it needs to configure ASMM instead of AMM.

     * The 'pga_aggregate_target' is outside the SGA and

       you should accommodate this while calculating SGA size.

     * In case you changes the DB SGA size,

       as the new SGA will not fit in the previous HugePages configuration,

       it had better disable the whole HugePages,

       start the DB with new SGA size and run the script again.

    And make sure that:

     * Oracle Database instance(s) are up and running

     * Oracle Database 11g Automatic Memory Management (AMM) is not setup

       (See Doc ID 749851.1)

     * The shared memory segments can be listed by command:

         # ipcs -m

    Press Enter to proceed...

    Recommended setting: vm.nr_hugepages = 72708

    [root@crcsn1 scripts]# ipcs -m

    ------ Shared Memory Segments --------

    key        shmid      owner      perms      bytes      nattch     status      

    0x00000000 1245184    grid       600        4096       0                       

    0x00000000 1277953    grid       600        4096       0                       

    0x4dfc72ac 1310722    grid       600        24576      48                      

    0x00000000 1343491    grid       600        8802304    124                     

    0x00000000 1376260    grid       600        1056964608 62                      

    0x00000000 1409029    grid       600        7974912    62                      

    0xef940690 1441798    grid       600        20480      62                      

    0x00000000 2129927    oracle     600        30035968   614                     

    0x00000000 2162696    oracle     600        150860726272 307                     

    0x00000000 2195465    oracle     600        506834944  307                     

    0x51c60604 2228234    oracle     600        24576      307

    设置hugepages

    # vim /etc/sysctl.conf

    vm.nr_hugepages = 72708

    # sysctl -p

    # grep HugePages /proc/meminfo

    AnonHugePages:   1093632 kB

    HugePages_Total:   61313

    HugePages_Free:    61313

    HugePages_Rsvd:        0

    HugePages_Surp:        0

    附件

    hugepages_settings.sh

    #!/bin/bash

    #

    # hugepages_settings.sh

    #

    # Linux bash script to compute values for the

    # recommended HugePages/HugeTLB configuration

    # on Oracle Linux

    #

    # Note: This script does calculation for all shared memory

    # segments available when the script is run, no matter it

    # is an Oracle RDBMS shared memory segment or not.

    #

    # This script is provided by Doc ID 401749.1 from My Oracle Support

    # http://support.oracle.com

    # Welcome text

    echo "

    This script is provided by Doc ID 401749.1 from My Oracle Support

    (http://support.oracle.com) where it is intended to compute values for

    the recommended HugePages/HugeTLB configuration for the current shared

    memory segments on Oracle Linux. Before proceeding with the execution please note following:

     * For ASM instance, it needs to configure ASMM instead of AMM.

     * The 'pga_aggregate_target' is outside the SGA and

       you should accommodate this while calculating SGA size.

     * In case you changes the DB SGA size,

       as the new SGA will not fit in the previous HugePages configuration,

       it had better disable the whole HugePages,

       start the DB with new SGA size and run the script again.

    And make sure that:

     * Oracle Database instance(s) are up and running

     * Oracle Database 11g Automatic Memory Management (AMM) is not setup

       (See Doc ID 749851.1)

     * The shared memory segments can be listed by command:

         # ipcs -m

    Press Enter to proceed..."

    read

    # Check for the kernel version

    KERN=`uname -r | awk -F. '{ printf("%d.%d ",$1,$2); }'`

    ...skipping...

    for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`

    do

        MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`

        if [ $MIN_PG -gt 0 ]; then

            NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`

        fi

    done

    RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`

    # An SGA less than 100MB does not make sense

    # Bail out if that is the case

    if [ $RES_BYTES -lt 100000000 ]; then

        echo "***********"

        echo "** ERROR **"

        echo "***********"

        echo "Sorry! There are not enough total of shared memory segments allocated for

    HugePages configuration. HugePages can only be used for shared memory segments

    that you can list by command:

        # ipcs -m

    of a size that can match an Oracle Database SGA. Please make sure that:

     * Oracle Database instance is up and running

     * Oracle Database 11g Automatic Memory Management (AMM) is not configured"

        exit 1

    fi

    # Finish with results

    case $KERN in

        '2.2') echo "Kernel version $KERN is not supported. Exiting." ;;

        '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;

               echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;

        '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

        '3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

        '3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

        '4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

    esac

    # End

    参考

    1. HugePages on Oracle Linux 64-bit (文档 ID 361468.1)
    2. Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration (文档 ID 401749.1)
  • 相关阅读:
    paste 合并文件
    split 分割文件
    cut 从文本中提取一段文字并输出
    tailf 跟踪日志文件
    tail 显示文件内容尾部
    给Linux系统新增加一块硬盘
    Centos7+httpd+fastcgi安装提示错误
    Redhat 7使用CentOS 7的Yum网络源
    windows7下cmd窗口使用ssh命令
    PHP set_error_handler() 函数
  • 原文地址:https://www.cnblogs.com/automng/p/8890430.html
Copyright © 2011-2022 走看看