获取java.lang.OutOfMemoryError:使用水槽运行Twitter连接器时的Java堆空间 [英] Getting java.lang.OutOfMemoryError: Java heap space while running twitter connector using flume

查看:60
本文介绍了获取java.lang.OutOfMemoryError:使用水槽运行Twitter连接器时的Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此命令启动代理

I am starting the agent using this command

bin/flume-ng代理--conf ./conf/-f conf/twitter.conf Dflume.root.logger = DEBUG,控制台-n TwitterAgent

bin/flume-ng agent --conf ./conf/ -f conf/twitter.conf Dflume.root.logger=DEBUG,console -n TwitterAgent

我的错误消息是

Exception in thread "Twitter Stream consumer-1[Receiving stream]" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3332)
    at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:596)
    at java.lang.StringBuffer.append(StringBuffer.java:367)
    at java.io.BufferedReader.readLine(BufferedReader.java:370)
    at java.io.BufferedReader.readLine(BufferedReader.java:389)
    at twitter4j.StatusStreamBase.handleNextElement(StatusStreamBase.java:85)
    at twitter4j.StatusStreamImpl.next(StatusStreamImpl.java:57)
    at twitter4j.TwitterStreamImpl$TwitterStreamConsumer.run(TwitterStreamImpl.java:478)
18/05/15 16:53:36 ERROR hdfs.HDFSEventSink: process failed
java.lang.OutOfMemoryError: GC overhead limit exceeded

下面给出的我的twitter.conf的属性文件

My property file of twitter.conf given below

# Naming the components on the current agent.
TwitterAgent.sources = Twitter
TwitterAgent.channels = MemChannel
TwitterAgent.sinks = HDFS

# Describing/Configuring the source
TwitterAgent.sources.Twitter.type = org.apache.flume.source.twitter.TwitterSource
TwitterAgent.sources.Twitter.consumerKey = xxx
TwitterAgent.sources.Twitter.consumerSecret = xxx
TwitterAgent.sources.Twitter.accessToken = xxx
TwitterAgent.sources.Twitter.accessTokenSecret = xxx
TwitterAgent.sources.Twitter.keywords = kafka

# Describing/Configuring the sink

TwitterAgent.sinks.HDFS.type = hdfs
TwitterAgent.sinks.HDFS.hdfs.path = hdfs://xxx:7200/topics/
TwitterAgent.sinks.HDFS.hdfs.fileType = DataStream
TwitterAgent.sinks.HDFS.hdfs.writeFormat = Text
TwitterAgent.sinks.HDFS.hdfs.batchSize = 10000
TwitterAgent.sinks.HDFS.hdfs.rollSize = 0
TwitterAgent.sinks.HDFS.hdfs.rollCount = 100000

# Describing/Configuring the channel
TwitterAgent.channels.MemChannel.type = memory
TwitterAgent.channels.MemChannel.capacity = 100000
TwitterAgent.channels.MemChannel.transactionCapacity = 1000

# Binding the source and sink to the channel
TwitterAgent.sources.Twitter.channels = MemChannel
TwitterAgent.sinks.HDFS.channel = MemChannel

我的flume-env.sh文件

My flume-env.sh file

export JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/java

# Give Flume more memory and pre-allocate, enable remote monitoring via JMX
export JAVA_OPTS="-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote"


# Let Flume write raw event data and configuration information to its log files for debugging
# purposes. Enabling these flags is not recommended in production,
# as it may result in logging sensitive user information or encryption secrets.
# export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.flume.log.rawdata=true -Dorg.apache.flume.log.printconfig=true "

# Note that the Flume conf directory is always included in the classpath.
#FLUME_CLASSPATH=""

# export HIVE_HOME=/usr/lib/hive
# export HCAT_HOME=/usr/lib/hive-hcatalog

我在flume-env.sh文件中有更新export JAVA_OPTS =-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote",但仍然遇到Java堆内存问题.我应该怎么做才能进一步解决此问题.

i have update export JAVA_OPTS="-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote" in flume-env.sh file, but still getting java heap memory issue. What should i do to resolve this issue further.

推荐答案

我通过在twitter.conf文件中添加此行来解决了增加堆大小的问题

I solved this issue increasing the heap size, by adding this line in twitter.conf file

TwitterAgent.channels.MemChannel.byteCapacity = 6912212

然后增加flume-env.sh文件中的堆大小

Then increased the heap size in flume-env.sh file

export JAVA_OPTS="-Xms512m -Xmx1024m -Dcom.sun.management.jmxremote"

这篇关于获取java.lang.OutOfMemoryError:使用水槽运行Twitter连接器时的Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