博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hbase shell基本操作
阅读量:4136 次
发布时间:2019-05-25

本文共 3089 字,大约阅读时间需要 10 分钟。

1、启动

cd <hbase_home>/bin
$ ./start-hbase.sh

2、启动hbase shell

# find hadoop-hbase dfs files

hadoop fs -ls /hbase

#start shell

hbase shell

#Run a command to verify that cluster is actually running#

list

3、logs配置
Change the default by editing <hbase_home>/conf/hbase-env.sh
export HBASE_LOG_DIR=/new/location/logs

4、后台管理

HBase comes with web based management

– http://localhost:60010

5、端口服务

Both Master and Region servers run web server

– Browsing Master will lead you to region servers
– Regions run on port 60030

6、基本命令

Quote all names

Table and column names
– Single quotes for text
• hbase> get 't1', 'myRowId'
– Double quotes for binary
• Use hexadecimal representation of that binary value
• hbase> get 't1', "key\x03\x3f\xcd"

Display cluster's status via status command

– hbase> status
– hbase> status 'detailed'
• Similar information can be found on HBase
Web Management Console
– http://localhost:60010

7、建表

Create Table

Create table called 'Blog' with the following

schema
– 2 families
–'info' with 3 columns: 'title', 'author', and 'date'
–'content' with 1 column family: 'post'
首先建立表,附带列族columns families
create 'Blog', {NAME=>'info'}, {NAME=>'content'}
然后,添加数据,注意hbase是基于rowkey的列数据库,可以一次添加一列或多列,必须每次添加指定rowkey
使用Put命令:
hbase> put 'table', 'row_id', 'family:column', 'value'
例子:
put 'Blog', 'Michelle-001', 'info:title', 'Michelle'
put 'Blog', 'Matt-001', 'info:author', 'Matt123'
put 'Blog', 'Matt-001', 'info:date', '2009.05.01'
put 'Blog', 'Matt-001', 'content:post', 'here is content'

列可以任意的扩展,比如

put 'Blog', 'Matt-001', 'content:news', 'news is new column'

8、查看数据-指定rowid

#查看数据库

count 'Blog'
count 'Blog', {INTERVAL=>2}

#查看行数据

get 'table', 'row_id'
get 'Blog', 'Matt-001'
get 'Blog', 'Matt-001',{COLUMN=>['info:author','content:post']}
#时间戳
get 'Blog', 'Michelle-004',{COLUMN=>['info:author','content:post'],TIMESTAMP=>1326061625690}
#版本
get 'Blog', 'Matt-001',{ VERSIONS=1}
get 'Blog', 'Matt-001',{COLUMN=>'info:date', VERSIONS=1}
get 'Blog', 'Matt-001',{COLUMN=>'info:date', VERSIONS>=2}
get 'Blog', 'Matt-001',{COLUMN=>'info:date'}

9、查看数据-通过scan指定范围,注意,所有的记录均按时间戳作为范围排序
Limit what columns are retrieved
– hbase> scan 'table', {COLUMNS=>['col1', 'col2']}
• Scan a time range
– hbase> scan 'table', {TIMERANGE => [1303, 13036]}
• Limit results with a filter
– hbase> scan 'Blog', {FILTER =>org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
– More about filters later

scan 'Blog', {COLUMNS=>'info:title'}

开始于John,结束并排除Matt的
scan 'Blog', {COLUMNS=>'info:title',STARTROW=>'John', STOPROW=>'Matt'}
scan 'Blog', {COLUMNS=>'info:title', STOPROW=>'Matt'}

10、版本
put 'Blog', 'Michelle-004', 'info:date', '1990.07.06'
put 'Blog', 'Michelle-004', 'info:date', '1990.07.07'
put 'Blog', 'Michelle-004', 'info:date', '1990.07.08'
put 'Blog', 'Michelle-004', 'info:date', '1990.07.09'
get 'Blog', 'Michelle-004',{COLUMN=>'info:date', VERSIONS=>3}

11、Delete records
delete 'Blog', 'Bob-003', 'info:date'

12、Drop table

– Must disable before dropping
– puts the table “offline” so schema based operations can
be performed
– hbase> disable 'table_name'
– hbase> drop 'table_name'

转载地址:http://uapvi.baihongyu.com/

你可能感兴趣的文章
python数字逆序输出及多个print输出在同一行
查看>>
苏宁产品经理面经
查看>>
百度产品经理群面
查看>>
去哪儿一面+平安科技二面+hr面+贝贝一面+二面产品面经
查看>>
element ui 弹窗在IE11中关闭时闪现问题修复
查看>>
vue 遍历对象并动态绑定在下拉列表中
查看>>
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>
pytorch(三)
查看>>
ubuntu相关
查看>>
C++ 调用json
查看>>
nano中设置脚本开机自启动
查看>>
动态库调动态库
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>
手绘VS码绘(一):静态图绘制(码绘使用P5.js)
查看>>
手绘VS码绘(二):动态图绘制(码绘使用Processing)
查看>>