hive创建hbase映射表
hbase创建表,导入数据
/opt/app/hbase-2.1.0/bin/hbase shell
查看已有表,创建新表,查看表结构
list
create 'student', 'info', 'score'
desc 'student'
插入数据,查询表,查询记录
put 'student', '001', 'info:name', 'zhanghua'
put 'student', '001', 'info:sex', 'man'
put 'student', '001', 'score:Math', 78
put 'student', '002', 'info:name', 'wangmeng'
put 'student', '002', 'info:sex', 'woman'
put 'student', '002','score:Math', 92
scan 'student'
get 'student', '001'
建立hive与hbase映射
连接hive, 查看数据库、数据表
show databases;
use default;
创建hive映射表
create external table hbase_stu (key string,
name string,
sex string,
Math int)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping"=":key,info:name,info:sex,score:Math")
tblproperties ("hbase.table.name"="student");
查看表结构,详细表信息
desc hbase_stu;
describe extended hbase_stu;
执行SQL查询、统计
select count(*) from hbase_stu;
select * from hbase_stu where key = '001';