蜂房导入失败[java.lang.OutOfMemoryError]
问题描述:
我正在做一个SQL数据库的输入到配置单元数据库中的蜂巢客户端节点上(使用Hortonworks数据平台)与bash命令:蜂房导入失败[java.lang.OutOfMemoryError]
$ hive -f tables.sql
我得到的错误:
log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender.
Logging initialized using configuration in file:/etc/hive/2.6.1.0-129/0/hive-log4j.properties
Exception in thread "main" 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:448)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at org.apache.hadoop.hive.cli.CliDriver.processReader(CliDriver.java:409)
at org.apache.hadoop.hive.cli.CliDriver.processFile(CliDriver.java:429)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:718)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:685)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
我试图增加从1GB的HADOOP_HEAPSIZE至4 GB,但我仍然得到错误。有任何想法吗 ?
答
OutOfMemoryError
来自CliDriver#processReader(BufferedReader)
的Hive代码库。
public int processReader(BufferedReader r) throws IOException {
String line;
StringBuilder qsb = new StringBuilder();
while ((line = r.readLine()) != null) {
// Skipping through comments
if (! line.startsWith("--")) {
qsb.append(line + "\n");
}
}
return (processLine(qsb.toString()));
}
它加入所有行的从文件到一个StringBuilder
读取,然后执行它。这意味着您指定的输入文件非常大。是否有可能将其分割为多个较小的文件并分别执行每个文件,从而减少内存占用?
你提到过这是一个SQL数据库的导入。 Apache Sqoop可能更适合该用例。
我发现这个小回购拆分.sql到table.sql:https://github.com/kedarvj/mysqldumpsplitter,我正在尝试 –
经过研究Apache Scoop似乎比我的配置单元导入更好的工作命令 –
@AdrienForbu,很好的电话。 Sqoop在这里很有意义。 –