apache-hive-1.2.1和hbase-1.2.2的整合(伪分布式)

我的机器环境: hadoop2.6.0 的伪分布式  Hbase伪分布式环境
参考:hbase权威指南P240
1.启动hadoop和hbase 
2.下载apache-hive-1.2.1
3.修改hive中conf下的hive-env.sh
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/hadoop/hadoop
HBASE_HOME=/home/hadoop/hbase-1.2.2

# Hive Configuration Directory can be controlled by:
# export HIVE_CONF_DIR=
export HIVE_CLASSPATH=/home/hadoop/hbase-1.2.2/conf

# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/home/hadoop/hbase-1.2.2/lib
4.启动hive

备注:给通过hive给hbase建表时,如果出现下面的错误,需重新编译hive-hbase-handler-1.2.1.jar,替换hive/lib下的原jar包
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.apache.hadoop.hbase.HTableDescriptor.addFamily(Lorg/apache/hadoop/hbase/HColumnDescriptor;)V

操作记录:
hadoop@ubuntu:~/apache-hive-1.2.1-bin/bin$ ./hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/spark-1.6.1-bin-hadoop2.6/lib/spark-assembly-1.6.1-hadoop2.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hbase-1.2.2/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/spark-1.6.1-bin-hadoop2.6/lib/spark-assembly-1.6.1-hadoop2.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hbase-1.2.2/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/home/hadoop/apache-hive-1.2.1-bin/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> create table pokes(foo int,bar string);
OK
Time taken: 3.432 seconds
hive> load data local inpath '/home/hadoop/apache-hive-1.2.1-bin/examples/files/kv1.txt' overwrite into table pokes;
Loading data to table default.pokes
Table default.pokes stats: [numFiles=1, numRows=0, totalSize=5812, rawDataSize=0]
OK
Time taken: 1.353 seconds
hive> select * from pokes;
OK
238    val_238
86    val_86
311    val_311
27    val_27
165    val_165
409    val_409
Time taken: 1.143 seconds, Fetched: 500 row(s)
hive> create table hbase_table_1(key int,value string)
    > stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > with serdeproperties("hbase.columns.mapping"=":key,cf1:val")
    > tblproperties("hbase.table.name"="hbase_hive_t1");
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.apache.hadoop.hbase.HTableDescriptor.addFamily(Lorg/apache/hadoop/hbase/HColumnDescriptor;)V

针对这个错误,网上说这是不兼容造成的,网络上提供了两种解决方案:
1.换更高版本的hive 例如2.xx 可经试验发现问题依旧没有解决
2.重新编译hive-hbase-handler-1.2.1.jar,替换hive/lib中的同名包(此方法可行)
在网上有编译好的直接下载也可以: http://download.csdn.net/download/gao634209276/9530079

hive> create table hbase_table_1(key int,value string)
    >     stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    >      with serdeproperties("hbase.columns.mapping"=":key,cf1:val")
    >      tblproperties("hbase.table.name"="hbase_hive_t1");
OK
Time taken: 4.788 seconds
hive>
    > ;
