HBase Shell命令学习

在hbase shell状态下,使用命令help,会显示hbase 所有的命令

hbase(main):015:0> help
NameError: undefined local variable or method `he' for #<Object:0x1900f17>

hbase(main):016:0> help
HBase Shell, version 0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.

COMMAND GROUPS:
Group name: general
Commands: status, version

Group name: ddl
Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, is_disabled, is_enabled, list, show_filters

Group name: dml
Commands: count, delete, deleteall, get, get_counter, incr, put, scan, truncate

Group name: tools
Commands: assign, balance_switch, balancer, close_region, compact, flush, hlog_roll, major_compact, move, split, unassign, zk_dump

Group name: replication
Commands: add_peer, disable_peer, enable_peer, list_peers, remove_peer, start_replication, stop_replication

Group name: security
Commands: grant, revoke, user_permission

SHELL USAGE:
Quote all names in HBase Shell such as table and column names. Commas delimit
command parameters. Type <RETURN> after entering a command to run it.
Dictionaries of configuration used in the creation and alteration of tables are
Ruby Hashes. They look like this:

{'key1' => 'value1', 'key2' => 'value2', ...}

and are opened and closed with curley-braces. Key/values are delimited by the
'=>' character combination. Usually keys are predefined constants such as
NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type
'Object.constants' to see a (messy) list of all constants in the environment.

If you are using binary keys or values and need to enter them in the shell, use
double-quote'd hexadecimal representation. For example:

hbase> get 't1', "key\x03\x3f\xcd"
hbase> get 't1', "key\003\023\011"
hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"

The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
For more on the HBase Shell, see http://hbase.apache.org/docs/current/book.html

挨个看看
general:
status 查看hbase状态

hbase(main):017:0> status
1 servers, 0 dead, 4.0000 average load

version 查看版本

0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012

看一下hbase常用的操作命令有:
create,describe,disable,drop,list,scan,put,get,delete,deleteall,count,status

创建表
create 'user','username','mobile'
查看所有的表:
hbase(main):001:0> list
TABLE
test
test1
user
查看表结构

hbase(main):003:0> describe 'user'
DESCRIPTION ENABLED
{NAME => 'user', FAMILIES => [{NAME => 'mobile', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => ' true
0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', BLOCKSIZ
E => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'name', BLOOMFILTER => 'NO
NE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TT
L => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}
删除一个列族,alter,disable,enable
hbase(main):003:0>alter 'user',{NAME=>'mobile',METHOD=>'delete'}
drop一个表
Drop the named table. Table must first be disabled. If table has. more than one region, run a major compaction on .META.:
drop之前必须先disabled表
hbase(main):036:0> disable 'test'
0 row(s) in 2.2000 seconds

hbase(main):037:0> drop 'test'
0 row(s) in 1.8130 seconds

hbase(main):038:0> list
TABLE
persion
test1
user
查看表是否存在
hbase(main):039:0> exists 'test'
Table test does not exist

睡觉。
==续
version就是修改数据的版本,比如你可以查你修改之前的值
查看此列的多个版本
hbase(main):005:0> get 'blog','1',{COLUMN=>'author:name',VERSIONS=>2}
COLUMN CELL
author:name timestamp=1336903227226, value=zhangkai
author:name timestamp=1336903136510, value=zhnagkai
2 row(s) in 0.0350 seconds
如果只想看旧版本的值,需要借助TIMESTAMP
hbase(main):006:0> get 'blog','1',{COLUMN=>'author:name',TIMESTAMP=>1336903136510}
COLUMN CELL
author:name timestamp=1336903136510, value=zhnagkai
1 row(s) in 0.0270 seconds
删除一列
delete 'blog','1','author:name'
删除RowKey的所有column
deleteall 'blog','1'



参考:http://wiki.apache.org/hadoop/Hbase/Shell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值