hive hbase 整合
来源:互联网 发布:如何找回域名密码 编辑:程序博客网 时间:2024/06/11 14:28
Hadoop Hive与Hbase整合
为了更好的使用hive 和hbase 这里介绍一下 hive 和hbase 的整合,这样能够在你往hive里面存储数据的时候同时往hbase里面存储数据,形成hbase与hive 的同步;
wiki : https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration
wiki : https://cwiki.apache.org/confluence/display/Hive/StorageHandlers
一、进行hive配置
1. 拷贝hbase-common-0.98.6-cdh5.2.0.jar和zookeeper-3.4.5-cdh5.2.0.jar到hive/lib下。
注意:如何hive/lib下已经存在这两个文件的其他版本,建议删除后使用hbase下的相关版本。
2. 修改hive/conf下hive-site.xml文件,在底部添加如下内容:
<property><name>hive.aux.jars.path</name><value>file:///home/kkzhangtao/hive-0.13.1-cdh5.2.0/lib/hive-hbase-handler-0.8.0.jar,file:///home/kkzhangtao/hive-0.13.1-cdh5.2.0/lib/hbase-common-0.98.6-cdh5.2.0.jar,file:///home/kkzhangtao/hive-0.13.1-cdh5.2.0/lib/zookeeper-3.4.5-cdh5.2.0.jar</value></property>
注意:如果hive-site.xml不存在则自行创建,或者把hive-default.xml.template文件改名后使用。
3. 拷贝hbase-common-0.98.6-cdh5.2.0.jar到所有hadoop节点(包括master)的hadoop/lib下。
4. 拷贝hbase/conf下的hbase-site.xml文件到所有hadoop节点(包括master)的hadoop/conf下。
二、进入hive,创建hive表(与hbase关联)
1、进入hive
> bin/hive -hive
2、创建hive表
1>若hbase里面不存在需要创建的表
use hive_hbase_test;create table hive_hbase(rowkey varchar(64),andx_item_id char(32) ,xcount int ) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties ("hbase.columns.mapping" = ":key, service_info: id,service_info: xcount ") tblproperties ("hbase.table.name" = "hive_hbase") ;
hbase.table.name 不是必写项, 定义在hbase的table名称 例如:hive_hbase;;若是不写的话 默认与hive的表名称相同 例如:hive_hbase_test.hive_hbase;
hbase.columns.mapping 是必填的,是对用hbase里面的key 和 列族
2>若hbase里面存在需要创建的表
use hive_hbase_test;create EXTERNAL table hive_hbase(rowkey varchar(64),andx_item_id char(32) ,xcount int ) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties ("hbase.columns.mapping" = ":key, service_info: id,service_info: xcount ") tblproperties ("hbase.table.name" = some_existing_table") ;
3、在hive里面创建数据
non-native类型的表是不能使用load 的,所以需要建立一个中间表,把文件数据load进去
建立文件 hive_hbase 内容如下: 111111111_1 4028800947af3bf00147af4037c30001 23111111111_2 4028800947af3bf00147af4037c30001 30
建立中间表
use hive_hbase_test;create table hive_hbase_temp(rowkey varchar(64),andx_item_id char(32) ,xcount int ) ;
导入文件到中间表 hive_hbase_temp:
>LOAD DATA LOCAL INPATH '/home/fulong/Fulong/hive_hbase.txt' OVERWRITE INTO TABLE hive_hbase_temp;
把中间的表数据导入到hive_hbase中
INSERT OVERWRITE TABLE hive_hbase select * from hive_hbase_temp;
4、 查看hbase 和 hive 的 数据
hive > select * from hive_hbase;
hbase > scan hive_hbase_test.hive_hbase;
0 0
- hive系列-hive整合hbase
- Hbase和Hive整合
- Hive HBase 整合
- Hive HBase 整合(中文)
- Hive HBase 整合(中文)
- hive+hbase整合
- hive与hbase整合
- hbase,hive整合
- hive 整合 hbase
- HADOOP、HIVE、HBASE整合
- hbase和hive整合
- hive hbase整合
- Hive HBase 集群整合
- Hive和Hbase整合
- hbase与hive整合
- hive与hbase整合
- hive与Hbase整合
- Hive HBase 整合
- iOS开发 ARC下造成内存泄露的问题
- hdu 2212
- mllib svm分类
- Android开发中高效的数据结构用SparseArray代替HashMap
- 关于项目依赖问题
- hive hbase 整合
- mybatis 批处理更新
- 用Mysql5.6插入出现时间问题Incorrect datetime value: '' for column 'createtime'
- DBCP连接池原理分析
- 第十六周 项目一:平方根中的异常
- Tiling
- cookie和session的详细讲解
- iOS TableView实现QQ好友列表(一)
- GridView异步加载中一次加载完所有数据问题的解决以及其原因分析