通过hive操作hbase的注意事项:
(1)启动yarn服务:
yarn-daemon.sh start resourcemanager
yarn-daemon.sh start nodemanager
(2)在hive中建表时附加上:
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with
serdeproperties ("hbase.columns.mapping"=":key,列族:列名,...")
tblproperties("hbase.table.name" = "表名");
=====例1=====
--在hbase中创建表
create 'customer','order','addr'
--在hive中创建表映射
create external table customer(
name string,
order_numb string,
order_date string,
addr_city string,
addr_state string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with
serdeproperties ("hbase.columns.mapping"=":key,order:numb,order:date,addr:city,addr:state")
tblproperties("hbase.table.name" = "customer")
;
--在hive中执行以下更新查询操作
insert into table customer values ('James','1121','2018-05-31','toronto','ON');
select * from customer;
--在hbase中执行如下语句
scan 'customer'
put 'customer','Smith','order:numb','1122'
put 'customer','Smith','order:date','2019-09-12'
put 'customer','Smith','addr:city','beijing'
put 'customer','Smith','addr:state','HD'
--在hive中执行以下查询操作
select * from customer;
=====例2=====
1.在hbase中创建表
--不要create 'hive_hbase_emp_table','info'
2.实现Hive中创建表hive_hbase_emp_table关联HBase
CREATE TABLE hive_hbase_emp_table(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
TBLPROPERTIES ("hbase.table.name" = "hive_hbase_emp_table");
3.在Hive中插入数据,通过HBase查询
--hive中执行如下语句
insert into table hive_hbase_emp_table values(1,'Eric','Developer',5,'2019-12-18',2800.0,312.0,10);
--hbase shell中执行如下语句
scan 'hive_hbase_emp_table'
4.在HBase中插入数据,通过Hive查询
--在hbase shell中执行如下语句
put 'hive_hbase_emp_table','2','info:ename','zhangsan'
--在hive中执行如下语句
select * from hive_hbase_emp_table;
指定拆分算法,在linux中执行:
hbase org.apache.hadoop.hbase.util.RegionSplitter test_split1 HexStringSplit -c 10 -f mycf
#指定拆分点
create 'test_split2','mycf2',SPLITS=>['aaa','bbb','ccc','ddd','eee','fff']
#指定拆分文件
先在linux中创建以下内容的文件:
aaa
bbb
ccc
ddd
eee
fff
再在hbase中创建表
create 'test_split3','baseinfo',SPLITS_FILE => '/root/data/splits.txt'
Region 冷合并【必须先停止hbase服务,在linux中执行】
hbase org.apache.hadoop.hbase.util.Merge
【注】
Region 热合并【无需停止hbase服务,在hbase中执行】
merge 'region-1','region-2'
【注】region-1和region-2是指regionId
HFile minor合并
hbase.hregion.memstore.flush.size【134217728B=128M】
hbase.regionserver.optionalcacheflushinterval【3600000ms=1h】
hbase.hstore.compactionThreshold【3】
hbase.hstore.compaction.max【10】
HFile major合并
hbase.hregion.majorcompaction【604800000ms】
猜你喜欢
- 3天前(福朋喜来登酒店宴会厅)福朋喜来登品牌亮相北部湾城市群 阳江中心福朋喜来登酒店开业
- 3天前(曼谷丽思卡尔顿公寓价格)在曼谷丽思卡尔顿酒店CALEŌ 邂逅鸡尾酒的浪漫艺术
- 3天前(071 圣安东尼奥)秋季 圣安东尼奥交出了私藏活动清单
- 3天前(苏梅岛普吉岛哪个好玩)苏梅岛金普顿基塔蕾度假酒店推出家庭度假套餐
- 3天前(锦州新增两家国家aaa级旅游景区有哪些)锦州新增两家国家AAA级旅游景区
- 3天前(2025年安徽省“百场黄梅唱响百家景区”示范展示启动)2025年安徽省“百场黄梅唱响百家景区”示范展示启动
- 3天前(新西兰旅游局×时差岛:黄觉的“长白云之乡”奇遇)新西兰旅游局×时差岛:黄觉的“长白云之乡”奇遇
- 3天前(内蒙古冬季旅游攻略)内蒙古冬日奇遇:携程租车带你策马踏雪
- 3天前(携程租车加盟合作)携程租车加盟优势全解析:开启旅游出行市场新篇章
- 3天前(泛舟诗海觅春迹什么意思)泛舟觅桃源,又一头部机构下场文旅赛道
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章