Hbase基本shell操作

创建表

hbase(main):013:0> create 'member' , 'member_id','address','famliy'
0 row(s) in 1.2370 seconds

=> Hbase::Table - member

描述表结构

hbase(main):001:0> desc 'member'
Table member is ENABLED
member
COLUMN FAMILIES DESCRIPTION
{NAME => 'address', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NO
NE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'famliy', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NON
E', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'member_id', 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.5360 seconds

删除列族

hbase(main):002:0> alter 'member' , 'delete'=>'famliy'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9640 seconds

Table member is ENABLED
member
COLUMN FAMILIES DESCRIPTION
{NAME => 'address', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NO
NE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'member_id', 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.0220 seconds

删除表

hbase(main):005:0> disable 'member'
0 row(s) in 2.3030 seconds

hbase(main):006:0> drop 'member'
0 row(s) in 1.2960 seconds

列出HBase中的表

base(main):007:0> list
TABLE
0 row(s) in 0.0200 seconds

=> []

版本信息

hbase(main):008:0> version
1.2.0-cdh5.15.1, rUnknown, Thu Aug  9 09:07:24 PDT 2018

状态

hbase(main):009:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load

查看表数据

hbase(main):015:0> scan 'employee'
ROW                                           COLUMN+CELL
 mike                                         column=dept:dept_name, timestamp=1582608634676, value=TG
1 row(s) in 0.0370 seconds

插入数据(增)

#put后从左到右分别为表名,rowkey,列族:列字段,数据
hbase(main):014:0> put 'employee','mike','dept:dept_name','TG'
0 row(s) in 0.1950 seconds

删除数据(删)

#删除列
hbase(main):030:0> delete 'employee','mike','info:age'
0 row(s) in 0.0120 seconds
#删除整条
hbase(main):030:0> delete 'employee','mike'
0 row(s) in 0.0120 seconds

更改数据(改)

#针对已有数据执行put操作
hbase(main):025:0> put 'employee','mike','info:age','20'
0 row(s) in 0.0140 seconds

获取数据(查)

##获取指定rowkey的信息
hbase(main):017:0> get 'employee','mike'
COLUMN                                        CELL
 dept:dept_name                               timestamp=1582608634676, value=TG
1 row(s) in 0.0150 seconds
#获取指定列族的信息
hbase(main):021:0> get 'employee' , 'mike' ,'info'
COLUMN                                        CELL
 info:age                                     timestamp=1582609083261, value=18
 info:name                                    timestamp=1582609106954, value=mike
2 row(s) in 0.0170 seconds
#获取指定列的信息
hbase(main):022:0> get 'employee' , 'mike' ,'info:age'
COLUMN                                        CELL
 info:age                                     timestamp=1582609083261, value=18
1 row(s) in 0.0130 seconds

查看表中有几行数据

hbase(main):037:0> count 'employee'
0 row(s) in 0.0200 seconds

=> 0
发布了292 篇原创文章 · 获赞 73 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43777983/article/details/104495842