ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

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

2021-08-20 01:01:38  阅读:262  来源: 互联网

标签:大页 vm hugepages echo NUM PG 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 。如调整该参数,请反复确认

标签:大页,vm,hugepages,echo,NUM,PG,Oracle,内存
来源: https://www.cnblogs.com/yaoyangding/p/15164695.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有