我安装了单节点集群hadoop和hive。我能够加载数据并将其显示在配置单元中。我想执行一个创建临时函数的脚本。我需要添加jar文件。 jar文件添加了esri-geometry-api.jar spatial-sdk-hive-1.0-MODIFIED.jar和HiveUDFs.jar
我提到:How to write a script file in Hive? 我收到此错误:esri-geometry-api.jar不存在
我的配置详情:
$ echo $HADOOP_HOME:/home/hduser/hadoop-1.2.1
$ echo $JAVA_HOME:/usr/lib/java/jdk1.7.0_55
$ echo $:HIVE_HOME:/home/hduser/hadoop-1.2.1/hive-0.9.0-bin
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
hadoop版本:
Hadoop 1.2.1
Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2 -r 1503152
Compiled by mattf on Mon Jul 22 15:23:09 PDT 2013
From source with checksum 6923c86528809c4e7e6f493b6b413a9a
This command was run using /home/hduser/hadoop-1.2.1/hadoop-core-1.2.1.jar
HIVE VERSION: hive-0.9.0
hduser@ubuntu:~$ echo $HIVE_HOME
/home/hduser/hadoop-1.2.1/hive-0.9.0-bin
我有hive脚本,我需要执行如下: 我有一个数据,在5秒的时间间隔内具有经度。
add jar esri-geometry-api.jar spatial-sdk-hive-1.0-MODIFIED.jar HiveUDFs.jar;
create temporary function ST_AsText as 'com.esri.hadoop.hive.ST_AsText';
create temporary function ST_Intersects as 'com.esri.hadoop.hive.ST_Intersects';
create temporary function ST_Length as 'com.esri.hadoop.hive.ST_Length';
create temporary function ST_LineString as 'com.esri.hadoop.hive.ST_LineString';
create temporary function ST_Point as 'com.esri.hadoop.hive.ST_Point';
create temporary function ST_Polygon as 'com.esri.hadoop.hive.ST_Polygon';
create temporary function ST_SetSRID as 'com.esri.hadoop.hive.ST_SetSRID';
create temporary function collect_array as 'com.zombo.GenericUDAFCollectArray';
SELECT
id,
unix_timestamp(dt) - unix_timestamp(fv)
FROM (
SELECT
id, dt, fv
FROM (
SELECT
id, dt,
FIRST_VALUE(dt) OVER (PARTITION BY id ORDER BY dt) as fv,
ROW_NUMBER() OVER (PARTITION BY id ORDER BY dt DESC) as lastrk
FROM
uber
) sub1
WHERE
lastrk = 1
) sub2
WHERE
(unix_timestamp(dt) - unix_timestamp(fv)) < 28800;
我的问题如下:
当我尝试手动添加JAR时,它给出了以下错误: 蜂房&GT;添加JAR esri-geometry-api.jar / home / hduser / hadoop_jar; esri-geometry-api.jar不存在
蜂房&GT; add jar esri-geometry-api.jar; esri-geometry-api.jar不存在
我还添加了hive-site.xml,如下所示:
<configuration>
<property>
<name>hive.aux.jars.path</name>
<value>file:///home/hduser/hadoop_jar/HIVEUDFs.jar,
file:///home/hduser/hadoop_jar/esri-geometry-api-1.0.jar,
file:///home/hduser/hadoop_jar/spatial-sdk-json-1.0.1-sources.jar</value>
</property>
</configuration>
我将jar文件添加到hadoop文件夹中我的hive目录的lib文件夹中。
当我尝试运行脚本时:
hduser @ ubuntu:〜/查询$ hive queries.hive
警告:不推荐使用org.apache.hadoop.metrics.jvm.EventCounter。请在所有log4j.properties文件中使用org.apache.hadoop.log.metrics.EventCounter。 使用jar中的配置初始化日志:file:/home/hduser/hadoop-1.2.1/hive-0.9.0-bin/lib/hive-common-0.9.0.jar!/hive-log4j.properties Hive历史文件= / tmp / hduser / hive_job_log_hduser_201404290234_597714109.txt
蜂房&GT;
当我发出list jar;命令它给出:file:/home/hduser/hadoop-1.2.1/hive-0.9.0-bin/lib/hive-builtins-0.9.0.jar
我需要执行脚本。请帮忙。
答案 0 :(得分:0)
您无法执行脚本的原因是缺少-f选项执行脚本,如下所示:
hduser@ubuntu:~/queries$ hive -f queries.hive
由于hive内部使用Hadoop来保存其数据和Mapreduce以便执行。执行配置单元命令时应启动Hadoop服务。
在add jar语句中,应指定Jar的完成路径,并且应分别指定每个jar,如下所示
add jar <PATH_TO_JAR>/esri-geometry-api.jar; add jar <PATH_TO_JAR>/spatial-sdk-hive-1.0-MODIFIED.jar; add jar <PATH_TO_JAR>/HiveUDFs.jar;