创建一个表

hbase(main):002:0> create 'member', 'cf_tmp', 'address', 'info'

查看所有表清单

hbase(main):003:0> list
TABLE
member
1 row(s) in 0.0210 seconds

  

查看表描述

hbase(main):004:0> describe 'member'
Table member is ENABLED
member
COLUMN FAMILIES DESCRIPTION
{
NAME => 'address',
BLOOMFILTER => 'ROW',
VERSIONS => '1',
IN_MEMORY => 'false',
KEEP_DELETED_CELLS => 'FALSE',
DATA_BLOCK_ENCODING => 'NONE',
TTL => 'FOREVER',
COMPRESSION => 'NONE',
MIN_VERSIONS => '0',
BLOCKCACHE => 'true',
BLOCKSIZE => '65536',
REPLICATION_SCOPE => '0'
} {
NAME => 'cf_tmp',
BLOOMFILTER => 'ROW',
VERSIONS => '1',
IN_MEMORY => 'false',
KEEP_DELETED_CELLS => 'FALSE',
DATA_BLOCK_ENCODING => 'NONE',
TTL => 'FOREVER',
COMPRESSION => 'NONE',
MIN_VERSIONS => '0',
BLOCKCACHE => 'true',
BLOCKSIZE => '65536',
REPLICATION_SCOPE => '0' } {
NAME => 'info',
BLOOMFILTER => 'ROW',
VERSIONS => '1',
IN_MEMORY => 'false',
KEEP_DELETED_CELLS => 'FALSE',
DATA_BLOCK_ENCODING => 'NONE',
TTL => 'FOREVER',
COMPRESSION => 'NONE',
MIN_VERSIONS => '0',
BLOCKCACHE => 'true',
BLOCKSIZE => '65536',
REPLICATION_SCOPE => '0'
}
3 row(s) in 0.0330 seconds

浏览表中的数据

hbase(main):005:0> scan 'member'
ROW COLUMN+CELL
0 row(s) in 0.0580 seconds

  

删除一个列簇

