Hbase Quick Start -- shell operation

Source: Internet
Author: User
Tags hadoop mapreduce

I. Introduction

Hbase is a distributed, column-oriented open-source database. It originated from Google's paper bigtable: a distributed storage system for structured data. Hbase is an open-source implementation of Google bigtable. It uses hadoop HDFS as its file storage system, hadoop mapreduce to process massive data in hbase, and zookeeper as a collaborative service. 

Hbase stores data in tables. A table consists of rows and columns. The column is divided into several column families/column families ).

 

As shown in, key1, key2, key3 is the unique row key value of three records, column-family1, column-family2, and column-family3 are three columns, each containing several columns. For example, the columnfamily of column-family1 contains two columns named column1 and column2. T1: ABC, T2: gdxdf is a cell uniquely identified by row key1 and the column-family1-column1. The cell contains two data types: ABC and gdxdf. The timestamps of the two values are different, T1, T2, and hbase returns the value of the latest time to the requester.

 

Ii. Installation

Download the latest hbase version and put it in a suitable directory, such as/usr/local or/OPT.

Decompress the package

tar -zxvf hbase-x.y.z tar.gz

 

Iii. command line operations

Enter the decompressed directory, enable hbase, and start hbase Shell

bin/start-hbase.shbin/hbase shell

Enter help to view the Command Group

Some command lists

Group example below

General Operation

Query Server Status

Query hbase version

 

DDL operations

1. Create a table

create ‘table1‘, ‘tab1_id‘, ‘tab1_add‘, ‘tab1_info‘

2. List all tables

list

3. Get the table description

describe "table1"

4. delete a columnfamily disable alter enable

disable ‘table1‘alter ‘table1‘, {NAME=>‘tab1_add‘, METHOD=>‘delete‘}enable ‘table1‘

5. Check whether the table exists.

exists ‘table2‘

6. Determine whether the table is 'enable'

is_enabled ‘table1‘

Determine whether the table is 'disable'

is_disabled ‘table1‘

7. delete a table

disable ‘table1‘drop ‘table1‘

 

DML operations

1. Insert several records

put ‘member‘, ‘scutshuxue‘, ‘info:age‘, ‘24‘put ‘member‘, ‘scutshuxue‘, ‘info:birthday‘, ‘1987-06-17‘put ‘member‘, ‘scutshuxue‘, ‘info:company‘, ‘alibaba‘put ‘member‘, ‘scutshuxue‘, ‘address:contry‘, ‘china‘put ‘member‘, ‘scutshuxue‘, ‘address:province‘, ‘zhejiang‘put ‘member‘, ‘scutshuxue‘, ‘address:city‘, ‘hangzhou‘

2. Full table Scan

3. Get data get

3.1 obtain all data of a row

3.2 obtain all data of a row and columnfamily.

3.3 obtain all data of a row, column family, and column

4. Update a record put (change the scutshuxue age to 99)

put ‘member‘, ‘scutshuxue‘, ‘info:age‘, 99

5. delete Delete and deleteall

5.1 (delete the row 'scutshuxue' and the column family is the value of age in 'info'

delete ‘member‘, ‘scutshuxue‘, ‘info:age‘

5.2 Delete the entire row

deleteall ‘member‘, ‘scutshuxue‘

6. query the number of rows in the table

count ‘member‘

7. Add the 'info: age' field to the ID of 'xiaoming' and use counter to increase the value.

incr ‘member‘,  ‘xiaoming‘, ‘info:age‘   

8. Clear the entire table

truncate ‘member‘

 

Tools operation

1. Create a table

 

Iv. Reference

Http://smallwildpig.iteye.com/blog/1705718

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.