hbase Shell之简单命令说明

[hadoop@master hbase]$[color=red] bin/hbase shell[/color]
进入shell

hbase(main):001:0> [color=red]help[/color]
******(Shell命令说明)

hbase(main):002:0> [color=red]status[/color]
1 servers, 0 dead, 4.0000 average load (服务器,dead,负荷)

hbase(main):003:0> [color=red]version[/color]
0.94.2, r1395367, Sun Oct 7 19:11:01 UTC 2012 (版本)

hbase(main):001:0> [color=red]create 'member','member_id','address','info'[/color]
0 row(s) in 5.3700 seconds (创建表,成功)

hbase(main):002:0> [color=red]list[/color]
TABLE
htest
member
user
3 row(s) in 0.3400 seconds (查看TABLE信息)

hbase(main):003:0> [color=red]describe 'member'[/color]
DESCRIPTION ENABLED
{NAME => 'member', FAMILIES => [{NAME => 'address', DATA_BLO true
CK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SC
OPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERS
IONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'fal
se', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_D
ISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'info', DATA_
BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION
_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_V
ERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => '
false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_O
N_DISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'member_id
', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REP
LICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE
', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CE
LLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false',
ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0340 seconds (查看表)

hbase(main):002:0>[color=red] alter 'member',{NAME=>'member_id',METHOD=>'delete'}[/color]
[color=blue]ERROR: org.apache.hadoop.hbase.TableNotDisabledException: org.apache.hadoop.hbase.TableNotDisabledException: member
(不可直接修改,必须先把表离线,然后修改)[/color]
hbase(main):003:0>[color=red] disable 'member'[/color]
0 row(s) in 2.2260 seconds (disable表,先设为不可用)
hbase(main):004:0> alter 'member',{NAME=>'member_id',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.5010 seconds (修改成功)

hbase(main):005:0> [color=red]enable 'member'[/color]
0 row(s) in 2.2380 seconds (然后启动表)

hbase(main):009:0> [color=red]disable 'member'[/color]
0 row(s) in 2.1470 seconds (删除表也需要先把表设为不可用)

hbase(main):010:0> [color=red]drop 'member'[/color]
0 row(s) in 1.3690 seconds (删除成功)

hbase(main):011:0> [color=red]exists 'member'[/color]
Table member does not exist
0 row(s) in 0.1170 seconds (查看是否存在表)

hbase(main):015:0> [color=red]is_enabled 'member'[/color]
true
0 row(s) in 0.0030 seconds (查看表是否可用)

hbase(main):016:0> [color=red]is_disabled 'member'[/color]
false
0 row(s) in 0.0040 seconds (查看表是否不可用)

(插入记录)
hbase(main):017:0> [color=red]put 'member','scutshuxue','info:age','24'[/color]
hbase(main):018:0> put 'member','scutshuxue','info:birthday','1987-06-17'
hbase(main):020:0> put 'member','scutshuxue','info:company','alibaba'
hbase(main):025:0> put 'member','scutshuxue','address:province','zhejiang'

hbase(main):026:0> put 'member','scutshuxue','address:city','hangzhou'

hbase(main):027:0> put 'member','xiaofeng','info:birthday','1987-4-17'

hbase(main):028:0> put 'member','xiaofeng','info:company','alibaba'

hbase(main):029:0> put 'member','xiaofeng','address:contry','china'

hbase(main):030:0> put 'member','xiaofeng','address:province','guangdong'

hbase(main):031:0> put 'member','xiaofeng','address:city','jieyang'

hbase(main):032:0> put 'member','xiaofeng','address:town','xianqiao'

(查询记录:行键查询)
hbase(main):001:0> [color=red]get 'member','scutshuxue'[/color]
COLUMN CELL
address:city timestamp=1365791240949, value=hangzhou
address:province timestamp=1365791217245, value=zhejiang
info:age timestamp=1365790872766, value=24
info:birthday timestamp=1365790910608, value=1987-06-17
info:company timestamp=1365790948776, value=alibaba
5 row(s) in 2.8340 seconds

(查询记录:行键、一个列簇的所有信息)
hbase(main):002:0> [color=red]get 'member','scutshuxue','info'[/color]
COLUMN CELL
info:age timestamp=1365790872766, value=24
info:birthday timestamp=1365790910608, value=1987-06-17
info:company timestamp=1365790948776, value=alibaba
3 row(s) in 0.0220 seconds

(查询记录:行键、列簇的某列信息)
hbase(main):003:0> [color=red]get 'member','scutshuxue','info:age'[/color]
COLUMN CELL
info:age timestamp=1365790872766, value=24
1 row(s) in 0.0130 seconds

(更新一条记录)
hbase(main):004:0> [color=red]put 'member','scutshuxue','info:age','99'[/color]
0 row(s) in 0.0940 seconds

hbase(main):005:0> [color=red]get'member','scutshuxue','info:age'[/color]
COLUMN CELL
info:age timestamp=1365792994491, value=99
1 row(s) in 0.0170 seconds

(通过时间戳查询记录)
hbase(main):008:0> [color=red]get'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1365792994491}[/color]
COLUMN CELL
info:age timestamp=1365792994491, value=99
1 row(s) in 0.0110 seconds

(全表扫描)
hbase(main):009:0> [color=red]scan 'member'[/color]
ROW COLUMN+CELL
scutshuxue column=address:city, timestamp=1365791240949, value=hangzhou
scutshuxue column=address:province, timestamp=1365791217245, value=zhejiang
scutshuxue column=info:age, timestamp=1365792994491, value=99
scutshuxue column=info:birthday, timestamp=1365790910608, value=1987-06-17
scutshuxue column=info:company, timestamp=1365790948776, value=alibaba
xiaofeng column=address:city, timestamp=1365791360361, value=jieyang
xiaofeng column=address:contry, timestamp=1365791327027, value=china
xiaofeng column=address:province, timestamp=1365791339666, value=guangdong
xiaofeng column=address:town, timestamp=1365791380287, value=xianqiao
xiaofeng column=info:birthday, timestamp=1365791274037, value=1987-4-17
xiaofeng column=info:company, timestamp=1365791292933, value=alibaba
2 row(s) in 0.1540 seconds

(删除制定行键的字段)
hbase(main):010:0> [color=red]delete 'member','temp','info:age'[/color]
0 row(s) in 0.0500 seconds

hbase(main):011:0> [color=red]get'member','temp'[/color]
COLUMN CELL
0 row(s) in 0.0050 seconds

(删除整行)
hbase(main):013:0> [color=red]deleteall'member','xiaofeng'[/color]
0 row(s) in 0.0070 seconds

(查询行)
hbase(main):014:0> [color=red]count'member'[/color]
1 row(s) in 0.0670 seconds

(清空表)
hbase(main):015:0> [color=red]truncate'member'[/color]
Truncating 'member' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 3.8280 seconds

Hbase API
《Hbase权威指南》第3-5章
http://hbase.apache.org/apidocs/index.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值