ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux HugePages / HugeTLB Configuration

Linux HugePages / HugeTLB Configuration

Linux操作系统 作者:_JustDoIt_ 时间:2016-09-06 14:29:29 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 SGA 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\n",$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.2') echo "Kernel version $KERN is not supported. Exiting." ;;
  73. '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
  74. echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
  75. '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  76. '3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  77. '3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  78. '4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  79. esac
  80. # End

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

下一篇: 厚积,而后薄发
请登录后发表评论 登录
全部评论

注册时间:2016-03-15

  • 博文量
    28
  • 访问量
    26065