Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of getting started with HBase Sub-Project in hadoop

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the example analysis of the introduction of HBase sub-project in hadoop, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.

HBase provides a hbase shell similar to mysql and other relational databases, through which you can operate the related tables and column families in HBase, and the help command of HBase shell introduces the commands supported by HBase in detail.

Here is a simple example of student table scores. The table data are as follows:

Name grad course:math course:english Tom 1 89 97 Jerry 2 100 90

Here grad is a column for a table, course is a column family for a table, and this column family consists of two columns: math and english. Of course, we can create more column families in course according to our needs, such as computer,physics,art and other corresponding columns to add to the course column family.

The commonly used hbase shell commands listed below are as follows:

Name

Command expression

Create a tabl

Create 'table name', 'column name 1' column name 2 'column name N'

Add record

Put 'Table name', 'Row name', 'column name:', 'value'

View record

Get 'table name', 'row name'

View the total number of records in the table

Count 'table name'

Delete record

Delete 'Table name', 'Row name', 'column name'

Delete a table

The table must be blocked before it can be deleted. First step disable 'table name' second step drop 'table name'

View all records

Scan "Table name"

View all the data in a table and a column

Scan "Table name", ['column name:']

Update record

Is to rewrite it and overwrite it.

1. Create a table scores with two column families, grad and courese, as follows:

Hbase (main): 002create 'scores',' grade', 'course' 0 row (s) in 4.1610 seconds

2. Check which tables are in the current HBase.

Hbase (main): 003row 0 > list scores 1 row (s) in 0.0210 seconds

3. View the construction of the table

Hbase (main): 004scores' {NAME = > 'scores', IS_ROOT = >' false', IS_META = > 'false', FAMILIES = > [{NAME = >' course', BLOOMFILTER = > 'false', IN_MEMORY = >' false', LENGTH = > '2147483647', BLOCKCACHE = > 'false', VERSIONS = >' 3', TTL = >'- 1', COMPRESSION = > 'NONE'}, {NAME = >' grade', BLOOMFILTER = > 'false', IN_MEMORY = >' false', LENGTH = > '2147483647', BLOCKCACHE = > 'false', VERSIONS = >' 3' TTL = >'- 1century, COMPRESSION = > 'NONE'}]} 1 row (s) in 0.0130 seconds

4. Add a row of data, the row name is Tom column family grad, and the column name is "" value bit 1.

Hbase (main): 005Tom', 0 > put 'scores',' Tom', 'grade:',' 1' 0 row (s) in 0.0070 seconds

5. Add a column to the column family of the data in the Tom row

Hbase (main): 006 Tom', 0 > put 'scores',' Tom', 'course:math',' 89' 0 row (s) in 0.0040 seconds

6. Add a column to the column family of the data in the Tom row

Hbase (main): 007Tom', 0 > put 'scores',' Tom', 'course:english',' 97' 0 row (s) in 0.0030 seconds

7. Add a row of data, the row name is Jerry column family grad, and the column name is "" value bit 2.

Hbase (main): 008: 0 > put 'scores',' Jerry', 'grade:',' 2' 0 row (s) in 0.0040 seconds

8. Add a column to the column family of the data in the Jerry row

Hbase (main): 009 Jerry', 0 > put 'scores',' Jerry', 'course:math',' 100' 0 row (s) in 0.0030 seconds

9. Add a column to the column family of the data in the Jerry row

Hbase (main): 010scores', 0 > put 'scores',' Jerry', 'course:english',' 90' 0 row (s) in 0.0050 seconds

10. View Tom-related data in the scores table

Hbase (main): 011scores', 0 > get 'scores',' Tom' COLUMN CELL course:english timestamp=1224726394286, value=97 course:math timestamp=1224726377027, value=89 grade: timestamp=1224726360727, value=1 3 row (s) in 0.0070 seconds

11. Determine whether the table is enable

Hbase (main): 012scores' true 0 > is_enabled 'scores' true 0 row (s) in 0.0110seconds

12. Determine whether the table is disable

Hbase (main): 013scores' false 0 > is_disabled 'scores' false 0 row (s) in 0.0110seconds

13. Delete table scores

Hbase (main): 014 scores' 0 > disable 'scores' 0 row (s) in 2.0590seconds hbase (main): 030 scores' 0 > drop' scores' 0 row (s) in 1.1070seconds

14. Query whether the table exists

Hbase (main): 015scores' Table scores doesexist 0 > exists' scores' Table scores doesexist 0 row (s) in 0.1610seconds

15. View all the data in the scores table

Hbase (main): 016 row 0 > scan 'scores' ROW COLUMN+CELL Tom column=course:english, timestamp=1224726394286, value=97 Tom column=course:math, timestamp=1224726377027, value=89 Tom column=grade:, timestamp=1224726360727, value=1 Jerry column=course:english, timestamp=1224726424967, value=90 Jerry column=course:math, timestamp=1224726416145, value=100 Jerry column=grade:, timestamp=1224726404965, value=2 6 row (s) in 0.0410 seconds

View all the data in the scores table, all the data of the courses column family

Hbase (main): 017 scores', 0 > scan 'scores', [' course:'] ROW COLUMN+CELL Tom column=course:english, timestamp=1224726394286, value=97 Tom column=course:math, timestamp=1224726377027, value=89 Jerry column=course:english, timestamp=1224726424967, value=90 Jerry column=course:math, timestamp=1224726416145, value=100 4 row (s) in 0.0200 seconds Thank you for reading this article carefully. I hope the article "sample Analysis of getting started with HBase Sub-projects in hadoop" shared by the editor will be helpful to you. At the same time, I hope you will support it. Pay attention to the industry information channel, more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report