HBase Shell基本使用总结
创建一个表
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基本使用总结的更多相关文章
- HBase Shell操作
Hbase 是一个分布式的.面向列的开源数据库,其实现是建立在google 的bigTable 理论之上,并基于hadoop HDFS文件系统. Hbase不同于一般的关系型数据库(RDBMS ...
- HBase Shell 常用命令及例子
下面我们看看HBase Shell的一些基本操作命令,我列出了几个常用的HBase Shell命令,如下: 名称 命令表达式 创建表 create '表名称', '列名称1','列名称2','列名称N ...
- hbase shell command
进入hbase shell console $HBASE_HOME/bin/hbase shell 如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成 ...
- hbase shell基础和常用命令详解(转)
HBase shell的基本用法 hbase提供了一个shell的终端给用户交互.使用命令hbase shell进入命令界面.通过执行 help可以看到命令的帮助信息. 以网上的一个学生成绩表的例子来 ...
- hbase shell 基本命令总结
访问hbase,以及操作hbase,命令不用使用分号hbase shell 进入hbase list 查看表hbase shell -d hbase(main):024:0> scan '.ME ...
- hbase shell 常用命令
进入hbase shell console$HBASE_HOME/bin/hbase shell如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成功之 ...
- Hbase Shell常用命令
hbase shell常用的操作命令有create,describe,disable,drop,list,scan,put,get,delete,deleteall,count,status等,通过h ...
- hbase shell中log4j重复问题
[root@centos ~]# hbase shellSLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding ...
- (转)Hbase shell 常用命令(1)
Hbase shell 常用命令(1) link:http://blog.csdn.net/scutshuxue/article/details/6988348 下面我们看看HBase Shell的一 ...
- HBase shell
进入命令行 ./hbase shell 查看HBase shell帮助 help 查看命令帮助 直接输入命令回撤 创建命名空间 create_namespace 'ns1' 查看命名空间 list_n ...
随机推荐
- soj 131 找题
soj 131 找题 给出两个长度为n,都含k个1的字符串A,B.现在令\(a_1,a_2,\dots,a_k\)是A中1的下标,\(b_1,b_2,\dots,b_k\)是B中1的下表,然后将a,b ...
- UVa_Live 3664(精度坑)
题意很好理解的贪心题,然而却卡疯了的精度坑. 再次理解一下double小数运算时可能导致的精度问题,本题为避免该问题可以将小数乘以100化为整数进行比较,输出的时候再除以100就ok: 思路也很好想, ...
- hadoop HDFS文件系统的特征
hadoop HDFS文件系统的特征 存储极大数目的信息(terabytes or petabytes),将数据保存到大量的节点当中.支持很大单个文件. 提供数据的高可靠性,单个或者多个节点不工作,对 ...
- linux硬盘IO优化相关资料整理
内核相关参数 相关内核参数,有条件的话可以修改参数测试验证一下. 1./proc/sys/vm/dirty_ratio 这个参数则指定了当文件系统缓存脏页数量达到系统内存百分之多少时(如10%),系统 ...
- Common operators to overload-c++运算符重载的标准语法(全)
Common operators to overload Most of the work in overloading operators is boiler-plate code. That is ...
- 黑马MySQL数据库学习day04 MySQL变量 存储过程 用户和授权管理
/* MySQL中的变量局部变量,用户变量,会话变量和全局变量. 用户变量不用定义,直接使用. 1.用户变量赋值 set @xxx = 值; 2.查询 select @xxx; 语法帮助: 过程保存在 ...
- 类关系/self/特殊成员
1.依赖关系 在方法中引入另一个类的对象 2.关联关系.聚合关系.组合关系 #废话少说 直接上代码===>选课系统 # coding:utf-8 class Student(object): d ...
- ubuntu下vnc部署安装
ubuntu下vnc部署安装,参考如下博客:https://www.cnblogs.com/xuliangxing/p/7642650.html https://jingyan.baidu.com/a ...
- redis数据库介绍(NoSql数据库)
- Java中的两个类:Desktop和SystemTray
在JDK6中 ,AWT新增加了两个类:Desktop和SystemTray,前者可以用来打开系统默认浏览器浏览指定的URL,打开系统默认邮件客户端给指定的邮箱发邮件,用默认应用程序打开或编辑文件(比如 ...