hbase结合hive和sqoop实现导数据到mysql

25 篇文章 0 订阅
[size=large][b]hive整合hbase表的两点好处:[/b][/size]
[color=blue][size=medium][b] 1.实现数据导入到MYSQL。
2.实现hbase表转换为另外一张hbase表。[/b][/size][/color]


三个操作环节:
1.hbase关联hive作为外部表:
CREATE EXTERNAL TABLE hive_device_app(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:genera_type,cf:install_type,cf:label,cf:meid,cf:model,cf:pkg_name,cf:specific_type")
TBLPROPERTIES("hbase.table.name" = "tb_yl_device_app_info1");


2.hbase真正关联hive,hive的插入更新等操作直接影响hbase中的数据
CREATE  TABLE hbase_device_app(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:genera_type,cf:install_type,cf:label,cf:meid,cf:model,cf:pkg_name,cf:specific_type")
TBLPROPERTIES("hbase.table.name" = "tb_yl_device_app_info2");


3.创建一张hive表
CREATE TABLE hive_device_app_real(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string) 


4.外部表数据导入hive实表
insert overwrite table hive_device_app_real select * from hive_device_app 

5.sqoop导出hive的数据到mysql
sqoop export --connect jdbc:mysql://Hadoop48/toplists -m 1 --table hive_device_app_real --export-dir /user/hive/warehouse/hive_device_app_real/000000_0 --input-null-string "\\\\N" --input-null-non-string "\\\\N" --input-fields-terminated-by "\\01" --input-lines-terminated-by "\\n"


6.habse(关联hive)中一张表转到另外一张表当然可以利用hive的内置函数实现数据处理
insert overwrite table another_hive_hbase_related_table select * from hbase_device_app 



[size=medium][color=red][b]导出hbase中数据到mysql需要经过步骤:1345
hbase中一张表到另外一张表(中间可以利用hive内置函数做数据处理):226[/b][/color][/size]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值