Hbase进阶

通过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 <table-name> <region-1> <region-2>
【注】<region-1><region-2>包括“表名,分界点,时间戳.regionId.”

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】

相关推荐

  1. Hbase

    2024-01-06 09:44:04       34 阅读
  2. CSS<span style='color:red;'>进</span><span style='color:red;'>阶</span>

    CSS

    2024-01-06 09:44:04      29 阅读
  3. C++:模板

    2024-01-06 09:44:04       31 阅读
  4. SQLMap使用

    2024-01-06 09:44:04       34 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-06 09:44:04       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-06 09:44:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-06 09:44:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-06 09:44:04       20 阅读

热门阅读

  1. 数据库索引的使用

    2024-01-06 09:44:04       33 阅读
  2. 【记录】如何提高sql执行效率?

    2024-01-06 09:44:04       42 阅读
  3. k8s之pod组件

    2024-01-06 09:44:04       40 阅读
  4. 区块链智能合约测试框架Foundry技术指南

    2024-01-06 09:44:04       41 阅读
  5. [运维|gitlab] docker Gitlab 命令行后台修改密码

    2024-01-06 09:44:04       38 阅读
  6. 正则表达式基础

    2024-01-06 09:44:04       48 阅读
  7. linux驱动-poll使用笔记

    2024-01-06 09:44:04       33 阅读