设为首页 收藏本站
查看: 874|回复: 0

[经验分享] 在Linux 中为oracle配置hugepage的方法

[复制链接]

尚未签到

发表于 2018-9-13 10:56:55 | 显示全部楼层 |阅读模式
  在Linux中配置hugepage可以提高oracle的性能,减少oracle sga的页交换,类似于aix中的largepage。
  下面演示配置hugepage的方法。
  系统环境:
  OS:CentOS6.4 64bit
  Oracle:10.2.0.5
  配置过程
  检查hugepagesize
[oracle@ehrtest ~]$ grep Hugepagesize /proc/meminfo  Hugepagesize:       2048 kB
  查看默认hugepage的值
  nr_hugepages的计算公式:nr_hugepages >= sga(mb)/Hugepagesize(mb)
  [oracle@ehrtest ~]$ sysctl -a|grep nr_huge
  vm.nr_hugepages = 0
  检查hugepage的分配情况
[oracle@ehrtest ~]$ grep HugePages_Total /proc/meminfo  HugePages_Total:       0
使用oracle 提供的脚本计算出系统最佳值  [oracle@ehrtest ~]$ sh auto_vm_huge.sh
  This script is provided by Doc ID 401749.1 from My Oracle Support
  (http://support.oracle.com) where it is intended to compute values for
  the recommended HugePages/HugeTLB configuration for the current shared
  memory segments. Before proceeding with the execution please note following:
  * For ASM instance, it needs to configure ASMM instead of AMM.
  * The 'pga_aggregate_target' is outside the SGA and
  you should accommodate this while calculating SGA size.
  * In case you changes the DB SGA size,
  as the new SGA will not fit in the previous HugePages configuration,
  it had better disable the whole HugePages,
  start the DB with new SGA size and run the script again.
  And make sure that:
  * Oracle Database instance(s) are up and running
  * Oracle Database 11g Automatic Memory Management (AMM) is not setup
  (See Doc ID 749851.1)
  * The shared memory segments can be listed by command:
  # ipcs -m
  Press Enter to proceed...
  Recommended setting: vm.nr_hugepages = 482
配置oracle用户的memlock  需要修改/etc/security/limits.conf文件,加入标记为红色的两行
  计算公式为:>=HugePages_Total×1024,我这里设置了2倍的值,即:2×50×1024=102400
ora_test@root[/root]> cat /etc/security/limits.conf|grep lock  # - memlock - max locked-in-memory address space (KB)
  # - locks - max number of file locks the user can hold
  oracle soft memlock 102400
  oracle hard memlock 102400
  检查memlock情况
  切换到oracle用户身份,使用ulimit -l命令检查memlock情况
ora_test@root[/root]> su - oracle  ora_test@oracle[/home/oracle]> ulimit -l
  102400
  启动数据库
ora_test@oracle[/home/oracle]> sqlplus / as sysdba  SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 25 09:50:33 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  Connected to an idle instance.
  idle> startup
  ORACLE instance started.
  Total System Global Area 167772160 bytes
  Fixed Size 1218292 bytes
  Variable Size 67111180 bytes
  Database Buffers 92274688 bytes
  Redo Buffers 7168000 bytes
  Database mounted.
  Database opened.
  idle> exit
  Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
  With the Partitioning, OLAP and Data Mining options
  检查是否已经使用了hugepage
ora_test@oracle[/home/oracle]> grep HugePages_Free /proc/meminfo  HugePages_Free: 30
  这里显示剩余的hugepage为30,小于HugePages_Total(50),证明oracle已经使用了hugepage
  --end--
  为何oracle一起来,系统就会有swap?
  db是11g,total memory 是16g ,swap 是8g,分给sga_target=8g,pga_aggregate_target=3g.按理说,这个内存分配也不会导致oracle吞噬过多内存导 致系统发生swap,可现在只要db起来,用vmsta 命令观察就会出现swap, 类似如下。
  procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
  r b swpd free buff cache si so  bi  bo in cs us sy id wa st
  0 0 168524 87336  340 26356 128 3014 178 3054 1305 417 0 1 94 5 0
  0 3 168524 81336  480 29052 1798  0 3166 8 1243 687 0 0 94 6 0
  0 0 171024 85292  496 28984 880 1500 1176 1500 1225 612 0 0 89 11 0
  0 0 171024 85292  496 28960 24  0  24 0 1055 348 0 0 99 0 0
  0 3 172284 81960  512 34860 372 1158 430 1230 1307 1496 0 2 94 4 0
  0 1 167072 84424  320 38828 1564 210 1716 230 1545 2796 0 3 85 12 0
  0 1 167072 84008  340 39152 286  0 362  18 1115 504 0 0 96 4 0
  0 0 167072 83764  352 39392 34  0  94 6 1069 344 0 0 99 0 0
  0 0 167072 83764  352 39580 32  0  32 0 1072 347 0 0 100 0 0
  0 0 167072 82896  352 39568 410  0 410 0 1075 367 0 0 99 1 0
  我看了alert log,没有其他报错。现在系统非常慢,大伙帮我分析分析。
  QUOTE:
原帖由 oracle_kai 于 2010-12-7 18:28 发表 http://www.itpub.net/images/common/back.gif  系统使用的就是hugepage,但问题也就出现在hugepage 参数的设置上面。
  原先vm.nr_hugepages = 41984
  cat /proc/memory|grep HugePages_Total
  HugePages_Total=7925
  7925*2m 几乎就是整个os内存了。
  后来修改该参数,参考sga=8g,所以新设vm.nr_hugepages =4096
  重启机器,oracle起来后memory swap 消失,系统反应也正常。
  #!/bin/bash
  #
  # hugepages_settings.sh
  #
  # Linux bash script to compute values for the
  # recommended HugePages/HugeTLB configuration
  #
  # Note: This script does calculation for all shared memory
  # segments available when the script is run, no matter it
  # is an Oracle RDBMS shared memory segment or not.
  #
  # This script is provided by Doc ID 401749.1 from My Oracle Support
  # http://support.oracle.com
  # Welcome text
  echo "
  This script is provided by Doc ID 401749.1 from My Oracle Support
  (http://support.oracle.com) where it is intended to compute values for
  the recommended HugePages/HugeTLB configuration for the current shared
  memory segments. Before proceeding with the execution please make sure
  that:
  * Oracle Database instance(s) are up and running
  * Oracle Database 11g Automatic Memory Management (AMM) is not setup
  (See Doc ID 749851.1)
  * The shared memory segments can be listed by command:
  # ipcs -m
  Press Enter to proceed..."
  read
  # Check for the kernel version
  KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
  # Find out the HugePage size
  HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
  # Initialize the counter
  NUM_PG=0
  # Cumulative number of pages required to handle the running shared memory segments
  for SEG_BYTES in `ipcs -m | awk '{print $5}' | grep "[0-9][0-9]*"`
  do
  MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
  if [ $MIN_PG -gt 0 ]; then
  NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
  fi
  done
  RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
  # An SGA less than 100MB does not make sense
  # Bail out if that is the case
  if [ $RES_BYTES -lt 100000000 ]; then
  echo "***********"
  echo "** ERROR **"
  echo "***********"
  echo "Sorry! There are not enough total of shared memory segments allocated for
  HugePages configuration. HugePages can only be used for shared memory segments
  that you can list by command:
  # ipcs -m
  of a size that can match an Oracle Database SGA. Please make sure that:
  * Oracle Database instance is up and running
  * Oracle Database 11g Automatic Memory Management (AMM) is not configured"
  exit 1
  fi
  # Finish with results
  case $KERN in
  '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
  echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
  '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  *) echo "Unrecognized kernel version $KERN. Exiting." ;;
  esac
  # End


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-577684-1-1.html 上篇帖子: Oracle 监听无法启动。已解决 下篇帖子: Oracle HTTP 乱码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表