[英]how to add a jar file in hive
I'm trying to add hive-contrib-0.10.0.jar in hive using ADD JAR hive-contrib-0.10.0.jar command but it always saying hive-contrib-0.10.0.jar does not exist. 我正在尝试使用ADD JAR hive-contrib-0.10.0.jar命令在hive中添加hive-contrib-0.10.0.jar,但它总是说hive-contrib-0.10.0.jar不存在。
I'm using HDP 2.1 version right now. 我正在使用HDP 2.1版本。 I also added this jar file into /user/root
folder using hue and run the command 我还使用hue将此jar文件添加到/user/root
文件夹中并运行命令
ADD JAR hdfs:///hive-contrib-0.10.0.jar
but it giving me same error jar file doesn't exist
. 但是它给了我同样的错误jar file doesn't exist
。
Is there any way to solve this problem. 有什么办法可以解决这个问题。 Where should I keep this jar file so that it will run successfully and what will be the command to be used? 我应该将该jar文件保存在哪里,以便它可以成功运行,将使用什么命令?
Example: 例:
hadoop fs -put ~/Downloads/hive.jar /lib/
open hive shell 打开蜂巢壳
add jar hdfs:///lib/hive.jar
if you want to permanently add the jars you need to do the following. 如果要永久添加罐子,则需要执行以下操作。 1. Hive-site.xml ( /etc/hive/conf ) 1. Hive-site.xml(/ etc / hive / conf)
<property>
<name>hive.aux.jars.path</name>
<value>file:///mnt1/hive-jars/hive-contrib-2.1.1.jar</value>
</property>
This should ideally work after restarting hive-server2. 理想情况下,这应该在重新启动hive-server2之后起作用。 3. sudo stop hive-server2 4. sudo start hive-server2 3. sudo停止hive-server2 4. sudo启动hive-server2
But sometimes it does not work. 但有时它不起作用。 i am not sure why so you can use the following dirty way. 我不知道为什么,所以您可以使用以下肮脏的方式。
put your jar file in the following path so that hive automatically picks it up while restart. 将jar文件放在以下路径中,以便配置单元在重新启动时自动将其拾取。
I see following issues with your approach. 我发现您的方法存在以下问题。 Before adding make sure you are able to list the file on Local file system or hdfs where ever it exists. 添加之前,请确保您能够在本地文件系统或hdfs上列出该文件(如果存在)。
The jar you are trying to add is by default in hive class path as its part of $HIVE_HOME/lib (on local file system where ever you have hive client/service installed) 默认情况下,您尝试添加的jar在hive类路径中,作为其$ HIVE_HOME / lib的一部分(在安装了hive客户端/服务的本地文件系统上)
on the other hand in regards to your question about how to add jars in hive, we can add using local file system or hadoop distributed file system (HDFS) 另一方面,关于您有关如何在配置单元中添加jar的问题,我们可以使用本地文件系统或hadoop分布式文件系统(HDFS)进行添加
Add jar file:///root/hive-contrib-0.10.0.jar (Given that you copied this jar on LFS root directory)
Add jar hdfs://<namenode_hostname>:8020/user/root/hive-contrib-0.10.0.jar (Given that you copied to HDFS root home)
I have read these answers above which was very useful. 我在上面已经阅读了这些答案,这非常有用。 And I combined all into one solution: 然后,我将所有内容组合为一个解决方案:
put jars into local disk and give read/write permission 将罐子放入本地磁盘并提供读/写权限
chmod -R 777 /tmp/json.jar
upload to hdfs file system and give permissions too: 上传到hdfs文件系统并授予权限:
hdfs dfs -put /tmp/json.jar hdfs://1.1.1.1:8020/jars/ hdfs dfs -chmod -R 777 hdfs://1.1.1.1:8020/jars/
add jar into hive env. 将jar添加到蜂巢环境中。
add jar hdfs://1.1.1.1:8020/jars/json.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.