Hive

CDH 中配置 Hive 的辅助 JAR 目录

2019-11-24  本文已影响0人  lei_charles
方法一
  1. 分别在 HiveServer2 和 WebHCat Server 所在的服务器上创建 /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.hive
    
    image

    如果没有在 HiveServer2 或 WebHCat Server 所在的服务器创建的该目录,重启时会报以下异常。

    ...
    + 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.
    ...
    
  2. Hive --> 配置 --> 搜索 jar

    /etc/hive/auxlib
    
    image
  3. Hive --> 配置 --> 搜索 hive-env.sh

    HIVE_AUX_JARS_PATH=/etc/hive/auxlib
    
    image
  4. 重启 Hive

    image
    image
    image
方法二
  1. 分别在 HiveServer2 和 Hive Metastore Server 所在的服务器上创建 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 不在同另一台主机上,​​那么要在这两台机器上创建相同的目录,但是 JAR 文件需要上传到 HiveServer2 主机上。

  2. 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
  3. 部署客户端配置,重启 Hive。


    image
    image
    image

优缺点:

方法一方式设置 Hive CLI 和 Beeline 均适用,但是目录位置必须为 /etc/hive/auxlib

方法二方式设置只对 Beeline 适用,Hive CLI 方式无法识别 Jar 包,优点在于目录位置可以随意指定,使用时需要执行执行 RELOAD 命令(好像要执行两次)即可加载到新增 Jar 包。

参考 CDH 官方文档:

https://www.cloudera.com/documentation/enterprise/latest/topics/cm_mc_hive_udf.html

上一篇 下一篇

猜你喜欢

热点阅读