日期:2014-05-16  浏览次数:20487 次

Hbase shell 常用命令(1)

学习笔记,转自:http://blog.csdn.net/scutshuxue/article/details/6988348

?

下面我们看看HBase Shell的一些基本操作命令,我列出了几个常用的HBase Shell命令,如下:

名称

命令表达式

创建表

create '表名称', '列名称1','列名称2','列名称N'

添加记录??? ??

put '表名称', '行名称', '列名称:', '值'

查看记录

get '表名称', '行名称'

查看表中的记录总数

count? '表名称'

删除记录

delete? '表名' ,'行名称' , '列名称'

删除一张表

先要屏蔽该表,才能对该表进行删除,第一步 disable '表名称' 第二步? drop '表名称'

查看所有记录

scan "表名称"??

查看某个表某个列中所有数据

scan "表名称" , ['列名称:']

更新记录?

就是重写一遍进行覆盖

?

下面是一些常见命令的说明,在hbaseshell中输入help的帮助信息,在本文中,我们先介绍前3个,后面2个,将在下一篇博文中介绍。

COMMAND GROUPS:

? Group name: general

? Commands: status, version

?

? Group name: ddl

? Commands: alter, create, describe, disable,drop, enable, exists, is_disabled, is_enabled, list

?

? Group name: dml

? Commands: count, delete, deleteall, get,get_counter, incr, put, scan, truncate

?

? Group name: tools

? Commands: assign, balance_switch, balancer,close_region, compact, flush, major_compact, move, split, unassign, zk_dump

?

? Group name: replication

? Commands: add_peer, disable_peer,enable_peer, remove_peer, start_replication, stop_replication

??

一、一般操作

1.查询服务器状态

hbase(main):024:0>status

3 servers, 0 dead,1.0000 average load

?

2.查询hive版本

?

hbase(main):025:0>version

0.90.4, r1150278,Sun Jul 24 15:53:29 PDT 2011

?

二、DDL操作

?

1.创建一个表

hbase(main):011:0>create 'member','member_id','address','info'???

0 row(s) in 1.2210seconds

?

2.获得表的描述

hbase(main):012:0>list

TABLE???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

member??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

1 row(s) in 0.0160seconds

hbase(main):006:0>describe 'member'

DESCRIPTION??????????????????????????????????????????????????????????????????????????????????????????ENABLED???????????????????????????????????????????????

?{NAME => 'member', FAMILIES => [{NAME=> 'address', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', true?????????????????????????????????????????????????

? VERSIONS => '3', COMPRESSION => 'NONE',TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'fa???????????????????????????????????????????????????????

?lse', BLOCKCACHE => 'true'}, {NAME =>'info', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSI???????????????????????????????????????????????????????

?ONS => '3', COMPRESSION => 'NONE', TTL=> '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false',????????????????????????????????????????????????????????

?BLOCKCACHE => 'true'}]}????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

1 row(s) in 0.0230seconds

?

3.删除一个列族,alter,disable,enable

我们之前建了3个列族,但是发现member_id这个列族是多余的,因为他就是主键,所