尝试使用Hive流API建立连接时,hive scratch目录的权限被拒绝

时间:2016-10-27 07:14:17

标签: java hadoop permissions hive hdfs

我正在使用HCatalogue Streaming api编写示例程序

我有一个正在运行的hadoop,Hiveserver和一个Hivemetastore服务器。

我编写了一个java程序来连接到hive Metastore。源代码如下所示

public class HCatalogueStreamingclient {
    public static void main(String[] args) {
        System.setProperty("hadoop.home.dir", "E:\\midhun\\hadoop\\hive\\winutils");
        String dbName = "hive_streaming";
        String tblName = "alerts";
        ArrayList<String> partitionVals = new ArrayList<String>(2);
        partitionVals.add("Asia");
        partitionVals.add("India");
        HiveEndPoint hiveEP = new HiveEndPoint("thrift://192.168.10.149:8000", dbName, tblName, partitionVals);
        HiveConf conf = new HiveConf();
        conf.set("hive.exec.scratchdir", "/tmp/hivetmp");

        try {
            StreamingConnection connection = hiveEP.newConnection(true,conf);
        } catch (ConnectionError e) {
            e.printStackTrace();
        } catch (InvalidPartition e) {
            e.printStackTrace();
        } catch (InvalidTable e) {
            e.printStackTrace();
        } catch (PartitionCreationFailed e) {
            e.printStackTrace();
        } catch (ImpersonationFailed e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

在运行程序时,我遇到异常

Exception in thread "main" java.lang.RuntimeException: The root scratch dir: /tmp/hivetmp on HDFS should be writable. Current permissions are: rw-rw-rw-
    at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:690)
    at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:622)
    at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:550)
    at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:513)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint$ConnectionImpl.createPartitionIfNotExists(HiveEndPoint.java:445)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint$ConnectionImpl.<init>(HiveEndPoint.java:314)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint$ConnectionImpl.<init>(HiveEndPoint.java:278)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint.newConnectionImpl(HiveEndPoint.java:215)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint.newConnection(HiveEndPoint.java:192)
    at org.apache.hive.hcatalog.streaming.HiveEndPoint.newConnection(HiveEndPoint.java:113)
    at com.mj.HCatalogueStreamingclient.main(HCatalogueStreamingclient.java:27)

任何人都对如何对hdfs文件夹/ tmp / hivetmp

的宏写入权限有所了解

1 个答案:

答案 0 :(得分:0)

确定问题。

  • 我们需要为hadoop目录/tmp/hivetmp授予所有权限。授予权限的命令是$ HADOOP_HOME / bin / hadoop fs -chmod 777 -R / tmp / hivetmp
  • 我在Windows 7 64位操作系统中运行该程序。我们需要下载适用于操作系统和版本的winutil。

在完成上述要点之后,我能够使用Hive HCatalogue Streaming api建立连接