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

What are the common commands in Hbase shell

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what Hbase shell commands are commonly used, the article is very detailed, has a certain reference value, interested friends must read it!

I listed several commonly used HBase Shell commands, 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.

I. General operation

1. Query server status

Hbase (main): 024pur0 > status

3 servers, 0 dead,1.0000 average load

two。 Query hive version

Hbase (main): 025 0 > version

0.90.4, r1150278,Sun Jul 24 15:53:29 PDT 2011

II. DDL operation

1. Create a table

Hbase (main): 011 create 0 > member','member_id','address','info'

0 row (s) in 1.2210seconds

two。 Get a description of the table

Hbase (main): 012 0 > list

TABLE

Member

1 row (s) in 0.0160seconds

Hbase (main): 006 describe 0 > member'

DESCRIPTION ENABLED

{NAME= > 'member', FAMILIES = > [{NAME= >' address', BLOOMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm, true

VERSIONS = > '3Qing, COMPRESSION = >' NONE',TTL = > '21474836474th, BLOCKSIZE = >' 655366', IN_MEMORY = >'fa

Lse', BLOCKCACHE = > 'true'}, {NAME = >' info', BLOOMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm, VERSI

ONS = > '319, COMPRESSION = >' NONE', TTL= > '2147483647, BLOCKSIZE = >' 65536, IN_MEMORY = > 'false'

BLOCKCACHE = > 'true'}]}

1 row (s) in 0.0230seconds

3. Delete a column family, alter,disable,enable

We have built three column families before, but we found that the column family member_id is redundant, because it is the primary key, so we have to delete it.

Hbase (main): 003member', 0 > alter 'member', {NAME= >' member_id',METHOD= > 'delete'}

ERROR: Table memberis enabled. Disable it first before altering.

An error is reported. When deleting a column family, you must first drop the table to disable.

Hbase (main): 004disable 0 > member'

0 row (s) in 2.0390seconds

Hbase (main): 005alter'member',NAME= 0 > alter'member',NAME= > 'member_id',METHOD= >' delete'

0 row (s) in 0.0560seconds

Hbase (main): 006 describe 0 > member'

DESCRIPTION ENABLED

{NAME= > 'member', FAMILIES = > [{NAME= >' address', BLOOMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm

VERSIONS = > '3Qing, COMPRESSION = >' NONE',TTL = > '21474836474th, BLOCKSIZE = >' 655366', IN_MEMORY = >'fa

Lse', BLOCKCACHE = > 'true'}, {NAME = >' info', BLOOMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm, VERSI

ONS = > '319, COMPRESSION = >' NONE', TTL= > '2147483647, BLOCKSIZE = >' 65536, IN_MEMORY = > 'false'

BLOCKCACHE = > 'true'}]}

1 row (s) in 0.0230seconds

The column family has been deleted, so we continue to change the table enable

Hbase (main): 008 enable 0 > member'

0 row (s) in 2.0420seconds

4. List all the tables

Hbase (main): 028 0 > list

TABLE

Member

Temp_table

2 row (s) in 0.0150seconds

5.drop a table

Hbase (main): 029 disable 0 > temp_table'

0 row (s) in 2.0590seconds

Hbase (main): 030 drop 0 > temp_table'

0 row (s) in 1.1070seconds

6. Query whether the table exists

Hbase (main): 021 exists 0 > member'

Table member doesexist

0 row (s) in 0.1610seconds

7. Determine whether the table is enable

Hbase (main): 034Rank 0 > is_enabled 'member'

True

0 row (s) in 0.0110seconds

8. Determine whether the table is disable

Hbase (main): 032 is_disabled 0 > member'

False

0 row (s) in 0.0110seconds

3. DML operation

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'

Put'member','xiaofeng','info:birthday','1987-4-17'

Put'member','xiaofeng','info:favorite','movie'

Put'member','xiaofeng','info:company','alibaba'

Put'member','xiaofeng','address:contry','china'

Put'member','xiaofeng','address:province','guangdong'

Put'member','xiaofeng','address:city','jieyang'

Put'member','xiaofeng','address:town','xianqiao'

two。 Get a piece of data

Get all the data of an id

Hbase (main): 001get 0 > member','scutshuxue'

COLUMN CELL

Address:city timestamp=1321586240244, value=hangzhou

Address:contry timestamp=1321586239126, value=china

Address:province timestamp=1321586239197, value=zhejiang

Info:age timestamp=1321586238965, value=24

Info:birthday timestamp=1321586239015, value=1987-06-17

Info:company timestamp=1321586239071, value=alibaba

6 row (s) in 0.4720seconds

