【问题标题】:Permission denied for hive scratch directory while trying to establish connection using Hive streaming api尝试使用 Hive 流 api 建立连接时,hive 暂存目录的权限被拒绝
【发布时间】:2016-10-27 07:14:17
【问题描述】:

我正在使用 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 授予写入权限

【问题讨论】:

    标签: java hadoop permissions hive hdfs


    【解决方案1】:

    问题已确定。

    • 我们需要对hadoop目录/tmp/hivetmp的所有权限进行grand。granding权限的命令是$HADOOP_HOME/bin/hadoop fs -chmod 777 -R /tmp/hivetmp
    • 我在 Windows 7 64 位操作系统中运行程序。我们需要下载适合操作系统和版本的 winutils。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-04
      • 1970-01-01
      • 1970-01-01
      • 2017-11-25
      • 2018-08-07
      • 2021-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多