Hbase的常用shell操作

来源:互联网 发布:淘宝爱玩电玩数码店 编辑:程序博客网 时间:2024/06/15 18:17

Hbase的常用shell操作

标签: shellhbasehbaseshellscanhdfs
538人阅读 评论(0)收藏举报
分类:
作者同类文章X
    • 1.进入hbase的shell界面:
    [root@lijie bin]# ./hbase shell
    • 1
    • 1
    • 2.创建表
    hbase(main):002:0> create 'tablename','cf1','cf2'0 row(s) in 0.5830 seconds=> Hbase::Table - tablename
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4
    • 3.列出所有表
    hbase(main):003:0> listTABLE                                                                                                                                                              stu                                                                                                                                                                t1                                                                                                                                                                 tablename                                                                                                                                                          3 row(s) in 0.0100 seconds=> ["stu", "t1", "tablename"]
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 4.插入数据
    hbase(main):005:0> put 'tablename','rowkey01','cf1:name','lijie'0 row(s) in 0.0570 secondshbase(main):006:0> put 'tablename','rowkey01','cf1:addr','chongqing'0 row(s) in 0.0070 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 5.查看表的所有数据
    hbase(main):012:0> scan 'tablename'ROW                                       COLUMN+CELL                                                                                                               rowkey01                                 column=cf1:addr, timestamp=1486547683853, value=chongqing                                                                 rowkey01                                 column=cf1:name, timestamp=1486547607486, value=lijie                                                                     rowkey02                                 column=cf1:addr, timestamp=1486547771954, value=shenzhen                                                                  rowkey02                                 column=cf1:name, timestamp=1486547737573, value=zhangsan                                                                 2 row(s) in 0.0280 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 6.根据rowkey查看数据
    hbase(main):015:0> get 'tablename','rowkey01'COLUMN                                    CELL                                                                                                                      cf1:addr                                 timestamp=1486547683853, value=chongqing                                                                                  cf1:name                                 timestamp=1486547607486, value=lijie                                                                                     2 row(s) in 0.0250 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7.查询数据的条数
    hbase(main):016:0> count 'tablename'2 row(s) in 0.0410 seconds=> 2
    • 1
    • 2
    • 3
    • 4
    • 5
    • 1
    • 2
    • 3
    • 4
    • 5
    • 8.获取一行指定列族的数据
    hbase(main):017:0> get 'tablename','rowkey01','cf1'COLUMN                                    CELL                                                                                                                      cf1:addr                                 timestamp=1486547683853, value=chongqing                                                                                  cf1:name                                 timestamp=1486547607486, value=lijie                                                                                     2 row(s) in 0.0120 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 9.获取一行指定列族某列数据
    hbase(main):021:0> get 'tablename','rowkey01','cf1:name'COLUMN                                    CELL                                                                                                                      cf1:name                                 timestamp=1486547607486, value=lijie                                                                                     1 row(s) in 0.0080 seconds
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4
    • 10.删除列族
    hbase(main):027:0> delete 'tablename','rowkey01','cf1:addr'0 row(s) in 0.0030 seconds
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3
    • 11.删除一整行数据
    hbase(main):029:0> deleteall 'tablename','rowkey01' 0 row(s) in 0.0090 seconds
    • 1
    • 2
    • 1
    • 2
    • 12.更新一条数据
    hbase(main):032:0> put 'tablename','rowkey02','cf1:addr','shanghai'0 row(s) in 0.0040 seconds
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3
    • 13.是否enable或者disable
    hbase(main):034:0> is_enabled 'tablename'true                                                                                                                                                               0 row(s) in 0.0070 secondshbase(main):035:0> is_disabled 'tablename'false                                                                                                                                                              0 row(s) in 0.0050 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 14.查看表是否存在
    hbase(main):036:0> exists 'tablename'Table tablename does exist                                                                                                                                         0 row(s) in 0.0050 seconds
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4
    • 15.服务器状态
    hbase(main):037:0> status1 servers, 0 dead, 5.0000 average load
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3
    • 16.hbase版本
    hbase(main):039:0> version1.0.3, rf1e1312f9790a7c40f6a4b5a1bab2ea1dd559890, Tue Jan 19 19:26:53 PST 2016
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3
    • 17.删除一个列族
    hbase(main):040:0> disable 'tablename'0 row(s) in 1.2310 secondshbase(main):041:0> alter 'tablename',{NAME => 'cf1',METHOD => 'delete'} Updating all regions with the new schema...1/1 regions updated.Done.0 row(s) in 1.1460 secondshbase(main):042:0> enable 'tablename'0 row(s) in 0.1550 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 18.获得表的描述
    hbase(main):044:0> describe 'tablename'Table tablename is ENABLED                                                                                                                                         tablename                                                                                                                                                          COLUMN FAMILIES DESCRIPTION                                                                                                                                        {NAME => 'cf2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                        1 row(s) in 0.0150 secondshbase(main):045:0> desc 'tablename'Table tablename is ENABLED                                                                                                                                         tablename                                                                                                                                                          COLUMN FAMILIES DESCRIPTION                                                                                                                                        {NAME => 'cf2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                        1 row(s) in 0.0240 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 19.清空整个表
    hbase(main):046:0> truncate 'tablename'Truncating 'tablename' table (it may take a while): - Disabling table... - Truncating table...0 row(s) in 1.3600 seconds
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 20.删除整个表
    hbase(main):048:0> disable 'tablename'0 row(s) in 1.1720 secondshbase(main):049:0> drop 'tablename'0 row(s) in 0.1720 secondshbase(main):050:0> listTABLE                                                                                                                                                              stu                                                                                                                                                                t1                                                                                                                                                                 2 row(s) in 0.0100 seconds=> ["stu", "t1"]
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    下次更新filter操作,未完待续。。。。

    1
    0
     
     

      相关文章推荐
    • Hbase入门API操作和 shell操作
    • HBase Shell 常用操作
    • HBase客户端操作
    • HBase学习笔记 --- 基本shell操作
    • HBase Shell工具操作HBase
    • hbase的shell操作
    • HBase Shell 基本操作
    • hbase shell常用操作指令
    • Hbase 基本shell操作命令
    • HBase shell基础和常用命令详解
    原创粉丝点击