Hbase Shell Basic Operations

Source: Internet
Author: User
Tags hadoop fs

1. Start
CD $./start-hbase.sh

2. Start HBase Shell

# Find Hadoop-hbase DFS files
Hadoop fs-ls/hbase

#start Shell
HBase Shell

#Run a command to verify this cluster is actually running#
List


3. Logs Configuration
Change the default by editing Export Hbase_log_dir=/new/location/logs

4. Backstage Management

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

5. Port Service

Both Master and region servers run Web server
–browsing Master'll leads you to region servers
–regions run on port 60030

6. Basic commands

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 ', "Key\x03\x3f\xcd"

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. Build a table

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 '
First set up the table, with the column family columns families
Create ' Blog ', {name=> ' info '}, {name=> ' content '}
Then, add data, note that HBase is a Rowkey-based column database, and you can add one or more columns at a time, and you must add the specified Rowkey each time
Use the PUT command:
hbase> put ' table ', ' row_id ', ' family:column ', ' value '
Example:
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's content '

Columns can be arbitrarily extended, such as

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

8. View data-Specify 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. View data-Specify a range via scan, note that all records are sorted by timestamp as a range
Limit What columns is 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 '}
Starting with John, ending and excluding Matt's
Scan ' Blog ', {columns=> ' info:title ',startrow=> ' John ', stoprow=> ' Matt '}
Scan ' Blog ', {columns=> ' info:title ', stoprow=> ' Matt '}


10. Version
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 '

Hbase Shell Basic Operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.