zoukankan      html  css  js  c++  java
  • 【大页内存】Oracle数据库配置大页内存

    【大页内存】Oracle数据库配置大页内存

    原创 Oracle 作者:xysoul_云龙 时间:2021-08-19 10:23:42  12  0

    配置大页内存

    脚本内容

    1. #!/bin/bash
    2. #
    3. # hugepages_settings.sh
    4. #
    5. # Linux bash script to compute values for the
    6. # recommended HugePages/HugeTLB configuration
    7. # on Oracle Linux
    8. #
    9. # Note: This script does calculation for all shared memory
    10. # segments available when the script is run, no matter it
    11. # is an Oracle RDBMS shared memory segment or not.
    12. #
    13. # This script is provided by Doc ID 401749.1 from My Oracle Support
    14. # http://support.oracle.com
    15. # Welcome text
    16. echo "
    17. This script is provided by Doc ID 401749.1 from My Oracle Support
    18. (http://support.oracle.com) where it is intended to compute values for
    19. the recommended HugePages/HugeTLB configuration for the current shared
    20. memory segments on Oracle Linux. Before proceeding with the execution please note following:
    21. * For ASM instance, it needs to configure ASMM instead of AMM.
    22. * The 'pga_aggregate_target' is outside the SGA and
    23. you should accommodate this while calculating the overall size.
    24. * In case you changes the DB SGA size,
    25. as the new SGA will not fit in the previous HugePages configuration,
    26. it had better disable the whole HugePages,
    27. start the DB with new SGA size and run the script again.
    28. And make sure that:
    29. * Oracle Database instance(s) are up and running
    30. * Oracle Database 11g Automatic Memory Management (AMM) is not setup
    31. (See Doc ID 749851.1)
    32. * The shared memory segments can be listed by command:
    33. # ipcs -m
    34. Press Enter to proceed..."
    35. read
    36. # Check for the kernel version
    37. KERN=`uname -r | awk -F. '{ printf("%d.%d ",$1,$2); }'`
    38. # Find out the HugePage size
    39. HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
    40. if [ -z "$HPG_SZ" ];then
    41. echo "The hugepages may not be supported in the system where the script is being executed."
    42. exit 1
    43. fi
    44. # Initialize the counter
    45. NUM_PG=0
    46. # Cumulative number of pages required to handle the running shared memory segments
    47. for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
    48. do
    49. MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
    50. if [ $MIN_PG -gt 0 ]; then
    51. NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
    52. fi
    53. done
    54. RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
    55. # An SGA less than 100MB does not make sense
    56. # Bail out if that is the case
    57. if [ $RES_BYTES -lt 100000000 ]; then
    58. echo "***********"
    59. echo "** ERROR **"
    60. echo "***********"
    61. echo "Sorry! There are not enough total of shared memory segments allocated for
    62. HugePages configuration. HugePages can only be used for shared memory segments
    63. that you can list by command:
    64. # ipcs -m
    65. of a size that can match an Oracle Database SGA. Please make sure that:
    66. * Oracle Database instance is up and running
    67. * Oracle Database 11g Automatic Memory Management (AMM) is not configured"
    68. exit 1
    69. fi
    70. # Finish with results
    71. case $KERN in
    72. '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
    73. echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
    74. '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    75. '3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    76. '3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    77. '4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    78. '4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    79. '4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    80. '5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    81. *) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
    82. esac
    83. # End

    开始配置

    1. #运行,数据库开启状态
    2. chmod +x hugepages_settings.sh
    3. ./hugepages_settings.sh
    4. # /etc/security/limits.conf 配置
    5. * soft memlock 60397977
    6. * hard memlock 60397977
    7. #/etc/sysctl.conf 配置,eg
    8. vm.nr_hugepages = 1496
    9. sysctl -p
    10. grep Huge /proc/meminfo
    11. #重启数据库

    当然也可以使用参数来锁定数据库使用的内存,以防止其他程序使用。如数据库参数use_large_pages。
    系统参数vm.hugetlb_shm_group 。如调整该参数,请反复确认

  • 相关阅读:
    为什么java使用对象序列化到文件,打开之后是乱码,而且更换编码格式查看也不能正常显示呢
    String类能够导入IDEA,但是里面的构造方法无法使用,一直显示报错
    IDEA不能提示导入java.io.File类,但是自己手写import没问题,最后找到了问题所在
    扑克牌发牌,排序的功能实现
    TFS 生成定义
    Git-tfs工具
    日期和时间
    调用惯例
    优化查找和排序
    使用更好的库
  • 原文地址:https://www.cnblogs.com/yaoyangding/p/15164695.html
Copyright © 2011-2022 走看看