Home >Database >Mysql Tutorial >hbase组合hive和sqoop实现导数据到mysql
hbase结合hive和sqoop实现导数据到mysql hive整合hbase表的两点好处: 1.实现数据导入到MYSQL。 2.实现hbase表转换为另外一张hbase表。 三个操作环节: 1.hbase关联hive作为外部表: CREATE EXTERNAL TABLE hive_device_app(row_key string,genera_type strin
hbase结合hive和sqoop实现导数据到mysqlCREATE 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");
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");
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)
insert overwrite table hive_device_app_real select * from hive_device_app
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"
insert overwrite table another_hive_hbase_related_table select * from hbase_device_app