进入shell
[root@n3 ~]# /usr/bin/hbase shell
16/07/06 21:09:18 INFO Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
hbase(main):001:0>
-- 帮助
hbase(main):001:0> help
HBase Shell, version 0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
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, 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, incr, put, scan, truncate, truncate_preserve
Group name: tools
Commands: assign, balance_switch, balancer, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, flush, hlog_roll, major_compact, merge_region, move, split, trace, unassign, zk_dump
Group name: replication
Commands: add_peer, disable_peer, enable_peer, list_peers, list_replicated_tables, remove_peer, set_peer_tableCFs, show_peer_tableCFs
Group name: snapshots
Commands: clone_snapshot, delete_snapshot, list_snapshots, rename_snapshot, restore_snapshot, snapshot
Group name: quotas
Commands: list_quotas, set_quota
Group name: security
Commands: grant, revoke, user_permission
Group name: visibility labels
Commands: add_labels, clear_auths, get_auths, 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/docs/current/book.html
--一些常用操作
-- 查看表
hbase(main):030:0> list
TABLE
member
t1
2 row(s) in 0.0340 seconds
=> ["member", "t1"]
-- 当前用户
hbase(main):031:0> whoami
root (auth:SIMPLE)
groups: root
--查看服务器状态
hbase(main):032:0> status
2 servers, 0 dead, 2.0000 average load
-- 版本
hbase(main):002:0> version
0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
-- 创建表
hbase(main):029:0> create 't1','f1','f2'
0 row(s) in 0.8330 seconds
=> Hbase::Table - t1
--表描述
hbase(main):003:0> desc 't1'
DESCRIPTION ENABLED
't1', {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', true
REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VE
RSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE
=> '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'f2',
DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE =>
'0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL =>
'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMOR
Y => 'false', BLOCKCACHE => 'true'}
1 row(s) in 9.2200 seconds
--判断表是否enable
hbase(main):033:0> is_enabled 't1'
true
0 row(s) in 0.0560 seconds
--删除一个表
hbase(main):025:0> truncate 't1'
Truncating 't1' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 25.7020 seconds
-- 插入记录
hbase(main):004:0> put 't1','china','f1:col1','12'
0 row(s) in 0.1270 seconds
hbase(main):002:0> put 't1','china','f2:col1','123'
0 row(s) in 0.1150 seconds
hbase(main):006:0> put 't1','china','f2:col2','456'
0 row(s) in 0.0240 seconds
-- 查看数据
hbase(main):007:0> get 't1','china'
COLUMN CELL
f1:col1 timestamp=1467807350653, value=12
f2:col1 timestamp=1467808335001, value=123
f2:col2 timestamp=1467808529479, value=456
3 row(s) in 0.0270 seconds
hbase(main):008:0> get 't1','china','f1'
COLUMN CELL
f1:col1 timestamp=1467807350653, value=12
1 row(s) in 0.0310 seconds
-- 全表扫描
hbase(main):034:0> scan 't1'
ROW COLUMN+CELL
0 row(s) in 0.0890 seconds
-- 删除数据
hbase(main):039:0> scan 't1'
ROW COLUMN+CELL
china column=f1:col2, timestamp=1467811618914, value=789
china column=f2:col2, timestamp=1467811613943, value=789
1 row(s) in 0.0520 seconds
hbase(main):040:0> delete 't1','china','f1:col2'
0 row(s) in 0.0390 seconds
hbase(main):041:0> scan 't1'
ROW COLUMN+CELL
china column=f2:col2, timestamp=1467811613943, value=789
1 row(s) in 0.0380 seconds
-- 删除正行
hbase(main):043:0> scan 't1'
ROW COLUMN+CELL
china column=f2:col2, timestamp=1467811711290, value=789
1 row(s) in 0.0310 seconds
hbase(main):044:0> put 't1','china','f1:col2','789'
0 row(s) in 0.0310 seconds
hbase(main):045:0> scan 't1'
ROW COLUMN+CELL
china column=f1:col2, timestamp=1467811725232, value=789
china column=f2:col2, timestamp=1467811711290, value=789
1 row(s) in 0.0390 seconds
hbase(main):046:0> deleteall 't1','china'
0 row(s) in 0.0310 seconds
hbase(main):047:0> scan 't1'
ROW COLUMN+CELL
0 row(s) in 0.0370 seconds
[root@n3 ~]# /usr/bin/hbase shell
16/07/06 21:09:18 INFO Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
hbase(main):001:0>
-- 帮助
hbase(main):001:0> help
HBase Shell, version 0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
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, 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, incr, put, scan, truncate, truncate_preserve
Group name: tools
Commands: assign, balance_switch, balancer, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, flush, hlog_roll, major_compact, merge_region, move, split, trace, unassign, zk_dump
Group name: replication
Commands: add_peer, disable_peer, enable_peer, list_peers, list_replicated_tables, remove_peer, set_peer_tableCFs, show_peer_tableCFs
Group name: snapshots
Commands: clone_snapshot, delete_snapshot, list_snapshots, rename_snapshot, restore_snapshot, snapshot
Group name: quotas
Commands: list_quotas, set_quota
Group name: security
Commands: grant, revoke, user_permission
Group name: visibility labels
Commands: add_labels, clear_auths, get_auths, 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/docs/current/book.html
--一些常用操作
-- 查看表
hbase(main):030:0> list
TABLE
member
t1
2 row(s) in 0.0340 seconds
=> ["member", "t1"]
-- 当前用户
hbase(main):031:0> whoami
root (auth:SIMPLE)
groups: root
--查看服务器状态
hbase(main):032:0> status
2 servers, 0 dead, 2.0000 average load
-- 版本
hbase(main):002:0> version
0.98.6-cdh5.3.9, rUnknown, Tue Dec 22 14:05:15 PST 2015
-- 创建表
hbase(main):029:0> create 't1','f1','f2'
0 row(s) in 0.8330 seconds
=> Hbase::Table - t1
--表描述
hbase(main):003:0> desc 't1'
DESCRIPTION ENABLED
't1', {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', true
REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VE
RSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE
=> '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'f2',
DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE =>
'0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL =>
'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMOR
Y => 'false', BLOCKCACHE => 'true'}
1 row(s) in 9.2200 seconds
--判断表是否enable
hbase(main):033:0> is_enabled 't1'
true
0 row(s) in 0.0560 seconds
--删除一个表
hbase(main):025:0> truncate 't1'
Truncating 't1' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 25.7020 seconds
-- 插入记录
hbase(main):004:0> put 't1','china','f1:col1','12'
0 row(s) in 0.1270 seconds
hbase(main):002:0> put 't1','china','f2:col1','123'
0 row(s) in 0.1150 seconds
hbase(main):006:0> put 't1','china','f2:col2','456'
0 row(s) in 0.0240 seconds
-- 查看数据
hbase(main):007:0> get 't1','china'
COLUMN CELL
f1:col1 timestamp=1467807350653, value=12
f2:col1 timestamp=1467808335001, value=123
f2:col2 timestamp=1467808529479, value=456
3 row(s) in 0.0270 seconds
hbase(main):008:0> get 't1','china','f1'
COLUMN CELL
f1:col1 timestamp=1467807350653, value=12
1 row(s) in 0.0310 seconds
-- 全表扫描
hbase(main):034:0> scan 't1'
ROW COLUMN+CELL
0 row(s) in 0.0890 seconds
-- 删除数据
hbase(main):039:0> scan 't1'
ROW COLUMN+CELL
china column=f1:col2, timestamp=1467811618914, value=789
china column=f2:col2, timestamp=1467811613943, value=789
1 row(s) in 0.0520 seconds
hbase(main):040:0> delete 't1','china','f1:col2'
0 row(s) in 0.0390 seconds
hbase(main):041:0> scan 't1'
ROW COLUMN+CELL
china column=f2:col2, timestamp=1467811613943, value=789
1 row(s) in 0.0380 seconds
-- 删除正行
hbase(main):043:0> scan 't1'
ROW COLUMN+CELL
china column=f2:col2, timestamp=1467811711290, value=789
1 row(s) in 0.0310 seconds
hbase(main):044:0> put 't1','china','f1:col2','789'
0 row(s) in 0.0310 seconds
hbase(main):045:0> scan 't1'
ROW COLUMN+CELL
china column=f1:col2, timestamp=1467811725232, value=789
china column=f2:col2, timestamp=1467811711290, value=789
1 row(s) in 0.0390 seconds
hbase(main):046:0> deleteall 't1','china'
0 row(s) in 0.0310 seconds
hbase(main):047:0> scan 't1'
ROW COLUMN+CELL
0 row(s) in 0.0370 seconds