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

[经验分享] linux的hugepage的配置-优化oracle内存 .

[复制链接]

尚未签到

发表于 2016-2-24 08:48:31 | 显示全部楼层 |阅读模式
  linux的hugepage的配置
  
  linux虽然没有aix,hp unix那么强悍,但linux也是非常优秀的,为了提升linux的性能,它采用了很多
io,memory的调度机制,linux使用内存的方式是采用vm的方式,即linux把物理内存和swap共同虚拟成
内存来对外提供,有时用户看似使用内存,可实际上是使用磁盘,那如何避免使用swap磁盘空间呢?
  linux管理内存的单位是页(pages),一般情况下是4k的page,当我们使用的大内存时(>8G),管理这么大的内存
就会给系统造成很大的负担,再加上频繁的pagein/pageout,会成为系统的瓶颈。
  
  1.hugepage介绍
2.实践配置

  
1.hugepage介绍
hugepage是在linux2.6内核被引入的,主要提供4k的page和比较大的page的选择
  当我们访问内存时,首先访问”page table“,然后linux在通过“page table”的
mapping来访问真实物理内存(ram+swap)。为了提升性能,linux在cpu中申请
固定大小的buffer,被称为TLB,TLB中保存有“page table”的部分内容,这也遵循
了,让数据尽可能的靠近cpu原则。在TLB中通过hugetlb来指向hugepage。这些被分配
的hugepage作为内存文件系统hugetlbfs(类似tmpfs)提供给进程使用。
  普通4k page
DSC0000.gif
  
  启用hugepage
DSC0001.gif
  
  hugepage特点
linux系统启动,hugepage就被分配并保留,不会pagein/pageout,除非人为干预,如改变hugepage的配置等;
根据linux内核的版本和HW的架构,hugepage的大小从2M到256M不等。因为采用大page,所以也减少TLB
和page table的管理压力
  为什么使用hugepage
  对于大内存(>8G),hugepage对于提高在linux上的oracle性能是非常有帮助的
1)Larger Page Size and Less of Pages:减少了HugeTLB 的工作量
2)No Page Table Lookups:因为hugepage是不swappable的,所有就没有page table lookups。
3)No Swapping: 在Linux下,hugepage是不支持swapping
4)No 'kswapd' Operations:在linux下进程“kswapd”是管理swap的,如果是大内存,那pages的数量就非常大, 那“kswapd”就会被频繁的调用,从而会影响性能。
  
  1) 配置之前
  [oracle@db101 ~]$ grep HugePages /proc/meminfo
HugePages_Total:   0
HugePages_Free:   0
HugePages_Rsvd:   0
Hugepagesize:   2048 kB


(2) 首先修改limits.conf
[iyunv@db101 ~]# vi /etc/security/limits.conf
  ## 等于SGA_MAX_SIZE 下面是KB 锁定15G内存
  ##zengmuansha add 0122
oracle soft  memlock  15826672
oracle hard  memlock  15826672

  (3) [ORACLE 11G] 必须关闭AMM(自动内存管理)特性才能使用hugepage
设置如下初始化参数:
ALTER SYSTEM SET sga_max_size=15455M SCOPE=SPFILE;
ALTER SYSTEM SET sga_target=0 SCOPE=SPFILE;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET=2048M SCOPE=SPFILE;
ALTER SYSTEM SET memory_target=0 SCOPE=SPFILE;
ALTER SYSTEM SET memory_max_target=0 SCOPE=SPFILE;
  
(4) 配置分配hugepage的数量
nr_hugepages的计算公式:nr_hugepages>=sga(mb)/Hugepagesize(mb)
echo "vm.nr_hugepages=3872" >> /etc/sysctl.conf
  
  (5) 重启系统
  reboot
  (6) 启动数据库
  sqlplus / as sysba
  startup
  (7) 检查是否生效
  root@db101:[/root]grep HugePages /proc/meminfo
HugePages_Total: 3890
HugePages_Free: 17
HugePages_Rsvd: 0


为了确保HugePages配置的有效性,HugePages_Free值应该小于HugePages_Total的值,并且应该等于HugePages_Rsvd的值。
Hugepages_Free和HugePages_Rsvd的值应该小于SGA 分配的gages。

2.8 故障处理
一些常见的问题如下:

SymptomPossible Cause
Troubleshooting Action
System is running out of memory or swappingNot enough HugePages to cover the SGA(s) and therefore the area reserved for HugePages are wasted where SGAs are allocated through regular pagesReview your HugePages configuration to make sure that all SGA(s) are covered.
Databases fail to start
memlock limits are not set properly
Make sure the settings in limits.conf apply to database owner account.
One of the database fail to start while another is up
The SGA of the specific database could not find available HugePages and remaining RAM is not enough.
Make sure that the RAM and HugePages are enough to cover all your database SGAs
Cluster Ready Services (CRS) fail to start
HugePages configured too large (maybe larger than installed RAM)
Make sure the total SGA is less than the installed RAM and re-calculate HugePages.
HugePages_Total = HugePages_Free
HugePages are not used at all. No database instances are up or using AMM.
Disable AMM and make sure that the database instances are up.
Database started successfully and the performance is slow
The SGA of the specific database could not find available HugePages and therefore the SGA is handled by regular pages, which leads to slow performance
Make sure that the HugePages are many enough to cover all your database SGAs

2.9 MOS 相关文档
HugePages and Oracle Database 11g AutomaticMemory Management (AMM) on Linux [ID 749851.1]
Hugepages are Not used by Database BufferCache [ID 829850.1]
Oracle Not Utilizing Hugepages [ID803238.1]
/proc/meminfo Does Not Provide HugePagesInformation on Oracle Enterprise Linux (OEL5) [ID 860350.1]
HugePages Not Released On Oracle RDBMSInstance Shutdown with RHEL / EL 5 Update 1 (5.1) [ID 550443.1]
Shell Script to Calculate ValuesRecommended Linux HugePages / HugeTLB Configuration [ID 401749.1]
HugePages on Oracle Linux 64-bit [ID 361468.1]
HugePages on Linux: What It Is... and WhatIt Is Not... [ID361323.1]
Document749851.1HugePages and Oracle Database 11g Automatic Memory Management(AMM) on Linux
Document829850.1Hugepages Are Not Used by Database Buffer Cache
Document803238.1Oracle Not Utilizing Hugepages
Document728063.1Setup HugePages in an Guest Does Not Work with Oracle VM 2.1or 2.1.1
Document550443.1HugePages Not Released On Oracle RDBMS Instance Shutdown withRHEL / EL 5 Update 1 (5.1)
Document860350.1/proc/meminfo Does Not Provide HugePages Information onOracle Enterprise Linux
  

运维网声明 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-182025-1-1.html 上篇帖子: 《linux核心应用命令速查》连载十:ps:查看权限 下篇帖子: Linux与Windows下的Java开发对比
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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