복붙노트

[HADOOP] java.lang.OutOfMemoryError : 하이브가있는 Java 힙 공간

HADOOP

java.lang.OutOfMemoryError : 하이브가있는 Java 힙 공간

내가 hadoop 하이브 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)

해결법

  1. ==============================

    1.Hive에서 컨테이너 heapsize를 설정하고이 오류를 해결할 수 있습니다.

    Hive에서 컨테이너 heapsize를 설정하고이 오류를 해결할 수 있습니다.

    Hadoop MapReduce 프레임 워크에서 작동하는 대부분의 도구는 작업에 대한 이러한 Hadoop 수준 설정을 조정하는 방법을 제공합니다. 하이브에서 여러 가지 방법이 있습니다. 다음 세 가지가 여기에 표시됩니다.

    1) Hive 명령 줄을 통해 직접 전달하십시오.

    hive -hiveconf mapreduce.map.memory.mb=4096 -hiveconf mapreduce.reduce.memory.mb=5120 -e "select count(*) from test_table;"
    

    2) Hive를 호출하기 전에 ENV 변수를 설정하십시오.

    export HIVE_OPTS="-hiveconf mapreduce.map.memory.mb=4096 -hiveconf mapreduce.reduce.memory.mb=5120"
    

    3) 하이브 CLI에서 "set"명령을 사용하십시오.

    hive> set mapreduce.map.memory.mb=4096;
    hive> set mapreduce.reduce.memory.mb=5120;
    hive> select count(*) from test_table;
    
  2. ==============================

    2.글쎄, 내 경우에는 java.opts에서 메모리를 설정해야한다.

    글쎄, 내 경우에는 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;
    
  3. from https://stackoverflow.com/questions/29673053/java-lang-outofmemoryerror-java-heap-space-with-hive by cc-by-sa and MIT license