• Hbase shell基本操作


    1、启动
    cd <hbase_home>/bin
    $ ./start-hbase.sh

    2、启动hbase shell

    # find hadoop-hbase dfs files
    hadoop fs -ls /hbase

    #start shell
    hbase shell

    #Run a command to verify that cluster is actually running#
    list


    3、logs配置
    Change the default by editing <hbase_home>/conf/hbase-env.sh
    export HBASE_LOG_DIR=/new/location/logs

    4、后台管理

    HBase comes with web based management
    – http://localhost:60010

    5、端口服务

    Both Master and Region servers run web server
    – Browsing Master will lead you to region servers
    – Regions run on port 60030

    6、基本命令

    Quote all names
    Table and column names
    – Single quotes for text
    • hbase> get 't1', 'myRowId'
    – Double quotes for binary
    • Use hexadecimal representation of that binary value
    • hbase> get 't1', "keyx03x3fxcd"

    Display cluster's status via status command
    – hbase> status
    – hbase> status 'detailed'
    • Similar information can be found on HBase
    Web Management Console
    – http://localhost:60010

    7、建表

    Create Table

    Create table called 'Blog' with the following
    schema
    – 2 families
    –'info' with 3 columns: 'title', 'author', and 'date'
    –'content' with 1 column family: 'post'
    首先建立表,附带列族columns families
    create 'Blog', {NAME=>'info'}, {NAME=>'content'}
    然后,添加数据,注意hbase是基于rowkey的列数据库,可以一次添加一列或多列,必须每次添加指定rowkey
    使用Put命令:
    hbase> put 'table', 'row_id', 'family:column', 'value'
    例子:
    put 'Blog', 'Michelle-001', 'info:title', 'Michelle'
    put 'Blog', 'Matt-001', 'info:author', 'Matt123'
    put 'Blog', 'Matt-001', 'info:date', '2009.05.01'
    put 'Blog', 'Matt-001', 'content:post', 'here is content'

    列可以任意的扩展,比如

    put 'Blog', 'Matt-001', 'content:news', 'news is new column'

    8、查看数据-指定rowid

    #查看数据库
    count 'Blog'
    count 'Blog', {INTERVAL=>2}

    #查看行数据
    get 'table', 'row_id'
    get 'Blog', 'Matt-001'
    get 'Blog', 'Matt-001',{COLUMN=>['info:author','content:post']}
    #时间戳
    get 'Blog', 'Michelle-004',{COLUMN=>['info:author','content:post'],TIMESTAMP=>1326061625690}
    #版本
    get 'Blog', 'Matt-001',{ VERSIONS=1}
    get 'Blog', 'Matt-001',{COLUMN=>'info:date', VERSIONS=1}
    get 'Blog', 'Matt-001',{COLUMN=>'info:date', VERSIONS>=2}
    get 'Blog', 'Matt-001',{COLUMN=>'info:date'}


    9、查看数据-通过scan指定范围,注意,所有的记录均按时间戳作为范围排序
    Limit what columns are retrieved
    – hbase> scan 'table', {COLUMNS=>['col1', 'col2']}
    • Scan a time range
    – hbase> scan 'table', {TIMERANGE => [1303, 13036]}
    • Limit results with a filter
    – hbase> scan 'Blog', {FILTER =>org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
    – More about filters later

    scan 'Blog', {COLUMNS=>'info:title'}
    开始于John,结束并排除Matt的
    scan 'Blog', {COLUMNS=>'info:title',STARTROW=>'John', STOPROW=>'Matt'}
    scan 'Blog', {COLUMNS=>'info:title', STOPROW=>'Matt'}


    10、版本
    put 'Blog', 'Michelle-004', 'info:date', '1990.07.06'
    put 'Blog', 'Michelle-004', 'info:date', '1990.07.07'
    put 'Blog', 'Michelle-004', 'info:date', '1990.07.08'
    put 'Blog', 'Michelle-004', 'info:date', '1990.07.09'
    get 'Blog', 'Michelle-004',{COLUMN=>'info:date', VERSIONS=>3}


    11、Delete records
    delete 'Blog', 'Bob-003', 'info:date'

    12、Drop table
    – Must disable before dropping
    – puts the table “offline” so schema based operations can
    be performed
    – hbase> disable 'table_name'
    – hbase> drop 'table_name'

  • 相关阅读:
    13,发布CRM
    12,nginx+uWSGI+django+virtualenv+supervisor发布web服务器
    11.2,nginx负载均衡实验
    11.1,nginx集群概念
    11,nginx入门与实战
    10,python开发之virtualenv与virtualenvwrapper
    9.5web service基础知识
    9.4python开发之virtualenv与virtualenvwrapper
    9.3centos7安装python3 以及tab补全功能
    Google 浏览器被劫持怎么办?
  • 原文地址:https://www.cnblogs.com/starcrm/p/7447244.html
Copyright © 2020-2023  润新知