Hbase:0.2Help

出典: LunaBiblos

Software > DataBase > KeyValueストア > HBaseの利用 > Hbase:0.2Help

目次

HBASE SHELL COMMANDS

alter

Alter column family schema;
pass table name and a dictionary specifying new column family schema.Dictionaries are described below in the GENERAL NOTES section. Dictionary must include name of column family to alter. For example,

To change or add the 'ColumnFamily1' column family in table 'Table1' from defaults to instead keep a maximum of 5 cell VERSIONS, do:

hbase> alter 'Table1', {NAME => 'ColumnFamily1', VERSIONS => 5}

To delete the 'ColumnFamily1' column family in table 'Table1', do:

hbase> alter 'Table1', {NAME => 'ColumnFamily1', METHOD => 'delete'}

You can also change table-scope attributes like MAX_FILESIZE MEMSTORE_FLUSHSIZE and READONLY.

For example, to change the max size of a family to 128MB, do:

hbase> alter 'Table1', {METHOD => 'table_att', MAX_FILESIZE => '134217728'}

count

Count the number of rows in a table. This operation may take a LONG time (Run '$HADOOP_HOME/bin/hadoop jar hbase.jar rowcount' to run a counting mapreduce job). Current count is shown every 1000 rows by default. Count interval may be optionally specified. Examples:

hbase> count 'Table1'
hbase> count 'Table1', 100000

create

Create table; pass table name, a dictionary of specifications per column family, and optionally a dictionary of table configuration. Dictionaries are described below in the GENERAL NOTES section. Examples:

hbase> create 'Table1', {NAME => 'ColumnFamily1', VERSIONS => 5}
hbase> create 'Table1', {NAME => 'ColumnFamily1'}, {NAME => 'ColumnFamily2'}, {NAME => 'ColumnFamily3'}
hbase> # The above in shorthand would be the following:
hbase> create 'Table1', 'ColumnFamily1', 'ColumnFamily2', 'ColumnFamily3'
hbase> create 'Table1', {NAME => 'ColumnFamily1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}

describe

Describe the named table: e.g.

hbase> describe 'Table1'

delete

Put a delete cell value at specified table/row/column and optionally timestamp coordinates. Deletes must match the deleted cell's coordinates exactly. When scanning, a delete cell suppresses older versions. Takes arguments like the 'put' command described below

deleteall

Delete all cells in a given row; pass a table name, row, and optionally a column and timestamp

disable

Disable the named table: e.g.

hbase> disable 'Table1'

drop

Drop the named table. Table must first be disabled. If table has more than one region, run a major compaction on .META.:

hbase> major_compact ".META."

enable

Enable the named table

exists

Does the named table exist? e.g.

hbase> exists 'Table1'

exit

Type "hbase> exit" to leave the HBase Shell

get

Get row or cell contents; pass table name, row, and optionally a dictionary of column(s), timestamp and versions. Examples:

hbase> get 'Table1', 'Row1'
hbase> get 'Table1', 'Row1', {COLUMN => 'Column1'}
hbase> get 'Table1', 'Row1', {COLUMN => ['Column1', 'Column2', 'Column3']}
hbase> get 'Table1', 'Row1', {COLUMN => 'Column1', TIMESTAMP => Timestamp1}
hbase> get 'Table1', 'Row1', {COLUMN => 'Column1', TIMESTAMP => Timestamp1, VERSIONS => 4}

list

List all tables in hbase

put

Put a cell 'value' at specified table/row/column and optionally timestamp coordinates. To put a cell value into table 'Table1' at row 'Row1' under column 'Column1' marked with the time 'Timestamp1', do:

hbase> put 'Table1', 'Row1', 'Column1', 'value', Timestamp1

tools

Listing of hbase surgery tools

scan

Scan a table; pass table name and optionally a dictionary of scanner specifications. Scanner specifications may include one or more of the following: LIMIT, STARTROW, STOPROW, TIMESTAMP, or COLUMNS. If no columns are specified, all columns will be scanned. To scan all members of a column family, leave the qualifier empty as in 'col_family:'. Examples:

hbase> scan '.META.'
hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
hbase> scan 'Table1', {COLUMNS => ['Column1', 'Column2'], LIMIT => 10, STARTROW => 'xyz'}

status

Show cluster status. Can be 'summary', 'simple', or 'detailed'. The default is 'summary'. Examples:

hbase> status
hbase> status 'simple'
hbase> status 'summary'
hbase> status 'detailed'

shutdown

Shut down the cluster.

truncate

Disables, drops and recreates the specified table.

version

Output this HBase version

GENERAL NOTES:

Quote all names in the hbase shell such as table and column names. Don't forget 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', ...}

They 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.

In case you are using binary keys or values and need to enter them into the shell then use double-quotes to make use of hexadecimal or octal notations, for example:

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

Using the double-quote notation you can directly use the values output by the shell for example during a "scan" call.

This HBase shell is the JRuby IRB with the above HBase-specific commands added. For more on the HBase Shell, see http://wiki.apache.org/hadoop/Hbase/Shell