作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 hive 壳上添加jar。我知道服务器上的全局选项,但是我的要求是在配置单元 shell 上的每个 session 中添加它们。
我已将这个class用于hdfs dfs命令,将jar添加到hdfs文件系统中
这是我尝试过的:
在hdfs / tmp上创建一个文件夹
使用FileSystem.copyFromLocalFile method将文件添加到hdfs文件系统
(相当于hdfs dfs -put myjar.jar / tmp
在fs fs文件系统上的文件上设置权限
使用getFileSystem method检查jar是否已加载到hdfs
使用listFiles在fs FileSystem上列出文件,以确认 jar 在那里。
这有效,我将jar加载到hdfs,但是我无法将jar添加到配置单元 session
当我尝试将其添加到配置单元 shell 时,我正在执行以下操作:
statement = setStmt(createStatement(getConnection()));
query = "add jar " + path;
statement.execute(query);
Error while processing statement: /tmp/myjar.jar does not exist
query = "add jar hdfs://<host>:<port>" + path;
query = "add jar <host>:<port>" + path;
query = "list jars";
ResultSet rs = statement.executeQuery(query);
最佳答案
我设法解决了这个问题
由于FileSystem的配置,该过程失败。
该对象是我们在 jar 中添加 jar 之前将其添加到 session 中的位置。
这是您初始化文件系统的方式FileSystem fs = FileSystem.newInstance(conf);
对象conf应该具有配置单元服务器的属性。
为了使该过程正常进行,我需要在Configuration属性上设置以下参数conf.set("fs.defaultFS", hdfsDstStr);
关于java - 如何在Java应用程序中的Hive Shell上添加jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61621122/
我是一名优秀的程序员,十分优秀!