linux 关于 HugePages 的配置

环境: OEL 6.5 64bit + Oracle 11.2.0.4 + 32G内存 [11GSGA]


在数据库启动中Alert日志有如下提示信息:


  1. ************************ Large Pages Information *******************
  2. Per process system memlock (soft) limit = 64 KB
  3. Total Shared Global Region in Large Pages = 0 KB (0%)
  4. Large Pages used by this instance: 0 (0 KB)
  5. Large Pages unused system wide = 0 (0 KB)
  6. Large Pages configured system wide = 0 (0 KB)
  7. Large Page size = 2048 KB
  8. RECOMMENDATION:
  9. Total System Global Area size is 11 GB. For optimal performance,
  10. prior to the next instance restart:
  11. 1. Increase the number of unused large pages by
  12. at least 5761 (page size 2048 KB, total size 11 GB) system wide to
  13. get 100% of the System Global Area allocated with large pages
  14. 2. Large pages are automatically locked into physical memory.
  15. Increase the per process memlock (soft) limit to at least 11 GB to lock
  16. 100% System Global Area\'s large pages into physical memory
  17. ********************************************************************

看来这样大的内存占用势必需要配置HugePages 提高性能。

在MY ORACLE SUPPORT 中  Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration (Doc ID 401749.1)
提供了计算 vm.nr_hugepages的具体脚本。


点击(此处)折叠或打开

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

如果配置到此,仅仅完成了第一步,在数据库启动时依然有如下提示信息:

点击(此处)折叠或打开

  1. ************************ Large Pages Information *******************
  2. Per process system memlock (soft) limit = 64 KB
  3. Total Shared Global Region in Large Pages = 0 KB (0%)
  4. Large Pages used by this instance: 0 (0 KB)
  5. Large Pages unused system wide = 5764 (11 GB)
  6. Large Pages configured system wide = 5764 (11 GB)
  7. Large Page size = 2048 KB
  8. RECOMMENDATION:
  9. Total System Global Area size is 11 GB. For optimal performance,
  10. prior to the next instance restart:
  11. 1. Large pages are automatically locked into physical memory.
  12. Increase the per process memlock (soft) limit to at least 11 GB to lock
  13. 100% System Global Area\'s large pages into physical memory
  14. ********************************************************************
根据提示需要将分配的内存Lock 在屋里内存中。

可以参考 MY ORACLE SUPPORT 中   HugePages on Oracle Linux 64-bit (Doc ID 361468.1)

配置  /etc/security/limits.conf 文件

点击(此处)折叠或打开

  1. soft memlock ******
  2. hard memlock ******
其中具体数值需要大于SGA大小。
至此配置完成,重新启动后,Alert日志出现以下内容:

点击(此处)折叠或打开

  1. ************************ Large Pages Information *******************
  2. Per process system memlock (soft) limit = 12 GB
  3. Total Shared Global Region in Large Pages = 11 GB (100%)
  4. Large Pages used by this instance: 5761 (11 GB)
  5. Large Pages unused system wide = 3 (6144 KB)
  6. Large Pages configured system wide = 5764 (11 GB)
  7. Large Page size = 2048 KB
  8. ********************************************************************

下面图片详细解释了HugePages





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

转载于:http://blog.itpub.net/28538954/viewspace-1344834/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值