Get an id, all the data of a column family

Hbase (main): 002 get 0 > member','scutshuxue','info'

COLUMN CELL

Info:age timestamp=1321586238965, value=24

Info:birthday timestamp=1321586239015, value=1987-06-17

Info:company timestamp=1321586239071, value=alibaba

3 row (s) in 0.0210seconds

Get an id, all the data of a column in a column family

Hbase (main): 002 get 0 > member','scutshuxue','info:age'

COLUMN CELL

Info:age timestamp=1321586238965, value=24

1 row (s) in 0.0320seconds

6. Update a record

Change the age of scutshuxue to 99

Hbase (main): 004 0 > put 'member','scutshuxue','info:age',' 99'

0 row (s) in 0.0210seconds

Hbase (main): 005hbase 0 > get 'member','scutshuxue','info:age'

COLUMN CELL

Info:age timestamp=1321586571843, value=99

1 row (s) in 0.0180seconds

3. Get two versions of data through timestamp

Hbase (main): 010 member','scutshuxue', 0 > get 'member','scutshuxue', {COLUMN= >' info:age',TIMESTAMP= > 1321586238965}

COLUMN CELL

Info:age timestamp=1321586238965, value=24

1 row (s) in 0.0140seconds

Hbase (main): 011 member','scutshuxue', 0 > get 'member','scutshuxue', {COLUMN= >' info:age',TIMESTAMP= > 1321586571843}

COLUMN CELL

Info:age timestamp=1321586571843, value=99

1 row (s) in 0.0180seconds

4. Full table scan:

Hbase (main): 013 scan 0 > member'

ROW COLUMN+CELL

Scutshuxue column=address:city, timestamp=1321586240244, value=hangzhou

Scutshuxue column=address:contry, timestamp=1321586239126, value=china

Scutshuxue column=address:province, timestamp=1321586239197, value=zhejiang

Scutshuxue column=info:age,timestamp=1321586571843, value=99

Scutshuxue column=info:birthday, timestamp=1321586239015, value=1987-06-17

Scutshuxue column=info:company, timestamp=1321586239071, value=alibaba

Temp column=info:age, timestamp=1321589609775, value=59

Xiaofeng column=address:city, timestamp=1321586248400, value=jieyang

Xiaofeng column=address:contry, timestamp=1321586248316, value=china

Xiaofeng column=address:province, timestamp=1321586248355, value=guangdong

Xiaofeng column=address:town, timestamp=1321586249564, value=xianqiao

Xiaofeng column=info:birthday, timestamp=1321586248202, value=1987-4-17

Xiaofeng column=info:company, timestamp=1321586248277, value=alibaba

Xiaofeng column=info:favorite, timestamp=1321586248241, value=movie

3 row (s) in 0.0570seconds

5. Delete the 'info:age' field of the value whose id is temp

Hbase (main): 016 delete 0 > member','temp','info:age'

0 row (s) in 0.0150seconds

Hbase (main): 018 get 0 > member','temp'

COLUMN CELL

0 row (s) in 0.0150seconds

6. Delete the entire row

Hbase (main): 001deleteall 0 > member','xiaofeng'

0 row (s) in 0.3990seconds

7. Query how many rows there are in the table:

Hbase (main): 019 count 0 > member'

2 row (s) in 0.0160seconds

8. Add the info:age' field to the 'xiaofeng' this id' and use counter to implement the increment

Hbase (main): 057:0*incr 'member','xiaofeng','info:age'

COUNTER VALUE = 1

Hbase (main): 058 get 0 > member','xiaofeng','info:age'

COLUMN CELL

Info:age timestamp=1321590997648, value=\ X00\ x00\ x01

1 row (s) in 0.0140seconds

Hbase (main): 059 incr 0 > member','xiaofeng','info:age'

COUNTER VALUE = 2

Hbase (main): 060 get 0 > member','xiaofeng','info:age'

COLUMN CELL

Info:age timestamp=1321591025110, value=\ x00\ x02

1 row (s) in 0.0160seconds

Gets the value of the current count

Hbase (main): 069 get_counter 0 > member','xiaofeng','info:age'

COUNTER VALUE = 2

9. Empty the entire table:

Hbase (main): 035 truncate 0 > member'

Truncating 'member'table (it may take a while):

-Disabling table...

-Dropping table...

-Creating table...

0 row (s) in 4.3430seconds

As you can see, hbase first drops the disable, and then drop drops and rebuilds the table to achieve the function of truncate.

These are all the contents of this article entitled "what are the Common commands in Hbase shell?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Internet Technology

Wechat

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

12
Report