hbase(main):006:0> disable 'member'
0 row(s) in 1.2720 seconds hbase(main):007:0> is_disabled 'member'
true
0 row(s) in 0.0110 seconds hbase(main):009:0> alter 'member', {NAME=>'cf_tmp', METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.1620 seconds hbase(main):010:0> enable 'member'
0 row(s) in 0.4120 seconds

插入几条数据

hbase(main):012:0> put 'member', '43010319820725XXXX', 'info:name', 'zhoulin'
0 row(s) in 0.0690 seconds hbase(main):013:0> put 'member', '43010319820725XXXX', 'info:age', '35'
0 row(s) in 0.0260 seconds hbase(main):014:0> put 'member', '43010319820725XXXX', 'info:birthday', '1982-07-25'
0 row(s) in 0.0190 seconds hbase(main):015:0> put 'member', '43010319820725XXXX', 'info:company', 'asiainfo'
0 row(s) in 0.0110 seconds hbase(main):016:0> put 'member', '43010319820725XXXX', 'address:contry', 'china'
0 row(s) in 0.0220 seconds hbase(main):017:0> put 'member', '43010319820725XXXX', 'address:province', 'hunan'
0 row(s) in 0.0140 seconds hbase(main):018:0> put 'member', '43010319820725XXXX', 'address:city', 'changsha'
0 row(s) in 0.0440 seconds hbase(main):019:0> scan 'member'
ROW COLUMN+CELL
43010319820725XXXX column=address:city, timestamp=1501569028721, value=changsha
43010319820725XXXX column=address:contry, timestamp=1501569027675, value=china
43010319820725XXXX column=address:province, timestamp=1501569027715, value=hunan
43010319820725XXXX column=info:age, timestamp=1501569027579, value=35
43010319820725XXXX column=info:birthday, timestamp=1501569027617, value=1982-07-25
43010319820725XXXX column=info:company, timestamp=1501569027640, value=asiainfo
43010319820725XXXX column=info:name, timestamp=1501569018899, value=zhoulin

1 row(s) in 0.0170 seconds

获取数据

// 获取 指定ROWKEY的所有数据
hbase(main):020:0> get 'member', '43010319820725XXXX'
COLUMN CELL
address:city timestamp=1501569028721, value=changsha
address:contry timestamp=1501569027675, value=china
address:province timestamp=1501569027715, value=hunan
info:age timestamp=1501569027579, value=35
info:birthday timestamp=1501569027617, value=1982-07-25
info:company timestamp=1501569027640, value=asiainfo
info:name timestamp=1501569018899, value=zhoulin
7 row(s) in 0.0370 seconds // 获取 指定ROWKEY、指定列簇的所有数据
hbase(main):031:0> get 'member', '43010319820725XXXX', 'info'
COLUMN CELL
info:age timestamp=1501569027579, value=35
info:birthday timestamp=1501569027617, value=1982-07-25
info:company timestamp=1501569027640, value=asiainfo
info:name timestamp=1501569018899, value=zhoulin
4 row(s) in 0.0300 seconds // 获取 指定ROWKEY、指定列的数据
hbase(main):032:0> get 'member', '43010319820725XXXX', 'info:age'
COLUMN CELL
info:age timestamp=1501569027579, value=35
1 row(s) in 0.0350 seconds // 获取 指定列簇、指定列,指定时间戳的数据
hbase(main):034:0> get 'member', '43010319820725XXXX', {COLUMN=>'info:age', TIMESTAMP=>1501569027579}
COLUMN CELL
info:age timestamp=1501569027579, value=35
1 row(s) in 0.0160 seconds

更新一条记录

hbase(main):001:0> put 'member', '43010319820725XXXX', 'info:age', '30'
0 row(s) in 0.4880 seconds hbase(main):002:0> get 'member', '43010319820725XXXX'
COLUMN CELL
address:city timestamp=1501569028721, value=changsha
address:contry timestamp=1501569027675, value=china
address:province timestamp=1501569027715, value=hunan
info:age timestamp=1501570309732, value=30
info:birthday timestamp=1501569027617, value=1982-07-25
info:company timestamp=1501569027640, value=asiainfo
info:name timestamp=1501569018899, value=zhoulin
7 row(s) in 0.0490 seconds

查询表中有多少行

hbase(main):003:0> count 'member'
1 row(s) in 0.0400 seconds

删除整行

hbase(main):007:0> deleteall 'member', '43010319820725XXXX'
0 row(s) in 0.0590 seconds hbase(main):008:0> scan 'member'
ROW COLUMN+CELL
0 row(s) in 0.0140 seconds

删除字段

// 删除ROWKEY为 43010319820725XXXX 的 'info:age' 字段
hbase(main):017:0> delete 'member', '43010319820725XXXX', 'info:age'
0 row(s) in 0.0110 seconds hbase(main):018:0> scan 'member'
ROW COLUMN+CELL
43010319820725XXXX column=address:city, timestamp=1501570611266, value=changsha
43010319820725XXXX column=address:contry, timestamp=1501570610720, value=china
43010319820725XXXX column=address:province, timestamp=1501570610742, value=hunan
43010319820725XXXX column=info:birthday, timestamp=1501570610574, value=1982-07-25
43010319820725XXXX column=info:company, timestamp=1501570610611, value=asiainfo
43010319820725XXXX column=info:name, timestamp=1501570610519, value=zhoulin
1 row(s) in 0.0200 seconds

  

增加字段

// 注:使用incr实现递增[不用预先增加字段salary]
hbase(main):019:0> incr 'member', '43010319820725XXXX', 'info:salary'
COUNTER VALUE = 1
0 row(s) in 0.0170 seconds hbase(main):020:0> incr 'member', '43010319820725XXXX', 'info:salary'
COUNTER VALUE = 2
0 row(s) in 0.0220 seconds hbase(main):021:0> incr 'member', '43010319820725XXXX', 'info:salary'
COUNTER VALUE = 3
0 row(s) in 0.0130 seconds hbase(main):022:0> incr 'member', '43010319820725XXXX', 'info:salary', 10000
COUNTER VALUE = 10003
0 row(s) in 0.0140 seconds hbase(main):023:0> incr 'member', '43010319820725XXXX', 'info:salary', 10000
COUNTER VALUE = 20003
0 row(s) in 0.0120 seconds hbase(main):024:0> incr 'member', '43010319820725XXXX', 'info:salary', 10000
COUNTER VALUE = 30003
0 row(s) in 0.0070 seconds hbase(main):025:0> incr 'member', '43010319820725XXXX', 'info:salary', 10000
COUNTER VALUE = 40003
0 row(s) in 0.0160 seconds hbase(main):026:0> incr 'member', '43010319820725XXXX', 'info:salary', 10000
COUNTER VALUE = 50003
0 row(s) in 0.0070 seconds // 获取计数器的值
hbase(main):027:0> get_counter 'member', '43010319820725XXXX', 'info:salary'
COUNTER VALUE = 50003 hbase(main):028:0> get 'member', '43010319820725XXXX', 'info:salary'
COLUMN CELL
info:salary timestamp=1501571074556, value=\x00\x00\x00\x00\x00\x00\xC3S
1 row(s) in 0.0120 seconds

清空表

hbase(main):029:0> scan 'member'
ROW COLUMN+CELL
43010319820725XXXX column=address:city, timestamp=1501570611266, value=changsha
43010319820725XXXX column=address:contry, timestamp=1501570610720, value=china
43010319820725XXXX column=address:province, timestamp=1501570610742, value=hunan
43010319820725XXXX column=info:birthday, timestamp=1501570610574, value=1982-07-25
43010319820725XXXX column=info:company, timestamp=1501570610611, value=asiainfo
43010319820725XXXX column=info:name, timestamp=1501570610519, value=zhoulin
43010319820725XXXX column=info:salary, timestamp=1501571074556, value=\x00\x00\x00\x00\x00\x00\xC3S
1 row(s) in 0.0180 seconds hbase(main):030:0> truncate 'member'
Truncating 'member' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 1.4890 seconds hbase(main):031:0> scan 'member'
ROW COLUMN+CELL
0 row(s) in 0.3180 seconds

过滤查询表内容

hbase(main):034:0> scan 'student'
ROW COLUMN+CELL
myrow-0000 column=info:age, timestamp=1501050432235, value=0
myrow-0000 column=info:name, timestamp=1501050432235, value=lily-0
myrow-0000 column=info:sex, timestamp=1501050432235, value=male
myrow-0001 column=info:age, timestamp=1501050432246, value=1
myrow-0001 column=info:name, timestamp=1501050432246, value=lily-1
myrow-0001 column=info:sex, timestamp=1501050432246, value=female
myrow-0002 column=info:age, timestamp=1501050432250, value=2
myrow-0002 column=info:name, timestamp=1501050432250, value=lily-2
myrow-0002 column=info:sex, timestamp=1501050432250, value=male
myrow-0003 column=info:age, timestamp=1501050432253, value=3
myrow-0003 column=info:name, timestamp=1501050432253, value=lily-3
myrow-0003 column=info:sex, timestamp=1501050432253, value=female
myrow-0004 column=info:age, timestamp=1501050432257, value=4
myrow-0004 column=info:name, timestamp=1501050432257, value=lily-4
myrow-0004 column=info:sex, timestamp=1501050432257, value=male
myrow-0005 column=info:age, timestamp=1501050432260, value=5
myrow-0005 column=info:name, timestamp=1501050432260, value=lily-5
myrow-0005 column=info:sex, timestamp=1501050432260, value=female
myrow-0006 column=info:age, timestamp=1501050432268, value=6
myrow-0006 column=info:name, timestamp=1501050432268, value=lily-6
myrow-0006 column=info:sex, timestamp=1501050432268, value=male
myrow-0007 column=info:age, timestamp=1501050432272, value=7
myrow-0007 column=info:name, timestamp=1501050432272, value=lily-7
myrow-0007 column=info:sex, timestamp=1501050432272, value=female
myrow-0008 column=info:age, timestamp=1501050432275, value=8
myrow-0008 column=info:name, timestamp=1501050432275, value=lily-8
myrow-0008 column=info:sex, timestamp=1501050432275, value=male
myrow-0009 column=info:age, timestamp=1501050432279, value=9
myrow-0009 column=info:name, timestamp=1501050432279, value=lily-9
myrow-0009 column=info:sex, timestamp=1501050432279, value=female
10 row(s) in 0.0710 seconds

// 只查看info列簇
hbase(main):035:0> scan 'student', {COLUMN=>'info'}
ROW COLUMN+CELL
myrow-0000 column=info:age, timestamp=1501050432235, value=0
myrow-0000 column=info:name, timestamp=1501050432235, value=lily-0
myrow-0000 column=info:sex, timestamp=1501050432235, value=male
myrow-0001 column=info:age, timestamp=1501050432246, value=1
myrow-0001 column=info:name, timestamp=1501050432246, value=lily-1
myrow-0001 column=info:sex, timestamp=1501050432246, value=female
myrow-0002 column=info:age, timestamp=1501050432250, value=2
myrow-0002 column=info:name, timestamp=1501050432250, value=lily-2
myrow-0002 column=info:sex, timestamp=1501050432250, value=male
myrow-0003 column=info:age, timestamp=1501050432253, value=3
myrow-0003 column=info:name, timestamp=1501050432253, value=lily-3
myrow-0003 column=info:sex, timestamp=1501050432253, value=female
myrow-0004 column=info:age, timestamp=1501050432257, value=4
myrow-0004 column=info:name, timestamp=1501050432257, value=lily-4
myrow-0004 column=info:sex, timestamp=1501050432257, value=male
myrow-0005 column=info:age, timestamp=1501050432260, value=5
myrow-0005 column=info:name, timestamp=1501050432260, value=lily-5
myrow-0005 column=info:sex, timestamp=1501050432260, value=female
myrow-0006 column=info:age, timestamp=1501050432268, value=6
myrow-0006 column=info:name, timestamp=1501050432268, value=lily-6
myrow-0006 column=info:sex, timestamp=1501050432268, value=male
myrow-0007 column=info:age, timestamp=1501050432272, value=7
myrow-0007 column=info:name, timestamp=1501050432272, value=lily-7
myrow-0007 column=info:sex, timestamp=1501050432272, value=female
myrow-0008 column=info:age, timestamp=1501050432275, value=8
myrow-0008 column=info:name, timestamp=1501050432275, value=lily-8
myrow-0008 column=info:sex, timestamp=1501050432275, value=male
myrow-0009 column=info:age, timestamp=1501050432279, value=9
myrow-0009 column=info:name, timestamp=1501050432279, value=lily-9
myrow-0009 column=info:sex, timestamp=1501050432279, value=female
10 row(s) in 0.0320 seconds // 只查看info列簇的第一个列
hbase(main):036:0> scan 'student', {COLUMN=>'info', FILTER=>"(FirstKeyOnlyFilter())"}
ROW COLUMN+CELL
myrow-0000 column=info:age, timestamp=1501050432235, value=0
myrow-0001 column=info:age, timestamp=1501050432246, value=1
myrow-0002 column=info:age, timestamp=1501050432250, value=2
myrow-0003 column=info:age, timestamp=1501050432253, value=3
myrow-0004 column=info:age, timestamp=1501050432257, value=4
myrow-0005 column=info:age, timestamp=1501050432260, value=5
myrow-0006 column=info:age, timestamp=1501050432268, value=6
myrow-0007 column=info:age, timestamp=1501050432272, value=7
myrow-0008 column=info:age, timestamp=1501050432275, value=8
myrow-0009 column=info:age, timestamp=1501050432279, value=9
10 row(s) in 0.0170 seconds

指定显示行数,指定ROWKEY开始位置

hbase(main):011:0> scan 'student', {COLUMNS=>['info'], LIMIT=>1}
ROW COLUMN+CELL
myrow-0000 column=info:age, timestamp=1501050432235, value=0
myrow-0000 column=info:name, timestamp=1501050432235, value=lily-0
myrow-0000 column=info:sex, timestamp=1501050432235, value=male
1 row(s) in 0.0370 seconds hbase(main):001:0> scan 'student', {COLUMNS=>['info'], LIMIT=>2}
ROW COLUMN+CELL
myrow-0000 column=info:age, timestamp=1501050432235, value=0
myrow-0000 column=info:name, timestamp=1501050432235, value=lily-0
myrow-0000 column=info:sex, timestamp=1501050432235, value=male
myrow-0001 column=info:age, timestamp=1501050432246, value=1
myrow-0001 column=info:name, timestamp=1501050432246, value=lily-1
myrow-0001 column=info:sex, timestamp=1501050432246, value=female
2 row(s) in 0.5840 seconds // 指定ROWKEY从哪行开始查看
hbase(main):019:0> scan 'student', {COLUMNS=>['info'], STARTROW=>'myrow-0005'}
ROW COLUMN+CELL
myrow-0005 column=info:age, timestamp=1501050432260, value=5
myrow-0005 column=info:name, timestamp=1501050432260, value=lily-5
myrow-0005 column=info:sex, timestamp=1501050432260, value=female
myrow-0006 column=info:age, timestamp=1501050432268, value=6
myrow-0006 column=info:name, timestamp=1501050432268, value=lily-6
myrow-0006 column=info:sex, timestamp=1501050432268, value=male
myrow-0007 column=info:age, timestamp=1501050432272, value=7
myrow-0007 column=info:name, timestamp=1501050432272, value=lily-7
myrow-0007 column=info:sex, timestamp=1501050432272, value=female
myrow-0008 column=info:age, timestamp=1501050432275, value=8
myrow-0008 column=info:name, timestamp=1501050432275, value=lily-8
myrow-0008 column=info:sex, timestamp=1501050432275, value=male
myrow-0009 column=info:age, timestamp=1501050432279, value=9
myrow-0009 column=info:name, timestamp=1501050432279, value=lily-9
myrow-0009 column=info:sex, timestamp=1501050432279, value=female
5 row(s) in 0.0390 seconds

  

HBase Shell基本使用总结的更多相关文章

  1. HBase Shell操作

    Hbase 是一个分布式的.面向列的开源数据库,其实现是建立在google 的bigTable 理论之上,并基于hadoop HDFS文件系统.     Hbase不同于一般的关系型数据库(RDBMS ...

  2. HBase Shell 常用命令及例子

    下面我们看看HBase Shell的一些基本操作命令,我列出了几个常用的HBase Shell命令,如下: 名称 命令表达式 创建表 create '表名称', '列名称1','列名称2','列名称N ...

  3. hbase shell command

    进入hbase shell console $HBASE_HOME/bin/hbase shell 如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成 ...

  4. hbase shell基础和常用命令详解(转)

    HBase shell的基本用法 hbase提供了一个shell的终端给用户交互.使用命令hbase shell进入命令界面.通过执行 help可以看到命令的帮助信息. 以网上的一个学生成绩表的例子来 ...

  5. hbase shell 基本命令总结

    访问hbase,以及操作hbase,命令不用使用分号hbase shell 进入hbase list 查看表hbase shell -d hbase(main):024:0> scan '.ME ...

  6. hbase shell 常用命令

    进入hbase shell console$HBASE_HOME/bin/hbase shell如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成功之 ...

  7. Hbase Shell常用命令

    hbase shell常用的操作命令有create,describe,disable,drop,list,scan,put,get,delete,deleteall,count,status等,通过h ...

  8. hbase shell中log4j重复问题

    [root@centos ~]# hbase shellSLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding ...

  9. (转)Hbase shell 常用命令(1)

    Hbase shell 常用命令(1) link:http://blog.csdn.net/scutshuxue/article/details/6988348 下面我们看看HBase Shell的一 ...

  10. HBase shell

    进入命令行 ./hbase shell 查看HBase shell帮助 help 查看命令帮助 直接输入命令回撤 创建命名空间 create_namespace 'ns1' 查看命名空间 list_n ...

随机推荐

  1. 大众点评CAT开源监控系统剖析

    参考文档: 大众点评的实时监控系统分析(一) CAT_source_analyze 透过CAT,来看分布式实时监控系统的设计与实现 深度剖析开源分布式监控CAT [分布式监控CAT] Client端源 ...

  2. asp如何让panel居中

    把panel放在一个table的td中,并把position设为relative,就可以在设计中直接调整它的位置了

  3. Ready api groovy script 参数化

    def token_type =context.expand ('${#Project#token_type}') def access_token = context.expand('${#Proj ...

  4. Java泛型<>内各种参数的异同

    先说下本篇随笔主要涉及到的东西(参考Java编程思想一书): 1.说明 List<Fruit> 与 List<Apple> 之间为什么是非继承关系. 2.由 1 引出的问题说明 ...

  5. tcp设置超时重传

    TCP超时和重传的基础是怎样根据给定连接RTT设置RTO,若TCP先于RTT开始重传,可能会在网络中引入不必要的重复数据,反之,若延迟至远大于RTT的间隔发送重传数据,整体网络利用率会随之下降.由于R ...

  6. vue.js组件之j间的通讯四,通过单一事件来管理组件通讯

    总结; 首先需要创建是一个空实例: var vm = new Vue(); vm.$emit(事件,数据); vm.$on(事件,function(data){ }bind(this))

  7. python 字符串的特性

    #######str字符串#####str字符判断大小写  url1 = 'http://www.cctv.com'  url2 = 'file:///mnt'  print url1.startsw ...

  8. Storm(1)-centos7下安装单机版Strom

    1.所需软件: jdk8.zookeeper.storm 2.安装zookeeper单机版 下载:http://zookeeper.apache.org/releases.html#download ...

  9. 复制虚拟机出现”适配器 的mac地址在保留地址范围内‘’

    首先我的虚拟机是复制出来的,选择我已经移到,但是结果会出现了以下情况,导致了我无法ping 通,先看下提示: 使用:ipconfig –all 命令查寻,果然再现有打开的虚拟机中,存在两个mac地址相 ...

  10. vue-cli构建的项目打包出现里面的js,css缺少dist路径

    转载 https://www.cnblogs.com/wanf/p/7871787.html