我使用了hadoop hive 0.9.0和1.1.2以及netbeans,但我遇到了此错误,无法解决此问题请帮助我编写代码:
public class Hive_test {
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
@SuppressWarnings("CallToThreadDumpStack")
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e){
e.printStackTrace();
System.exit(1);
}
System.out.println("commencer la connexion");
Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default",""," ");
Statement stmt = con.createStatement();
ResultSet res = stmt.executeQuery("select * from STATE");
while (res.next()){
System.out.println(String.valueOf(res.getInt(1)) + "\t" + res.getString(2));
System.out.println("sql terminer");
}
}
以下错误;
error :
commencer la connexion
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.apache.thrift.protocol.TBinaryProtocol.readStringBody(TBinaryProtocol.java:353)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:215)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at org.apache.hadoop.hive.service.ThriftHive$Client.recv_execute(ThriftHive.java:116)
at org.apache.hadoop.hive.service.ThriftHive$Client.execute(ThriftHive.java:103)
at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:192)
at org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:132)
at org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:132)
at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:122)
at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at hive.Hive_test.main(Hive_test.java:22)
3条答案
按热度按时间j91ykkif1#
对我来说,下面的解决方案是有效的。
在启动配置单元cli之前,请使用
export HADOOP_CLIENT_OPTS=" -Xmx8192m"
然后启动cli6mzjoqzu2#
嗯,就我而言,我还需要设置内存
java.opts
```set mapreduce.map.memory.mb=4096;
set mapreduce.map.java.opts=-Xmx3686m;
set mapreduce.reduce.memory.mb=4096;
set mapreduce.reduce.java.opts=-Xmx3686m;
stszievb3#
您可以在配置单元中设置容器堆化并解决此错误:
大多数在hadoopmapreduce框架上运行的工具都提供了为其作业调优这些hadoop级别设置的方法。在Hive中有多种方法可以做到这一点。这里显示了其中三个:
1) 通过配置单元命令行直接传递:
2) 在调用配置单元之前设置env变量:
3) 在配置单元cli中使用“set”命令。