Hbase深入学习(四)  Hbase操作命令列表

来源:互联网 发布:淘宝售假扣24分影响 编辑:程序博客网 时间:2024/06/02 19:01

Hbase深入学习(四)  Hbase操作命令列表

Connect to yourrunning hbase via the shell.

$ ./hbase shell

[WARN ]-XX:OnOutOfMemoryError=kill -9 %p is not a valid VM option. Ignoring

[WARN ]-XX:+UseConcMarkSweepGC is not a valid VM option. Ignoring

HBase Shell; enter'help<RETURN>' for list of supported commands.

Type"exit<RETURN>" to leave the HBase Shell

Version 0.94.11,r1513697, Wed Aug 14 04:54:46 UTC 2013

 

hbase(main):001:0>

Type help and then<return> to see a listing of shell commands and options.

HBase Shell, version0.94.11, r1513697, Wed Aug 14 04:54:46 UTC 2013

Type 'help"COMMAND"', (e.g. 'help "get"' -- the quotes are necessary)for help                                                                                                                                                             ona specific command.

Commands aregrouped. Type 'help "COMMAND_GROUP"', (e.g. 'help"general"') for h                                                                                                                                                            elp on acommand group.

 

COMMAND GROUPS:

  Group name: general

  Commands: status, version, whoami

 

  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, truncat                                                                                                                                                             e

 

  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, list_replicated_tab                                                                                                                                                            les, remove_peer, start_replication, stop_replication

 

  Group name: snapshot

  Commands: clone_snapshot, delete_snapshot,list_snapshots, restore_snapshot, s                                                                                                                                                            napshot

 

  Group name: security

  Commands: grant, revoke, user_permission

 

SHELL USAGE:

Quote all names inHBase Shell such as table and column names. Commas delimit

commandparameters.  Type <RETURN> afterentering a command to run it.

Dictionaries of configurationused in the creation and alteration of tables are

Ruby Hashes. Theylook like this:

 

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

 

and are opened andclosed with curley-braces.  Key/valuesare delimited by the

'=>' charactercombination.  Usually keys are predefinedconstants such as

NAME, VERSIONS,COMPRESSION, etc.  Constants do not needto be quoted.  Type

'Object.constants'to see a (messy) list of all constants in the environment.

 

If you are usingbinary keys or values and need to enter them in the shell, use

double-quote'dhexadecimal 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 isthe (J)Ruby IRB with the above HBase-specific commands added.

For more on theHBase Shell, see http://hbase.apache.org/docs/current/book.html

Create a tablenamed test with a single column family named cf. verify its creation by listingall tables and then insert some values.

hbase(main):002:0>create 'test','cf'

0 row(s) in 1.2240seconds

 

hbase(main):003:0>list 'test'

TABLE

test

1 row(s) in 0.0500 seconds hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0560 seconds
hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0370 seconds
hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0450 seconds

Above we inserted 3values, one at a time. The first insert is at row1, column cf:a with a value ofvalue1. Columns in hbase are comprised of a column family prefix – cf in thisexample – followed by a colon and then a column qualifier suffix (a in thiscase). Verify the data insert by running a scan of the table as follows

Verify the datainsert by running a scan of the table as follows

hbase(main):008:0>scan 'test'

ROW                                      COLUMN+CELL

 row1\x0A\x0A                             column=cf:a,timestamp=1377503568044, value=value1

1 row(s) in 0.0560seconds

Get a single row

hbase(main):015:0>get 'test','row2'

COLUMN                                    CELL

 cf:b                                    timestamp=1377503874806, value=value2

1 row(s) in 0.0190seconds

Disable and dropyour table.

hbase(main):017:0>disable 'test'

0 row(s) in 2.0600seconds

 

hbase(main):018:0>list 'test'

TABLE

test

1 row(s) in 0.0150seconds

 

hbase(main):019:0>drop 'test'

0 row(s) in 1.1950seconds

 

hbase(main):020:0>list 'test'

TABLE

0 row(s) in 0.0170seconds

Exit the shell bytyping exit.

原创粉丝点击