zoukankan      html  css  js  c++  java
  • 【hbase】hbase的基本使用

    连接hbase

    登录服务器

    进入hbase目录:cd /***/CDH-5.13.0-1.cdh5.13.0.p0.29/bin

    执行命令:./hbase shell

     

    基本操作命令

    1. 查看所有的表:list
      创建表:create <tablename>,<colFamily1>,<colFamily2>
      Eg.create "yctest3","baseinfo","schoolinfo"
    2. 查看表信息:describe <tablename>
      Eg. describe "yctest3"插入数据(一次只能插入一列):
      put <tablename>,<rowkey>,<colFamily:col>,value
      Eg. put "yctest3",001,"baseinfo:id",1
      put "yctest3",001,"baseinfo:name","xiaoming"
      put "yctest3",001,"schoolinfo:schoolname","mingyuexiaoxue"
      put "yctest3",001,"schoolinfo:classname","三年一班"
      put "yctest3",002,"baseinfo:id",2
      put "yctest3",002,"baseinfo:name","xiaohua"
      put "yctest3",002,"schoolinfo:schoolname","mingyuexiaoxue"
      put "yctest3",002,"schoolinfo:classname","三年二班"
    3. 查询插入的数据
      查询某一行的数据:  get "yctest3",001
      查询指定列族的一行数据:get "yctest3",001,"baseinfo"
      查询指定列族的某一列的一行数据:get "yctest3",001,"baseinfo:id"
      查询所有行:scan "yctest3"查询某一列族的所有数据:scan "yctest3",{COLUMN=>"baseinfo"}
      查询多列族的所有数据:scan "yctest3",{COLUMN=>["baseinfo","schoolinfo"]}
      查询多列族的某些列的数据:scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:classname"]}
      从第3行开始查询多列族的某些列的数据:scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:schoolname"],STARTROW=>'3'}
      查询第三行之前多列族的某些列的数据:scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:schoolname"],STOPROW=>'3'}
      查询第二行到第四行多列族的某些列的数据(左闭右开,开始包含,结束不包含):scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:schoolname"],STARTROW=>'2',STOPROW=>'5'}
      查询多列族的某些列的两条数据(REVERSED => false):scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:schoolname"],LIMIT=>2}
      倒序查询多列族的某些列的两条数据:scan "yctest3",{COLUMN=>["baseinfo:name","schoolinfo:schoolname"],LIMIT=>2,REVERSED=>TRUE}
    4. 更新数据,同插入语法,只是把需要修改的rowkey,列族写清楚,然后值写成最新的数据就可以
      put "yctest3",001,"baseinfo:name","xiaoming1"
    5. 添加列族
      alter "yctest3","friendsinfo"
    6. 删除数据
      删除某一列的数据:delete "yctest3",001,"baseinfo:name1"
      删除第一行的数据:deleteall "yctest3",001
      删除整张表的数据:truncate "yctest3"
    7. 执行hbase脚本
      新建脚本文件 tb_yctest4:

    create 'yctest4','column_family_1', 'column_family_2', 'column_family_3'

    put 'yctest4','key_1','column_family_1:column_1','value1'

    put 'yctest4','key_1','column_family_1:column_2','value2'

    put 'yctest4','key_2','column_family_1:column_1','value4'

    put 'yctest4','key_2','column_family_1:column_2','value5'

    put 'yctest4','key_3','column_family_1:column_2','value5'

    put 'yctest4','key_4','column_family_1:column_1','value1'

    put 'yctest4','key_4','column_family_2:column_3','value3'

    put 'yctest4','key_4','column_family_3:','value1'

    put 'yctest4','key_4','column_family_3:','value1'

    put 'yctest4','key_5','column_family_1:column_1','value1'

    put 'yctest4','key_5','column_family_2:column_3','value4'

    put 'yctest4','key_5','column_family_3:','value2'

    执行该文件: ./hbase shell tb_yctest4

    执行成功

  • 相关阅读:
    PointToPointNetDevice doesn't support TapBridgeHelper
    NS3系列—10———NS3 NodeContainer
    NS3系列—9———NS3 IP首部校验和
    NS3系列—8———NS3编译运行
    【习题 7-6 UVA
    【Good Bye 2017 C】 New Year and Curling
    【Good Bye 2017 B】 New Year and Buggy Bot
    【Good Bye 2017 A】New Year and Counting Cards
    【Educational Codeforces Round 35 D】Inversion Counting
    【Educational Codeforces Round 35 C】Two Cakes
  • 原文地址:https://www.cnblogs.com/Calinayc/p/12715109.html
Copyright © 2011-2022 走看看