Hbase的shell操作

一 进入hbase的shell
[root@master hbase-1.2.6]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017

二 hbase帮助
1 所有命令的帮助查询方法
hbase(main):001:0> help
HBase Shell, version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017
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, table_help, version, whoami
  Group name: ddl
  Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, locate_region, show_filters
  Group name: namespace
  Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables
  Group name: dml
  Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve
  Group name: tools
  Commands: assign, balance_switch, balancer, balancer_enabled, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, compact_rs, flush, major_compact, merge_region, move, normalize, normalizer_enabled, normalizer_switch, split, trace, unassign, wal_roll, zk_dump
  Group name: replication
  Commands: add_peer, append_peer_tableCFs, disable_peer, disable_table_replication, enable_peer, enable_table_replication, list_peers, list_replicated_tables, remove_peer, remove_peer_tableCFs, set_peer_tableCFs, show_peer_tableCFs
  Group name: snapshots
  Commands: clone_snapshot, delete_all_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshot
  Group name: configuration
  Commands: update_all_config, update_config
  Group name: quotas
  Commands: list_quotas, set_quota
  Group name: security
  Commands: grant, list_security_capabilities, revoke, user_permission
  Group name: procedures
  Commands: abort_procedure, list_procedures
  Group name: visibility labels
  Commands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibility
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/book.html
hbase(main):002:0> help ddl
NameError: undefined local variable or method `ddl' for #<Object:0xa9c5b75>

2 某个命令组的帮助查询方法
hbase(main):003:0> help "ddl"
Command: alter
Alter a table. If the "hbase.online.schema.update.enable" property is set to
false, then the table must be disabled (see help 'disable'). If the
"hbase.online.schema.update.enable" property is set to true, tables can be
altered without disabling them first. Altering enabled tables has caused problems
in the past, so use caution and test it before using in production.
You can use the alter command to add,
modify or delete column families or change table configuration options.
Column families work in a similar way as the 'create' command. The column family
specification can either be a name string, or a dictionary with the NAME attribute.
Dictionaries are described in the output of the 'help' command, with no arguments.
For example, to change or add the 'f1' column family in table 't1' from
current value to keep a maximum of 5 cell VERSIONS, do:
  hbase> alter 't1', NAME => 'f1', VERSIONS => 5
You can operate on several column families:
  hbase> alter 't1', 'f1', {NAME => 'f2', IN_MEMORY => true}, {NAME => 'f3', VERSIONS => 5}
To delete the 'f1' column family in table 'ns1:t1', use one of:
  hbase> alter 'ns1:t1', NAME => 'f1', METHOD => 'delete'
  hbase> alter 'ns1:t1', 'delete' => 'f1'
You can also change table-scope attributes like MAX_FILESIZE, READONLY,
MEMSTORE_FLUSHSIZE, DURABILITY, etc. These can be put at the end;
for example, to change the max size of a region to 128MB, do:
  hbase> alter 't1', MAX_FILESIZE => '134217728'
You can add a table coprocessor by setting a table coprocessor attribute:
  hbase> alter 't1',
    'coprocessor'=>'hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2'
Since you can have multiple coprocessors configured for a table, a
sequence number will be automatically appended to the attribute name
to uniquely identify it.
The coprocessor attribute must match the pattern below in order for
the framework to understand how to load the coprocessor classes:
  [coprocessor jar file location] | class name | [priority] | [arguments]
You can also set configuration settings specific to this table or column family:
  hbase> alter 't1', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}
  hbase> alter 't1', {NAME => 'f2', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
You can also remove a table-scope attribute:
  hbase> alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'
  hbase> alter 't1', METHOD => 'table_att_unset', NAME => 'coprocessor$1'
You can also set REGION_REPLICATION:
  hbase> alter 't1', {REGION_REPLICATION => 2}
There could be more than one alteration in one command:
  hbase> alter 't1', { NAME => 'f1', VERSIONS => 3 },
   { MAX_FILESIZE => '134217728' }, { METHOD => 'delete', NAME => 'f2' },
   OWNER => 'johndoe', METADATA => { 'mykey' => 'myvalue' }
Command: alter_async
Alter column family schema, does not wait for all regions to receive the
schema changes. Pass table name and a dictionary specifying new column
family schema. Dictionaries are described on the main help command output.
Dictionary must include name of column family to alter. For example,
To change or add the 'f1' column family in table 't1' from defaults
to instead keep a maximum of 5 cell VERSIONS, do:
  hbase> alter_async 't1', NAME => 'f1', VERSIONS => 5
To delete the 'f1' column family in table 'ns1:t1', do:
  hbase> alter_async 'ns1:t1', NAME => 'f1', METHOD => 'delete'
or a shorter version:
  hbase> alter_async 'ns1:t1', 'delete' => 'f1'
You can also change table-scope attributes like MAX_FILESIZE
MEMSTORE_FLUSHSIZE, READONLY, and DEFERRED_LOG_FLUSH.
For example, to change the max size of a family to 128MB, do:
  hbase> alter 't1', METHOD => 'table_att', MAX_FILESIZE => '134217728'
There could be more than one alteration in one command:
  hbase> alter 't1', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'}
To check if all the regions have been updated, use alter_status <table_name>
Command: alter_status
Get the status of the alter command. Indicates the number of regions of the
table that have received the updated schema
Pass table name.
hbase> alter_status 't1'
hbase> alter_status 'ns1:t1'
Command: create
Creates a table. Pass a table name, and a set of column family
specifications (at least one), and, optionally, table configuration.
Column specification can be a simple string (name), or a dictionary
(dictionaries are described below in main help output), necessarily
including NAME attribute.
Examples:
Create a table with namespace=ns1 and table qualifier=t1
  hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}
Create a table with namespace=default and table qualifier=t1
  hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
  hbase> # The above in shorthand would be the following:
  hbase> create 't1', 'f1', 'f2', 'f3'
  hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
  hbase> create 't1', {NAME => 'f1', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
  
Table configuration options can be put at the end.
Examples:
  hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40']
  hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40']
  hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe'
  hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' }
  hbase> # Optionally pre-split the table into NUMREGIONS, using
  hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
  hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
  hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', REGION_REPLICATION => 2, CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}}
  hbase> create 't1', {NAME => 'f1', DFS_REPLICATION => 1}
You can also keep around a reference to the created table:
  hbase> t1 = create 't1', 'f1'
Which gives you a reference to the table named 't1', on which you can then
call methods.
Command: describe
Describe the named table. For example:
  hbase> describe 't1'
  hbase> describe 'ns1:t1'
Alternatively, you can use the abbreviated 'desc' for the same thing.
  hbase> desc 't1'
  hbase> desc 'ns1:t1'
Command: disable
Start disable of named table:
  hbase> disable 't1'
  hbase> disable 'ns1:t1'
Command: disable_all
Disable all of tables matching the given regex:
hbase> disable_all 't.*'
hbase> disable_all 'ns:t.*'
hbase> disable_all 'ns:.*'
Command: drop
Drop the named table. Table must first be disabled:
  hbase> drop 't1'
  hbase> drop 'ns1:t1'
Command: drop_all
Drop all of the tables matching the given regex:
hbase> drop_all 't.*'
hbase> drop_all 'ns:t.*'
hbase> drop_all 'ns:.*'
Command: enable
Start enable of named table:
  hbase> enable 't1'
  hbase> enable 'ns1:t1'
Command: enable_all
Enable all of the tables matching the given regex:
hbase> enable_all 't.*'
hbase> enable_all 'ns:t.*'
hbase> enable_all 'ns:.*'
Command: exists
Does the named table exist?
  hbase> exists 't1'
  hbase> exists 'ns1:t1'
Command: get_table
Get the given table name and return it as an actual object to
be manipulated by the user. See table.help for more information
on how to use the table.
Eg.
  hbase> t1 = get_table 't1'
  hbase> t1 = get_table 'ns1:t1'
returns the table named 't1' as a table object. You can then do
  hbase> t1.help
which will then print the help for that table.
Command: is_disabled
Is named table disabled? For example:
  hbase> is_disabled 't1'
  hbase> is_disabled 'ns1:t1'
Command: is_enabled
Is named table enabled? For example:
  hbase> is_enabled 't1'
  hbase> is_enabled 'ns1:t1'
Command: list
List all tables in hbase. Optional regular expression parameter could
be used to filter the output. Examples:
  hbase> list
  hbase> list 'abc.*'
  hbase> list 'ns:abc.*'
  hbase> list 'ns:.*'
Command: locate_region
Locate the region given a table name and a row-key
  hbase> locate_region 'tableName', 'key0'
Command: show_filters
Show all the filters in hbase. Example:
  hbase> show_filters
  ColumnPrefixFilter
  TimestampsFilter
  PageFilter
  .....
  KeyOnlyFilter

3 某个命令帮助查询方法
hbase(main):004:0> help "get"
Get row or cell contents; pass table name, row, and optionally
a dictionary of column(s), timestamp, timerange and versions. Examples:
  hbase> get 'ns1:t1', 'r1'
  hbase> get 't1', 'r1'
  hbase> get 't1', 'r1', {TIMERANGE => [ts1, ts2]}
  hbase> get 't1', 'r1', {COLUMN => 'c1'}
  hbase> get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']}
  hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
  hbase> get 't1', 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}
  hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4}
  hbase> get 't1', 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"}
  hbase> get 't1', 'r1', 'c1'
  hbase> get 't1', 'r1', 'c1', 'c2'
  hbase> get 't1', 'r1', ['c1', 'c2']
  hbase> get 't1', 'r1', {COLUMN => 'c1', ATTRIBUTES => {'mykey'=>'myvalue'}}
  hbase> get 't1', 'r1', {COLUMN => 'c1', AUTHORIZATIONS => ['PRIVATE','SECRET']}
  hbase> get 't1', 'r1', {CONSISTENCY => 'TIMELINE'}
  hbase> get 't1', 'r1', {CONSISTENCY => 'TIMELINE', REGION_REPLICA_ID => 1}
Besides the default 'toStringBinary' format, 'get' also supports custom formatting by
column.  A user can define a FORMATTER by adding it to the column name in the get
specification.  The FORMATTER can be stipulated:
1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString)
2. or as a custom class followed by method name: e.g. 'c(MyFormatterClass).format'.
Example formatting cf:qualifier1 and cf:qualifier2 both as Integers:
  hbase> get 't1', 'r1' {COLUMN => ['cf:qualifier1:toInt',
    'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] }
Note that you can specify a FORMATTER by column only (cf:qualifier).  You cannot specify
a FORMATTER for all columns of a column family.
    
The same commands also can be run on a reference to a table (obtained via get_table or
create_table). Suppose you had a reference t to table 't1', the corresponding commands
would be:
  hbase> t.get 'r1'
  hbase> t.get 'r1', {TIMERANGE => [ts1, ts2]}
  hbase> t.get 'r1', {COLUMN => 'c1'}
  hbase> t.get 'r1', {COLUMN => ['c1', 'c2', 'c3']}
  hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
  hbase> t.get 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}
  hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4}
  hbase> t.get 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"}
  hbase> t.get 'r1', 'c1'
  hbase> t.get 'r1', 'c1', 'c2'
  hbase> t.get 'r1', ['c1', 'c2']
  hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE'}
  hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE', REGION_REPLICA_ID => 1}

三 实战
1 status
hbase(main):008:0* status
1 active master, 1 backup masters, 3 servers, 0 dead, 0.6667 average load

2 create
hbase(main):010:0> create 't1','cf1'
0 row(s) in 2.6320 seconds
=> Hbase::Table - t1
hbase(main):011:0> list
TABLE                                                                                             
t1                                                                                                
1 row(s) in 0.0420 seconds
=> ["t1"]
hbase(main):012:0> create 't2','cf1','cf2','cgf3'
0 row(s) in 2.2820 seconds
=> Hbase::Table - t2
hbase(main):013:0> list
TABLE                                                                                             
t1                                                                                                
t2                                                                                                
2 row(s) in 0.0100 seconds
=> ["t1", "t2"]
hbase(main):014:0> describe
describe             describe_namespace
hbase(main):014:0> describe 't2'
Table t2 is ENABLED                                                                               
t2                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                       
{NAME => 'cf1', 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 => 'cf2', 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 => 'cgf3', 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.3460 seconds
hbase(main):015:0> create 't3',{NAME=>'cf1',VERSIONS=>3},{NAME=>'cf2',VERSIONS=>2}
0 row(s) in 1.4600 seconds
=> Hbase::Table - t3

3 list
hbase(main):016:0> list
TABLE                                                                                             
t1                                                                                                
t2                                                                                                
t3                                                                                                
3 row(s) in 0.0140 seconds

4 describe
hbase(main):018:0> describe 't3'
Table t3 is ENABLED                                                                               
t3                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                       
{NAME => 'cf1', BLOOMFILTER => 'ROW', VERSIONS => '3', 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 => 'cf2', BLOOMFILTER => 'ROW', VERSIONS => '2', 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'}                        
2 row(s) in 0.0340 seconds

5 alter
hbase(main):021:0* alter 't1','cf1','cf2'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 3.9820 seconds
hbase(main):022:0> desc 't1'
Table t1 is ENABLED                                                                               
t1                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                       
{NAME => 'cf1', 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 => 'cf2', 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'}                        
2 row(s) in 0.0260 seconds
hbase(main):005:0> desc 't1'
Table t1 is ENABLED                                                                               
t1                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                       
{NAME => 'cf1', 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 => 'cf2', 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 => 'cf22', 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.3590 seconds
hbase(main):006:0> alter 't1',{METHOD='delete',NAME='cf22'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.2530 seconds
hbase(main):008:0> desc 't1'
Table t1 is ENABLED                                                                               
t1                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                       
{NAME => 'cf1', 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 => 'cf2', 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'}                        
2 row(s) in 0.0430 seconds

6 exists
hbase(main):011:0> exists 'tt'
Table tt does not exist                                                                           
0 row(s) in 0.0090 seconds
hbase(main):012:0> exists 't1'
Table t1 does exist                                                                               
0 row(s) in 0.0190 seconds

7 disable
hbase(main):014:0> disable 't1'
0 row(s) in 2.3530 seconds
hbase(main):015:0> is_disabled 't1'
true                                                                                              
0 row(s) in 0.0160 seconds

8 drop
hbase(main):016:0> drop 't1'
0 row(s) in 1.3290 seconds
hbase(main):017:0> list 't1'
TABLE                                                                                             
0 row(s) in 0.0090 seconds
=> []

9 put
hbase(main):002:0> create 'testtable','cf1','cf2'
0 row(s) in 1.3590 seconds
=> Hbase::Table - testtable
hbase(main):003:0> desc 'testtable'
Table testtable is ENABLED                                                                                 
testtable                                                                                                  
COLUMN FAMILIES DESCRIPTION                                                                                
{NAME => 'cf1', 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 => 'cf2', 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'}                                                   
2 row(s) in 0.1570 seconds
hbase(main):004:0> put 'testtable','r1','cf1:name','cakin'
0 row(s) in 0.1840 seconds

10 scan
hbase(main):005:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637540052, value=cakin                          
1 row(s) in 0.0800 seconds
hbase(main):006:0> put 'testtable','r1','cf1:name','cakin1'
0 row(s) in 0.0170 seconds
hbase(main):007:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
1 row(s) in 0.0510 seconds
hbase(main):008:0> put 'testtable','r1','cf2:name2','cakin11'
0 row(s) in 0.0340 seconds
hbase(main):009:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
r1                         column=cf2:name2, timestamp=1514637730492, value=cakin11                       
1 row(s) in 0.0250 seconds
hbase(main):010:0> put 'testtable','r1','cf2:age','33'
0 row(s) in 0.0090 seconds
hbase(main):011:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
r1                         column=cf2:age, timestamp=1514637785662, value=33                              
r1                         column=cf2:name2, timestamp=1514637730492, value=cakin11                       
1 row(s) in 0.0260 seconds
hbase(main):017:0> scan 'testtable',{COLUMNS=>'cf1:name'}
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
r2                         column=cf1:name, timestamp=1514638368676, value=xuz                            
2 row(s) in 0.0390 seconds

11 get
hbase(main):012:0> get 'testtable','r1'
COLUMN                      CELL                                                                           
cf1:name                   timestamp=1514637643881, value=cakin1                                          
cf2:age                    timestamp=1514637785662, value=33                                              
cf2:name2                  timestamp=1514637730492, value=cakin11                                         
3 row(s) in 0.0330 seconds
hbase(main):013:0> get 'testtable','r1','cf1:name'
COLUMN                      CELL                                                                           
cf1:name                   timestamp=1514637643881, value=cakin1                                          
1 row(s) in 0.0130 seconds
hbase(main):014:0> get 'testtable','r1',{COLUMNS=>'cf1:name',VERSIONS=>3}
COLUMN                      CELL                                                                           
cf1:name                   timestamp=1514637643881, value=cakin1                                          
1 row(s) in 0.0200 seconds

12 delete
hbase(main):019:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
r1                         column=cf2:age, timestamp=1514637785662, value=33                              
r1                         column=cf2:name2, timestamp=1514637730492, value=cakin11                       
r2                         column=cf1:name, timestamp=1514638368676, value=xuz                            
2 row(s) in 0.0270 seconds
hbase(main):022:0> delete 'testtable','r1','cf2:name2'
0 row(s) in 0.0100 seconds
hbase(main):023:0> scan 'testtable'
ROW                         COLUMN+CELL                                                                    
r1                         column=cf1:name, timestamp=1514637643881, value=cakin1                         
r1                         column=cf2:age, timestamp=1514637785662, value=33                              
r2                         column=cf1:name, timestamp=1514638368676, value=xuz                            
2 row(s) in 0.0220 seconds

13 truncate
hbase(main):024:0> truncate 'testtable'
Truncating 'testtable' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.7050 seconds
hbase(main):025:0> is_disabled 'testtable'
false                                                                                                      
0 row(s) in 0.0160 seconds

四 参考
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值