在学习Hbase的shell命令,之前先得了解如何进入hbase的shell命令行,通过执行如下简单的命令回车后进入hbase的shell命令行界面

hbase shell

进入hbase命令行后,执行help然后回车,就能看到Hbase的shell命令行下有哪些命令,下面是根据help反馈的几类命令来进行学习:

一、 general commands

Command list: status, table_help, version, whoami

1、查看整理的状态

hbase(main):007:0> status

1 servers, 0 dead, 4.0000 average load

2、查看表涉及的命令对应的帮助

hbase(main):009:0> table_help

Help for table-reference commands ......

3、查看Hbase版本

hbase(main):012:0> version

0.98.6.1, r, Tue Apr 12 16:23:18 CST 2016

4、查看当前用户

hbase(main):013:0> whoami

hbaseadmin (auth:SIMPLE)

groups: users

二、ddl commands

Command list: 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

1、显式所有的表

hbase(main):001:0> list

TABLE

member

t1

2 row(s) in 1.4470 seconds

显式某一类型的表,支持正则

hbase(main):003:0> list "mem.*"

TABLE

member

2、创建表(create)

2.1 创建student的表,含有name、address、age列族

create 'student','name','address','age'

2.2 创建namespace为hbase并且表名为t4的表

create 'hbase:t4',{NAME => 'f1'}

3、查看表(describe)

语法: describe 'tablename' or describe 'namespace:tablename'

备注:也可以使用缩写的desc来查看

3.1 查看创建的student表

describe 'student'

desc 'student'

4、修改表(alter)

4.1 为student表添加nickname的列族

alter 'student',NAME => 'nickname'

4.2 删除student表的nickname的列族

alter 'student','delete' => 'nickname'

5、启用表(enable)

hbase(main):003:0> enable 'student'

0 row(s) in 0.3000 seconds

6、禁用表(disable)

hbase(main):004:0> disable 'student'

0 row(s) in 1.3610 seconds

7、删除表(drop)

hbase(main):005:0> drop 'student'

0 row(s) in 0.2750 seconds

8、判断表是否存在(exists

hbase(main):008:0> exists 'member'

Table member does exist

hbase(main):009:0> exists 'student'

Table student does not exist

9、判断表是否启用(is_enabled)

hbase(main):011:0> enable 't1'

0 row(s) in 0.0470 seconds

hbase(main):012:0> disable 't2'

0 row(s) in 1.3090 seconds

hbase(main):014:0> is_enabled 't1'

true

hbase(main):015:0> is_enabled 't2'

false

10、判断表是否禁用(is_disabled)

hbase(main):016:0> is_disabled 't1'

false

hbase(main):017:0> is_disabled 't2'

true

三、 namespace commands

Command list: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables

1、查看表空间列表

hbase(main):026:0> list_namespace

NAMESPACE

default

hbase

2 row(s) in 0.0130 seconds

2、查看表空间

hbase(main):027:0> describe_namespace 'hbase'

DESCRIPTION

{NAME => 'hbase'}

1 row(s) in 0.0180 seconds

3、查看表空间的表

hbase(main):029:0> list_namespace_tables 'hbase'

TABLE

acl

meta

namespace

t4

4 row(s) in 0.0330 seconds

4、创建表空间

hbase(main):031:0> create_namespace 'test2'

0 row(s) in 0.0760 seconds

hbase(main):032:0> list_namespace

NAMESPACE

default

hbase

test2

3 row(s) in 0.0200 seconds

5、修改表空间

hbase(main):045:0> alter_namespace 'test2',{METHOD => 'set', 'PROERTY_NAME' => 'PROPERTY_VALUE'}

0 row(s) in 0.0450 seconds

hbase(main):046:0> describe_namespace 'test2'

DESCRIPTION

{NAME => 'test2', PROERTY_NAME => 'PROPERTY_VALUE'}

1 row(s) in 0.0050 seconds

hbase(main):047:0> alter_namespace 'test2',{METHOD => 'unset', NAME=>'PROERTY_NAME'}

0 row(s) in 0.0300 seconds

hbase(main):048:0> describe_namespace 'test2'

DESCRIPTION

{NAME => 'test2'}

1 row(s) in 0.0080 seconds

6、删除表空间

hbase(main):049:0> drop_namespace 'test2'

0 row(s) in 0.0990 seconds

hbase(main):050:0> list_namespace

NAMESPACE

default

hbase

2 row(s) in 0.0130 seconds

四、dml commands

Command list: append, count, delete, deleteall, get, get_counter, incr, put, scan, truncate, truncate_preserve

1、添加记录

添加rowkey为rowkey001记录

put 'student','rowkey001','address:colum1','jiaxi'

put 'student','rowkey001','age:colum1','100'

2、查询记录

查询studen表中rowkey为rowkey001的记录

get 'student','rowkey001'

查询student表中rowkey为rowkey001,并且列族age为colum1的记录

get 'student','rowkey001','age:colum1'

3、扫描表

全表扫描student的数据

scan 'student'

只扫描stdent的前2行记录

scan 'student',{LIMIT => 2}

4、查看表的记录数

查看student表的记录数

count 'student'

5、删除记录

删除student中rowkey001为aget:colum1的值

delete 'student','rowkey001','age:colum1'

删除整行的数据

deleteall 'student','rowkey001'

删除整个表的数据

truncate 'student'

Hbase的shell命令学习的更多相关文章

  1. HBase基本shell命令

    HBase基本shell命令 以下shell命令都是经过测试,正常展示,若有不足,还望指点! 1.创建表 create ‘表名称’,‘列族名称1’,‘列族名称1’create 'test_M_01', ...

  2. HBase的Shell命令

    1.HBase提供了一个shell的终端给用户交互 2.HBase Shell的DDL操作 (1)先进入HBase的 Shell命令行,即HBASE_HOME/bin/hbase shell …… & ...

  3. 原 HBase 常用Shell命令

    HBase 常用Shell命令 1.进入hbase shell console $HBASE_HOME/bin/hbase shell 如果有kerberos认证,需要事先使用相应的keytab进行一 ...

  4. HBase的Shell命令和JavaAPI

    HBase的shell操作和JavaAPI的使用: Shell 表操作 创建表 create 'student','info' #表名 列族 插入表 put 'student','1001','inf ...

  5. (转)HBase 常用Shell命令

    转自:http://my.oschina.net/u/189445/blog/595232 hbase shell命令                             描述  alter 修改 ...

  6. 2、Shell命令学习笔记

    1.Shell命令行解释器 1.1 Shell命令解释器 Shell是一个特殊的应用程序,介于操作系统内核和用户之间,负责接收用户输入的操作指令(命令)并进行解释,将需要执行的操作传递给内核执行. 因 ...

  7. HBase 学习之路(五)——HBase常用 Shell 命令

    一.基本命令 打开Hbase Shell: # hbase shell 1.1 获取帮助 # 获取帮助 help # 获取命令的详细信息 help 'status' 1.2 查看服务器状态 statu ...

  8. HBase 常用Shell命令

    两个月前使用过hbase,现在最基本的命令都淡忘了,留一个备查~ 进入hbase shell console$HBASE_HOME/bin/hbase shell如果有kerberos认证,需要事先使 ...

  9. 5 HBase 常用Shell命令

    进入hbase shell console $HBASE_HOME/bin/hbase shell 如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成 ...

随机推荐

  1. spoj 694 求一个字符串中不同子串的个数

    SPOJ Problem Set (classical) 694. Distinct Substrings Problem code: DISUBSTR Given a string, we need ...

  2. Codeforces 8D Two Friends 三分+二分+计算几何

    题目链接:点击打开链接 题意:点击打开链接 三分house到shop的距离,二分这条斜边到cinema的距离 #include<stdio.h> #include<string.h& ...

  3. Linux的定时器

    在服务端程序设计中,与时间有关的常见任务有: 获取当前时间,计算时间间隔: 定时操作,比如在预定的时间执行一项任务,或者在一段延时之后执行一项任务. Linux 时间函数 Linux 的计时函数,用于 ...

  4. java的学习之路01

    [原创 - 尚学堂科技 - 马士兵老师] JAVA自学之路 一:学会选择 [转载请注明出处:http://www.bjsxt.com/zixue/zixuezhilu_1.html] 为了就业,不少同 ...

  5. 自制MVC框架基础插件介绍

    本文介绍的基础插件不是实现BeforehandCommonAttribute或ProceedPlugin的postsharp插件,这些都是自定义的基础性的拦截,而且在项目中经常用到. 1). Comp ...

  6. struts2 在拦截器进行注入(依据Action是否实现自己定义接口)

    比如:经常在Action中都须要获取当前登录的User,就须要获取Session.然后从Session获取当前登录的User,由于这些步骤都是反复操作,能够想办法在拦截器中进行实现.能够自己定义一个接 ...

  7. 将json数组字符串转换为json数组对象(值是json对象的数组)

    var str1 ='[{"name":"kevin","age":18},{"name":"rose&quo ...

  8. 李洪强iOS开发之iOS好文章收集

    李洪强iOS开发之iOS好文章收集 该文收集朋友们转发或自己的写的技术文章,如果你也有相关的好文章,欢迎留言,当好文章多的时候,我会对这些好文章进行分门别类 文章 简述 日期 直播服务配置 使用 ng ...

  9. 大型跨境电商 JVM 调优经历

    前提: 某大型跨境电商业务发展非常快,线上机器扩容也很频繁,但是对于线上机器的运行情况,特别是jvm内存的情况,一直没有一个统一的标准来给到各个应用服务的owner.经过618大促之后,和运维的同学讨 ...

  10. flex and bison学习笔记01

    工作需要,学习一下Flex and bison,以前在编译原理的课上听老师说过他们的前辈,lex and yacc.Flex and bison就是lex and yacc的升级版. 参考书:flex ...