Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hive failed execution error return code 2 from org.apache.hadoop.hive.ql.exec.mapredtask

Tags:

hadoop

hive

I have one query. It is executing fine on Hive CLI and returning the result. But when I am executing it with the help of Hive JDBC, I am getting an error below:

java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
    at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:192)

What is the problem? Also I am starting the Hive Thrift Server through Shell Script. (I have written a shell script which has command to start Hive Thrift Server) Later I decided to start Hive thrift Server manually by typing command as:

hadoop@ubuntu:~/hive-0.7.1$ bin/hive --service hiveserver
Starting Hive Thrift Server
org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:10000.
    at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:99)
    at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:80)
    at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:73)
    at org.apache.hadoop.hive.service.HiveServer.main(HiveServer.java:384)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:186)

hadoop@ubuntu:~/hive-0.7.1$

Please help me out from this. Thanks

like image 839
Bhavesh Shah Avatar asked Aug 13 '26 08:08

Bhavesh Shah


1 Answers

For this error :
java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuer

Go to this link :

http://docs.amazonwebservices.com/ElasticMapReduce/latest/DeveloperGuide/UsingEMR_Hive.html

and add

**hadoop-0.20-core.jar
hive/lib/hive-exec-0.7.1.jar
hive/lib/hive-jdbc-0.7.1.jar
hive/lib/hive-metastore-0.7.1.jar
hive/lib/hive-service-0.7.1.jar
hive/lib/libfb303.jar
lib/commons-logging-1.0.4.jar    
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar**

to the class path of your project , add this jars from the lib of hadoop and hive, and try the code. and also add the path of hadoop, hive, and hbase(if your are using) lib folder path to the project class path, like you have added the jars.

and for the second error you got

type

**netstat -nl | grep 10000**

if it shows something means hive server is already running. the second error comes only when the port you are specifying is already acquired by some other process, by default server port is 10000 so very with the above netstat command which i said.

Note : suppose you have connected using code exit from ... bin/hive of if you are connected through bin/hive > then code will not connect because i think (not sure) only one client can connect to the hive server.

do above steps hopefully will solve your problem.

NOTE : exit from cli when you are going to execute the code, and dont start cli while code is being executing.

like image 133
Infinity Avatar answered Aug 15 '26 09:08

Infinity