mysql導入hbase可以直接通過sqoop進行微猖,但是hbase導出到mysql無法直接進行以故,需要經(jīng)過hive的中間作用來完成次洼,思路是這樣的hbase→hive外部表→hive內(nèi)部表→sqoop導出→mysql戚揭,這就需要hive和hbase 的整合集成
1雕旨、Hive和HBase整合集成
http://www.reibang.com/p/e9d1ccfc6ff1
2、Hive與HBase集成測試案例一
http://www.reibang.com/p/c43b5f530174
3悲柱、Hive與HBase集成測試案例二
http://www.reibang.com/p/3c0be7c78160
4锋喜、在mysql數(shù)據(jù)庫中創(chuàng)建hbase_staff表,為hbase導入做準備
mysql> create table hbase_staff(id int(4) , name varchar(255), sex varchar(255));
5豌鸡、創(chuàng)建hive 內(nèi)部表
hive> drop table nhbase;
hive> create table nhbase(id int,name string,sex string) row format delimited fields terminated by '\t';
6嘿般、創(chuàng)建Hive外部表,關聯(lián)HBase表
hive> create external table whbase(id int,name string,sex string)
> stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
> with serdeproperties("hbase.columns.mapping"=":key,info:name,info:sex")
> tblproperties("hbase.table.name"="staff_hbase");
7直颅、查詢Hive外部表
hive> select * from whbase;
8博个、把hive外部關聯(lián)hbase的表,通過查詢導入到hive內(nèi)部表
hive> insert overwrite table nhbase select * from whbase;
9功偿、查詢內(nèi)部表
hive> select * from nhbase;
10盆佣、通過sqoop把hive內(nèi)部表數(shù)據(jù)導入到mysql表中
完成hbase表數(shù)據(jù)到mysql表的全過程
[victor@node1 sqoop-1.4.7]$ bin/sqoop export \
--connect jdbc:mysql://node1:3306/company \
--username root \
--password 000000 \
--table hbase_staff \
--num-mappers 1 \
--export-dir /user/hive/warehouse/nhbase \
--input-fields-terminated-by "\t"