hive创建hbase映射表

芒果1年前技术文章570

hbase创建表,导入数据
/opt/app/hbase-2.1.0/bin/hbase shell
查看已有表,创建新表,查看表结构
list
create 'student', 'info', 'score'
desc 'student'

2ADD9119-D72F-494B-8132-F59A6C0C3DC4.png
插入数据,查询表,查询记录
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'

5C8393BD-811B-4C9C-B3E4-12B6E425312C.png

建立hive与hbase映射

连接hive, 查看数据库、数据表
show databases;
use default;
7BD391C4-2C8D-4EF0-90C3-315EF0D18D3F.png
创建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;
6B31802B-8C3A-4FD3-A718-7D39D7D4EE2C.png
describe extended hbase_stu;

执行SQL查询、统计
select count(*) from hbase_stu;
05096CAD-67CF-45FD-A93A-DE505352A88B.png
select * from hbase_stu where key = '001';

84C6F1DE-00BF-4728-A63A-279557F9E7D3.png

相关文章

Jenkinsfile说明

Jenkinsfile说明

当我们在使用jenkins进行CI/CD的时候,简单的内容我们可以通过jenkins页面来实现配置。但是如果有复杂的需求还是需要通过jenkinsfile来实现jenkinsfile简单介绍Jenki...

如何重塑IT运维核心竞争力?可观测运维这么做!

如何重塑IT运维核心竞争力?可观测运维这么做!

随着云计算、大数据、人工智能等新兴技术的兴起及运用,无论是通讯、金融、教育,还是交通、政府、企业等行业,都得到飞速发展,但在高速发展的同时,各行业巨大的 IT 维护和管理成本也在与日俱增,存在监控工具...

基于Gitlab和Kubernetes的CI/CD

基于Gitlab和Kubernetes的CI/CD

此套CI/CD流程仅依赖gitlab。runner等组件安装在kubernetes集群中,尽量减少其他依赖,便于维护。依赖介绍gitlab runnergitlab runner用来运行我们的作业并将...

磁盘分盘脚本分享

磁盘分区脚本名称:mg_fdisk.sh#!/bin/bashif [ "$#" -ne 1 ]; then  echo "请传入磁盘参数"  exit 1fidisk=$1# 检查磁盘是否存在if...

hive 报 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster

hive 报 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster

解决办法:关键需要配置两个配置:mapred-site.xml 和 yarn-site.xml下面配置hadoop classpath。先运行shell命令:hadoop classpath添加一个配...

Debezium抽取SQL Server同步kafka

Debezium抽取SQL Server同步kafka

ebezium SQL Server连接器捕获SQL Server数据库模式中发生的行级更改。官方2.0文档:https://debezium.io/documentation/reference/2...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。