zoukankan      html  css  js  c++  java
  • 【hadoop】【demo】HBase shell

    【hadoop】【demo】HBase shell

    t_student   cf1 cf2
    rowkey id name ... age address ...
    r1 1001 Kitty   20 /  
    r2 1002 Jack   / NanJing  

     

    1.创建 用户test_super(有supergroup权限),test_guest(无supergroup权限)

    2.连接用户 test_super 并创建表 't_student' 

    kinit test_super

    hbase shell

    whoami #查看用户权限

    list #查看用户下表

     

    create 't_student','cf1'

    describe 't_student'

    user_permission 't_student' #权限:action=ADMIN

     

    grant 'user_guest','CRW', 't_student' #授权 用户 user_guest 对 't_student' 有CRW 权限

    quit

     

    3.连接用户 test_guest 并修改表 't_student' 

    kinit test_guest

    hbase shell

    whoami #查看用户权限

    list #查看用户下表

     

    describe 't_student'

    disable 't_student'

    alter 't_student',{NAME=>'cf1',NAME=>'cf2'} #修改表结构

    enable 't_student'

     

    #新增表数据:此段语句可以写入 test.sh

    vi test.sh

    输入以下内容:

    hbase shell <<EOF

    put 't_student','r1','cf1:id','1001'

    put 't_student','r1','cf1:name','Kitty'

    put 't_student','r1','cf2:age','20'

     

    put 't_student','r2','cf1:id','1002'

    put 't_student','r2','cf1:name','Jack'

    put 't_student','r2','cf2:age','22'

    put 't_student','r2','cf2:address','NanJing'

    EOF

     

    执行test.sh

    sh test.sh

     

    #修改/删除表数据

    put 't_student','r1','cf1:name','Kitty'

    put 't_student','r1','cf1:name','Amy'

     

    #查询表数据

    scan 't_student' #查全表

    scan 't_student',{LIMIT=>1} #查1行

     

    get 't_student','r1'

    get 't_student','r2'

    get 't_student','r1',{COLUMN=> ['cf1','cf2']}

    get 't_student','r2',{COLUMN=> ['cf1','cf2']}

    get 't_student','r1',{COLUMN=> ['cf1:id','cf1:name','cf2:age']}

    get 't_student','r2',{COLUMN=> ['cf1:id','cf1:name','cf2:address']}

     

    get 't_student','r1',{COLUMN=> ['cf1:id','cf1:name']}

    get 't_student','r1',{COLUMN=> 'cf1:name'}

    get 't_student','r1','cf1:id','cf1:name'

    get 't_student','r1','cf1:name'

    get 't_student','r1','cf1:id','cf1:name','cf2:age'

    get 't_student','r2','cf1:id','cf1:name','cf2:address'

     

    disable 't_student'

    drop 't_student'

     

  • 相关阅读:
    自定义 mapper
    solr 服务搭建
    jedis 连接redis
    jedis 整合 Spring
    Redis 安装
    HttpClient 工具类
    springMvc 中返回字符串 乱码解决
    linux常用命令解析
    压缩jar包
    控制反转
  • 原文地址:https://www.cnblogs.com/greenZ/p/10396544.html
Copyright © 2011-2022 走看看