将对 hbase-0.90.6 和 hive-0.8.1 进行集成,使用的 hadoop-0.20.2
1. 首先将 hbase-0.90.6.jar 和 zookeeper-3.3.2.jar 复制到 hive/lib 目录下
注意:如果 hive/lib 下已经存在这两个文件的其他版本(例如 zookeeper-3.3.1.jar ),建议删除后使用 hbase 下的相关版本
2. 在 hive/conf 下 hive-site.xml 文件中添加如下的内容:
<property>
<name>hive.aux.jars.path</name>
<value>file:///home/hadoop/hadoop/hive-0.8.1/lib/hive-hbase-handler-0.8.1.jar,file:///home/hadoop/hadoop/hive-0.8.1/lib/hbase-0.90.6.jar,file:///home/hadoop/hadoop/hive-0.8.1/lib/zookeeper-3.3.2.jar</value>
</property>
这个需要根据自己的具体文件路径指定
3. 拷贝 hbase-0.90.6.jar 到所有 hadoop 节点 ( 包括 master) 的 hadoop/lib 下
4. 拷贝 hbase/conf 下的 hbase-site.xml 文件到所有 hadoop 节点 ( 包括 master) 的 hadoop/conf 下
5. 单结点启动 hive ,伪分布式属于单结点:
bin/hive -hiveconf hbase.master=localhost:60000
集群启动:
bin/hive -hiveconf hbase.zookeeper.quorum=slave
如何 hive-site.xml 文件中没有配置 hive.aux.jars.path ,则可以按照如下方式启动。
bin/hive --auxpath /usr/local/hive/lib/hive-hbase-handler-0.8.0.jar, /usr/local/hive/lib/hbase-0.90.5.jar, /usr/local/hive/lib/zookeeper-3.3.2.jar
-hiveconf hbase.zookeeper.quorum=slave
6. 创建 hbase 识别的数据,这个操作在 hive 下进行:
create table hive_hbase(key string,age int,sex int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with SERDEPROPERTIES("hbase.columns.mapping" = ":key,cf1:age,cf1:sex")tblproperties("hbase.table.name" = "hbase_hive");
7. 在 hbase 下面查看数据:
list
8. 创建临时表 person :
create table person(name string, age int, sex int) row format delimited fields terminated by '\t' stored as textfile;
9. 往临时表中添加数据:
load data local inpath '/home/hadoop/Desktop/data.txt' overwrite into table person;
10. 往 hive_hbase 表中添加数据:
insert overwrite table hive_hbase select * from person;
11. 查看表中数据:
select * from person limit 5;
12.hbase 中查看数据:
scan 'hbase_hive'