hive> insert overwrite table hbase_table_1 select * from pokes;
Query ID = hadoop_20170117004636_520fee8b-9d6c-4b41-88a5-a58402e0b6af
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1484619043631_0001, Tracking URL = http://ubuntu:8088/proxy/application_1484619043631_0001/
Kill Command = /home/hadoop/hadoop/bin/hadoop job  -kill job_1484619043631_0001
Hadoop job information for Stage-0: number of mappers: 1; number of reducers: 0
2017-01-17 00:47:53,388 Stage-0 map = 0%,  reduce = 0%
2017-01-17 00:48:21,381 Stage-0 map = 100%,  reduce = 0%, Cumulative CPU 6.54 sec
MapReduce Total cumulative CPU time: 6 seconds 540 msec
Ended Job = job_1484619043631_0001
MapReduce Jobs Launched:
Stage-Stage-0: Map: 1   Cumulative CPU: 7.34 sec   HDFS Read: 15889 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 7 seconds 340 msec
OK
Time taken: 108.485 seconds
hive> select count(*) from pokes;
Query ID = hadoop_20170117004939_099ed588-fbb4-4b9a-ac1c-1fb6259e7d11
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapreduce.job.reduces=<number>
Starting Job = job_1484619043631_0002, Tracking URL = http://ubuntu:8088/proxy/application_1484619043631_0002/
Kill Command = /home/hadoop/hadoop/bin/hadoop job  -kill job_1484619043631_0002
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
2017-01-17 00:50:10,356 Stage-1 map = 0%,  reduce = 0%
2017-01-17 00:50:30,514 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.94 sec
2017-01-17 00:50:49,055 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 6.38 sec
MapReduce Total cumulative CPU time: 6 seconds 380 msec
Ended Job = job_1484619043631_0002
MapReduce Jobs Launched:
Stage-Stage-1: Map: 1  Reduce: 1   Cumulative CPU: 6.38 sec   HDFS Read: 12409 HDFS Write: 4 SUCCESS
Total MapReduce CPU Time Spent: 6 seconds 380 msec
OK
500
Time taken: 72.3 seconds, Fetched: 1 row(s)
hive> select count(*) from hbase_table_1;
Query ID = hadoop_20170117005103_2fa584c7-0c2f-4b40-bc86-093f01e35a00
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapreduce.job.reduces=<number>
Starting Job = job_1484619043631_0003, Tracking URL = http://ubuntu:8088/proxy/application_1484619043631_0003/
Kill Command = /home/hadoop/hadoop/bin/hadoop job  -kill job_1484619043631_0003
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
2017-01-17 00:51:53,774 Stage-1 map = 0%,  reduce = 0%
2017-01-17 00:52:16,564 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 6.42 sec
2017-01-17 00:52:36,997 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 9.93 sec
MapReduce Total cumulative CPU time: 9 seconds 930 msec
Ended Job = job_1484619043631_0003
MapReduce Jobs Launched:
Stage-Stage-1: Map: 1  Reduce: 1   Cumulative CPU: 9.93 sec   HDFS Read: 13551 HDFS Write: 4 SUCCESS
Total MapReduce CPU Time Spent: 9 seconds 930 msec
OK
309
Time taken: 95.345 seconds, Fetched: 1 row(s)
hive> drop table pokes;
OK
Time taken: 3.374 seconds
hive> select * from pokes;
FAILED: SemanticException [Error 10001]: Line 1:14 Table not found 'pokes'
hive> drop table hbase_table_1;
OK
Time taken: 4.64 seconds
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误通常意味着Hive不能找到所需的执行jar包。你可以尝试以下几个步骤: 1. 检查Hive的配置是否正确,并确保`hive-exec-*.jar`文件存在于`/opt/module/apache-hive-1.2.1-bin/lib/`目录中。如果不存在,你可能需要重新安装Hive。 2. 检查你的环境变量是否正确设置。确保`HIVE_HOME`指向正确的Hive安装目录,并将`$HIVE_HOME/bin`添加到`$PATH`中。 3. 如果你正在使用Hadoop集群,请确保HiveHadoop版本兼容。不同版本Hive可能需要不同版本Hadoop支持。 4. 如果你正在使用远程Hive服务器,请确保你的客户端能够访问Hive服务器,并且Hive服务器上的配置正确。 如果以上步骤都没有解决问题,你可能需要查看Hive的日志文件,以确定更具体的错误信息。 ### 回答2: 在Hive中执行任务时,可能会遇到"Missing Hive Execution Jar"错误,表示Hive无法找到所需的hive-exec-*.jar文件。这个问题通常发生在缺少Hive的执行文件或文件位置错误的情况下。 要解决这个问题,可以按照以下步骤进行操作: 1. 首先,确保在指定的路径/opt/module/apache-hive-1.2.1-bin/lib/中存在hive-exec-*.jar文件。如果文件确实存在,那么可能是权限问题导致Hive无法读取该文件。可以使用chmod命令修改文件权限,确保Hive可以访问该文件。 2. 如果文件确实存在,并且权限设置正确,但Hive仍然无法找到该文件,可以尝试重新设置Hive的环境变量。在Hive配置文件中(通常是hive-env.sh或hive-site.xml),检查hive.exec.jar路径的设置。确保该路径正确地指向hive-exec-*.jar文件所在的位置。 3. 最后,可以通过重新安装Hive来解决该问题。在重新安装之前,确保彻底卸载Hive,并删除掉相关的文件和目录,然后重新安装最新版本Hive。 总之,解决"Missing Hive Execution Jar"错误的关键是确保hive-exec-*.jar文件存在且位置正确,并检查Hive的环境变量和配置文件中的设置是否正确。如果问题仍然存在,可以尝试重新安装Hive来解决该问题。 ### 回答3: 缺少Hive执行Jar包:/opt/module/apache-hive-1.2.1-bin/lib/hive-exec-*.jar。 这个错误表示在指定的路径中缺少Hive执行Jar包。Hive使用这个Jar包来执行Hive查询和任务。 要解决这个问题,首先需要确认是否正确安装了Hive,并且路径设置正确。如果路径不正确,可以在Hive配置文件中更正路径。 另外,还需要确认是否存在这个Jar包,并且该Jar包的版本Hive版本兼容。需要确保Hive执行Jar包与所使用的Hive版本匹配,否则可能会出现兼容性问题。 如果确保了路径和版本都是正确的,但依然缺少该Jar包,可以尝试重新下载并安装Hive。在安装过程中,确保将Hive执行Jar包正确地放置在指定的路径下。 如果还是无法解决问题,可能需要查看Hive的日志文件以获取更多详细的错误信息。根据日志中的具体错误,可以进一步排查可能的原因,并采取相应的解决措施。 总结来说,缺少Hive执行Jar包的错误是由于路径设置不正确或Jar包版本不兼容引起的。通过检查路径配置、重新下载安装和查看日志文件等步骤,可以解决这个问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值