Hive如何添加第三方JAR

來源:互聯網
上載者:User

以加入elsaticsearch-hadoop-2.1.2.jar為例,講述在Hive中加入第三方jar的幾種方式。
1,在hive shell中加入

[hadoop@hadoopcluster78 bin]$ ./hiveLogging initialized using configuration in file:/home/hadoop/apache/hive-0.13.1/conf/hive-log4j.propertieshive> add jar /home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar;                        //elasticsearch-hadoop-hive-2.1.2.jar放在本地檔案系統的/home/hadoop目錄。Added /home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar to class pathAdded resource: /home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar

串連方式
是否有效
Hive Shell
不需要重啟Hive服務就有效
Hive Server
無效

2,Jar放入${HIVE_HOME}/auxlib目錄

在${HIVE_HOME}中建立檔案夾auxlib,然後將自訂jar檔案放入該檔案夾中。
此方法添加不需要重啟Hive。而且比較便捷。

串連方式
是否有效
Hive Shell
不需要重啟Hive服務就有效
Hive Server
重啟Hive服務才生效

3,HIVE.AUX.JARS.PATH和hive.aux.jars.path hive-env.sh中的HIVE.AUX.JARS.PATH和hive-site.xml的hive.aux.jars.path配置對伺服器無效,僅對當前hive shell有效,不同的hive shell相互不影響,每個hive shell都需要配置,可以配置成檔案夾形式。

HIVE.AUX.JARS.PATH和hive.aux.jars.path僅支援本地檔案。可配置成檔案,也可配置為檔案夾。

在${HIVE_HOME}/conf/hive-env.sh下配置:
export HIVE_AUX_JARS_PATH=/home/hadoop/apache/hive-0.13.1/lib/mysql-connector-java-5.1.7-bin.jar #本地檔案路徑,不支援HDFS路徑

類似的,可以在${HIVE_HOME}/conf/hive-site.xml下配置:
<property>    <name>hive.aux.jars.path</name>    <value>/home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar</value></property>

串連方式
是否有效
Hive Shell
重啟Hive服務才生效且不同的Hive Shell互不影響
Hive Server
無效

註:hive-env.sh中配置的HIVE_AUX_JARS_PATH和hive-site.xml配置hive.aux.jars.path參數會有衝突,在使用的時候要特別注意。


4,直接將Jar加入${HIVE_HOME}/lib目錄
串連方式
是否有效
Hive Shell
重啟Hive服務才生效
Hive Server
重啟Hive服務才生效

總結:只有第2種和第4種方式才能在Hive Server中起效。其他的在Hive Server中都無效,網上看了一些文章,都說hive-site.xml配置hive.aux.jars.path是可以起作用的,但是試過很多次都沒用,百思不得其姐,期待大神答疑。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.