HBase Direct Memory OutOfMemory

1、java.lang.OutOfMemoryError: Direct buffer memory

最近对一个HBase集群增加了BucketCache配置,减少其堆内内存GC已达到提升新能的目的。
但是,没过多久整个集群就出现了大面积OOM现象,而且是发生在Direct Memory,日志错误信息如下。

2018-08-30 02:44:00,199 ERROR [Thread-40464] hdfs.DFSClient: Failed to close inode 43777915
java.io.IOException: DataStreamer Exception: 
        at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:666)
Caused by: java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:693)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
        at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:241)
        at sun.nio.ch.IOUtil.write(IOUtil.java:58)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
        at org.apache.hadoop.net.SocketOutputStream$Writer.performIO(SocketOutputStream.java:63)
        at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142)
        at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:159)
        at org.apache.hadoop.net.SocketOutputStream.write(SocketOutputStream.java:117)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
        at java.io.DataOutputStream.write(DataOutputStream.java:107)
        at org.apache.hadoop.hdfs.DFSPacket.writeTo(DFSPacket.java:176)
        at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:611)

2、OOM异常原因

在没开启BucketCache之前,在hbase-env.sh中是没有分配堆外内存Direct Memory的。
而BucketChace的分配的方式是offheap(支持heap,offheap,file,file通常是建立在SSD或者PCIE-IO存储上)

    <property>
      <name>hbase.bucketcache.ioengine</name>
      <value>offheap</value>
    </property>

    <property>
      <name>hbase.bucketcache.size</name>
      <value>12000</value>
    </property>

DirectMemory分配为:

-XX:MaxDirectMemorySize=12100m

除去BucketCache占用的堆外之外,仅100M空间可用,DFSClient用到Direct Memory因而容易出现OOM现象。

建议:MaxDirectMemorySize – hbase.bucketcache.size >= 2048M

参考资料:
https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.2.0/bk_Sys_Admin_Guides/content/ref-db219cd6-c586-49c1-bc56-c9c1c5475276.1.html
https://community.hortonworks.com/content/supportkb/150736/error-hdfsdfsclient-datastreamer-exception-javalan.html

此条目发表在hbase分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.