【大頁內存】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\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.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 。如調整該參數,請反復確認


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM