HBase Shell

$ ./bin/hbase shell   # 进入交互界面

DDL操作:

  1. create:创建表(默认命名空间为default)

    # create '表名','列族1','列族2'...
    hbase(main):005:0> create 'student','info'
    0 row(s) in 1.4250 seconds
    => Hbase::Table - student
  1. list:列出所有table

    hbase(main):005:0> list     # 列出所有的Table
    TABLE
    student
    1 row(s) in 0.0160 seconds
    => ["student"]
  2. describe '表名':查看表详细信息

    # 查看表详细信息describe
    hbase(main):007:0> describe 'student'
    Table student is ENABLED
    student
    COLUMN FAMILIES DESCRIPTION
    {NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '', BLOCKCACHE => 'true', BLOCKSIZE => '', REPLICATION_SCOPE => ''}
    1 row(s) in 0.1090 seconds
    • NAME:列族名

    • BLOOMFILTER:布隆过滤器

    • VERSIONS:版本数,当前列族可以存多少版本

  3. alter:修改某列族的信息:

    # alter '表名',{NAME=>'列族名' ....}
    # 比如:修改VERSION版本数
    hbase(main):011:0> alter 'student',{NAME=>'info',VERSIONS=>3}
    hbase(main):012:0> describe 'student' # 再次查看
    {NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '',....
  4. 删除表,需要先disabled

    # 删除表,需要先disabled,再drop
    hbase(main):016:0> disable 'student'
    hbase(main):017:0> drop 'student'

命名空间:

  1. 查看命名空间:list_namespace

    hbase(main):019:0> list_namespace
    NAMESPACE
    default
    hbase
    2 row(s) in 0.0330 seconds
  2. 创建命名空间:create_namespace '空间名'

    hbase(main):020:0> create_namespace 'bigdata'
  3. 创建表到指定命名空间

    hbase(main):022:0> create 'bigdata:student','info'
    0 row(s) in 2.2200 seconds
    => Hbase::Table - bigdata:student
  4. 删除命名空间:drop_namespace (必须是空的命名空间,要先删表)

    hbase(main):023:0> disable 'bigdata:student'
    0 row(s) in 2.2510 seconds
    hbase(main):024:0> drop 'bigdata:student'
    0 row(s) in 1.2370 seconds
    hbase(main):026:0> drop_namespace 'bigdata'
    0 row(s) in 0.8750 seconds

DML

  1. put:增加,修改数据

    # put '表名','RowKey','列族:列名','数据'
    hbase(main):030:0> put 'test','','info1:name','zhangsan'
  2. scan:扫描查询(最大范围是查整个table)

    # 注意:下面查询结果为3条数据
    hbase(main):040:0> scan 'test'
    ROW COLUMN+CELL
    1001 column=info1:age, timestamp=1571381227061, value=17
    1001 column=info1:name, timestamp=1571380877053, value=zhangsan
    1001 column=info2:addr, timestamp=1571381241065, value=shanghai
    1002 column=info1:age, timestamp=1571381266364, value=16
    1002 column=info1:name, timestamp=1571381256744, value=lily
    1002 column=info2:addr, timestamp=1571381276540, value=beijing
    1003 column=info2:addr, timestamp=1571381290769, value=nanjing
    3 row(s) in 0.0590 seconds
    # 查看,左闭右开区间
    hbase(main):044:0> scan 'test',{STARTROW=>'',ENDROW=>''}
    # 查看,覆盖的版本,已经type
    hbase(main):059:0> scan 'test',{RAW=>TRUE,VERSIONS=>3}
    ROW COLUMN+CELL
    1001 column=info1:age, timestamp=1571381227061, value=17
    1001 column=info1:name, timestamp=1571382287224, type=DeleteColumn
    1001 column=info1:name, timestamp=1571382179439, value=zhangsansan
    1001 column=info1:name, timestamp=1571382130052, value=zhang
    1001 column=info2:addr, timestamp=1571381241065, value=shanghai
    1002 column=info1:age, timestamp=1571381266364, value=16
    1002 column=info1:name, timestamp=1571381256744, value=lily
    1002 column=info2:addr, timestamp=1571381276540, value=beijing
    1003 column=info2:addr, timestamp=1571381290769, value=nanjing
  3. get:查询(最大范围是查RowKey)

    # 查看一条数据,一个RowKey
    hbase(main):041:0> get 'test',''
    COLUMN CELL
    info1:age timestamp=1571381227061, value=17
    info1:name timestamp=1571380877053, value=zhangsan
    info2:addr timestamp=1571381241065, value=shanghai
    1 row(s) in 0.0050 seconds
    # 查看某列
    hbase(main):042:0> get 'test','','info1:name'
    COLUMN CELL
    info1:name timestamp=1571380877053, value=zhangsan
  4. delete:删除数据,在shell命令中必须指定到列,API中可以指定到列族

    # 指定到列
    hbase(main):054:0> delete 'test','','info1:name'
  5. alter:变更表信息

    # 将info列族修改为可以存放3个版本
    hbase(main):004:0> alter 'stu',{NAME=>'info',VERSIONS=>3}
  6. 多版本查询

    hbase(main):007:0> get 'stu','',{COLUMN=>'info:name',VERSIONS=>3}
    COLUMN CELL
    info:name timestamp=1571383299883, value=lucy
    info:name timestamp=1571383293258, value=lily

【hbase】hbase的shell操作笔记的更多相关文章

  1. Hbase快速开始——shell操作

    一. 介绍 HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实 ...

  2. HBase(四)HBase集群Shell操作

    一.进入HBase命令行 在你安装的随意台服务器节点上,执行命令:hbase shell,会进入到你的 hbase shell 客 户端 [admin@node21 ~]$ hbase shell S ...

  3. Hbase数据结构和shell操作

    Hbase的数据结构 基本要素:命名空间.表.行.列.单元格,region,时间戳. 1.命名空间:NameSpaces的作用 Table:表,所有的表都是命名空间的成员,即表必属于某个命名空间,如果 ...

  4. HBase学习之路 (三)HBase集群Shell操作

    进入HBase命令行 在你安装的随意台服务器节点上,执行命令:hbase shell,会进入到你的 hbase shell 客 户端 [hadoop@hadoop1 ~]$ hbase shell S ...

  5. Hbase(二)【shell操作】

    目录 一.基础操作 1.进入shell命令行 2.帮助查看命令 二.命名空间操作 1.创建namespace 2.查看namespace 3.删除命名空间 三.表操作 1.查看所有表 2.创建表 3. ...

  6. Hbase的常见shell操作

    1.带namespace的:https://blog.csdn.net/opensure/article/details/46470969 2.http://www.cnblogs.com/xing9 ...

  7. HBase学习笔记——配置及Shell操作

    1.HBase的配置 还是以前配置的集群,见:http://www.cnblogs.com/DarrenChan/p/6493373.html 我们约定:weekend03和weekend04放HMa ...

  8. Hbase之shell操作

    一. 介绍 HBase是一个分布式的.面向列的 开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源 ...

  9. HBase(3)-安装与Shell操作

    一. 安装 1. 启动Zookeeper集群 2. 启动Hadoop集群 3. 上传并解压HBase -bin.tar.gz -C /opt/module 4. 修改配置文件 #修改habse-env ...

随机推荐

  1. Linux共享文件夹映射到Windows磁盘

    摘自:https://www.jianshu.com/p/4a06121450e5 1.1方案背景 本方案就是在解决磁盘不足的问题而产生的,利用映射盘的原理将Linux共享文件夹映射到Windows磁 ...

  2. shell 判断一个字符串是否由字母数字组成

    摘自:http://blog.51cto.com/lynnteng0/804520 describe="it's a describe by yourself" if echo & ...

  3. 基于EasyNVR摄像机无插件直播方案二次开发实现自己的摄像机IPC-NVR无插件化直播解决方案

    背景介绍 在之前的博客中<基于EasyNVR实现RTSP/Onvif监控摄像头Web无插件化直播监控>,对EasyNVR所实现的功能我们已经有较多描述,这些也在方案地址:http://ww ...

  4. EasyNVR网页无插件播放摄像机RTSP流是如何调取接口在Web页实现多窗口同时直播的

    背景需求 在互联网飞速发展的时代,开发者常会说的一个词就是"跨平台".自从移动端的用户需求越来越大,H5逐渐发展,跨平台似乎已经成为了软件开发不可或缺的技术.EasyNVR互联网直 ...

  5. [LeetCode] 232. Implement Queue using Stacks 用栈来实现队列

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  6. [LeetCode] 533. Lonely Pixel II 孤独的像素 II

    Given a picture consisting of black and white pixels, and a positive integer N, find the number of b ...

  7. ingress Whitelisting白名单机制

    Whitelisting To restrict the service in a way that only a list of IPs can access it, modify the ingr ...

  8. acme自动证书申请

    安装acme.sh curl https://get.acme.sh | sh acme.sh默认安装到了当前家目录. [root@iZbp17hycbhnayg00ohec9Z ~]# ~/.acm ...

  9. 为Ubuntu笔记本电脑创建WiFi热点共享上网

    from: linux公社 http://www.linuxidc.com/Linux/2014-02/97139.htm   该文由土木坛子转译而来,说是转译,其实看截图就可以方便的设置,没有任何命 ...

  10. JMeter进行Apache Kafka负载测试

    1.卡夫卡负载测试 在这个Apache Kafka教程中,我们将了解如何使用Apache JMeter,如何在Apache Kafka上执行Kafka负载测试.此外,这个Kafka负载测试教程教我们如 ...