方法一
-
分別在 HiveServer2 和 WebHCat Server 所在的服務(wù)器上創(chuàng)建 /etc/hive/auxlib 目錄
[root@cdh01 hive]# hostname cdh01.cnyimi.cn [root@cdh01 hive]# pwd /etc/hive [root@cdh01 hive]# ll 總用量 0 drwxr-xr-x 2 root root 6 6月 26 21:52 auxlib lrwxrwxrwx 1 root root 27 6月 26 21:56 conf -> /etc/alternatives/hive-conf drwxr-xr-x 2 root root 326 6月 26 21:56 conf.cloudera.hiveimage
如果沒(méi)有在 HiveServer2 或 WebHCat Server 所在的服務(wù)器創(chuàng)建的該目錄,重啟時(shí)會(huì)報(bào)以下異常。
... + ERROR: HIVE_AUX_JARS_PATH is configured in Cloudera Manager as /etc/hive/auxlib. However directory /etc/hive/auxlib does not exist. When configured, directory specified in HIVE_AUX_JARS_PATH must be created and managed manually before starting Hive. ... -
Hive --> 配置 --> 搜索 jar
/etc/hive/auxlibimage -
Hive --> 配置 --> 搜索 hive-env.sh
HIVE_AUX_JARS_PATH=/etc/hive/auxlibimage -
重啟 Hive
image
image
image
方法二
-
分別在 HiveServer2 和 Hive Metastore Server 所在的服務(wù)器上創(chuàng)建 Jar 存放目錄
[root@cdh01 lib]# pwd;ll /data/hive/lib 總用量 84 -rw-r--r-- 1 root root 82101 6月 27 20:53 json-serde-1.3.7-jar-with-dependencies.jar注意:
如果 Hive Metastore 與 HiveServer2 不在同另一臺(tái)主機(jī)上,??那么要在這兩臺(tái)機(jī)器上創(chuàng)建相同的目錄,但是 JAR 文件需要上傳到 HiveServer2 主機(jī)上。 -
Hive -> 配置 -> 搜索 hive-site.xml
<property> <name>hive.reloadable.aux.jars.path</name> <value>/data/hive/lib</value> <description>Path to Hive UDF JAR files.</description> </property>image -
部署客戶端配置,重啟 Hive。
image
image
image
優(yōu)缺點(diǎn):
方法一方式設(shè)置 Hive CLI 和 Beeline 均適用,但是目錄位置必須為 /etc/hive/auxlib。
方法二方式設(shè)置只對(duì) Beeline 適用,Hive CLI 方式無(wú)法識(shí)別 Jar 包,優(yōu)點(diǎn)在于目錄位置可以隨意指定,使用時(shí)需要執(zhí)行執(zhí)行 RELOAD 命令(好像要執(zhí)行兩次)即可加載到新增 Jar 包。
參考 CDH 官方文檔:
https://www.cloudera.com/documentation/enterprise/latest/topics/cm_mc_hive_udf.html