FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

记录一次HIVE执行查询的报错。

CDH平台搭建大数据平台,使用HIVE测试select count(1) from test,报错如下:

java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:292)
at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:393)
at com.QueryHiveUtils.countData(QueryHiveUtils.java:16)
at com.QueryHiveTest.main(QueryHiveTest.java:42)

 

解决:

之前使用了root运行报错,修改为hdfs用户可正常返回查询的结果。

private static String driverName ="org.apache.hive.jdbc.HiveDriver";
private static String user = "hdfs"; --使用root用户报错
private static String password = "hdfs";
private static String Url="jdbc:hive2://192.168.0.108:10000/default"; //填写hive的IP,之前在配置文件中配置的IP
private static Connection conn;
public static Connection getConnnection()
{
try
{
Class.forName(driverName);
conn = DriverManager.getConnection(Url,user,password); //此处的用户名一定是有权限操作HDFS的用户,否则程序会提示"permission deny"异常
}
catch(ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
}
catch (SQLException e) {
e.printStackTrace();
}
return conn;
}

posted @ 2017-09-15 17:13  HQin  阅读(4913)  评论(0编辑  收藏  举报