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 HBase shell commands?

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

Share

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

This article will explain in detail what the commonly used HBase shell commands are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

One: HBase

1. Check whether hbase is running properly before using the hbase command, and check the process through JPS

Hadoop@master:/mysoftware/hbase-1.2.1/bin$ jps4051 HQuorumPeer3776 QuorumPeerMain2818 NameNode4149 HMaster3140 SecondaryNameNode2966 DataNode4549 Jps4304 HRegionServer3365 ResourceManager

two。 Enter the HBase shell client

Hadoop@master:/mysoftware/hbase-1.2.1$ bin/hbase shell

II: Overview of HBase basic commands

Some basic operation commands of HBase Shell, and several commonly used HBase Shell commands are listed as follows:

Name command expression create table create 'table name', 'column name 1' column name 'column name 2' column name N' add record put 'table name', 'row name', 'column name: xxx',' value 'view record get' table name', 'row name' view total records in the table count 'table name' delete record delete 'table name', 'row name' Column name to delete a table, you have to mask the table. To delete the table, first step disable 'table name' second step drop 'table name' view all records scan "table name" view all data in a table column scan "table name", ['column name:'] to update the record is to rewrite and overwrite

Three: the basic HBase command is practical, the following steps

Four:. General operation

1. Query server status: status

Hbase (main): 002backup masters 0 > status1 active master, 0 backup masters, 1 servers, 0 dead, 3.0000 average load

two。 Query Hbase version: version

Hbase (main): 003VR 0 > vesionNameError: undefined local variable or method `vesion' for #

Five: DDL operation

1. Create a table userinfo: create 'userinfo','name','age'

Hbase (main): 011 in 0 > create 'userinfo','name','age'0 row (s) in 1.3220 seconds= > Hbase::Table-userinfo

two。 List all tables: list

Hbase (main): 013pur0 > listTABLE table1 Userinfo 2 row (s) in 0.0230 seconds= > ["table1" "userinfo"]

3. Get a description of the table: describe

Hbase (main): 014 describe 0 > userinfo'Table userinfo is ENABLED userinfo COLUMN FAMILIES DESCRIPTION {NAME = > 'age' DATA_BLOCK_ENCODING = > 'NONE', BLOOMFILTER = >' ROW', REPLICATION_SCOPE = > '0mm, VERSIONS = >' 1mm, COMPRESSION = > 'NONE', MIN_VERSIONS = >' 0mm, TTL = > 'FOREVER', KEEP_DELETED_CELLS = >' FALSE', BLOCKSIZE = > '65536', IN_MEMORY = >' false' BLOCKCACHE = > 'true'} {NAME = >' name', DATA_BLOCK_ENCODING = > 'NONE', BLOOMFILTER = >' ROW', REPLICATION_SCOPE = > '013', VERSIONS = > '1mm, COMPRESSION = >' NONE', MIN_VERSIONS = > '0mm, TTL = >' FOREVER', KEEP_DELETED_CELLS = > 'FALSE', BLOCKSIZE = >' 65536' IN_MEMORY = > 'false', BLOCKCACHE = >' true'} 2 row (s) in 0.0430 seconds

4. Check if the table exists: exists

Hbase (main): 017table2'Table table2 does not exist 0 > exists' table2'Table table2 does not exist 0 row (s) in 0.0210 seconds

5. Determine whether the table is: 'enable'

Hbase (main): 018 is_enabled 0 > userinfo'true

6. Determine whether the table is: 'disable'

Hbase (main): 019 is_disabled 0 > userinfo'false

7. Delete a column family disable alter enable

Hbase (main): 003table1'0 row 0 > disable 'table1'0 row (s) in 0.0230 secondshbase (main): 004table1'0 row 0 > alter 'table1', {NAME = >' t2', METHOD = > 'delete'} Updating all regions with the new schema...1/1 regions updated.Done.0 row (s) in 2.2240 secondshbase (main): 005table1'0 row 0 > enable' table1'0 row (s) in 1.2990 seconds

Then check to see if the column is deleted, by getting a description of the table, as follows: only the following'T1'is left.

Hbase (main): 006 describe 0 > table1'Table table1 is ENABLED table1 COLUMN FAMILIES DESCRIPTION {NAME = > 't1' DATA_BLOCK_ENCODING = > 'NONE', BLOOMFILTER = >' ROW', REPLICATION_SCOPE = > '0mm, VERSIONS = >' 1mm, COMPRESSION = > 'NONE', MIN_VERSIONS = >' 0mm, TTL = > 'FOREVER', KEEP_DELETED_CELLS = >' FALSE', BLOCKSIZE = > '65536', IN_MEMORY = >' false' BLOCKCACHE = > 'true'} 1 row (s) in 0.0290 seconds

8. Delete a table: drop. Before deleting a table, you need to mask the table.

Hbase (main): 007table1'0 row 0 > disable 'table1'0 row (s) in 2.2910 secondshbase (main): 008table1'0 row 0 > drop' table1'0 row (s) in 1.3030 seconds

Six: DML operation

1. Insert several records into userinfo: put 'table name', 'row name', 'column family name: xxx','value'

Hbase (main): 016main 0 > put 'userinfo','row1','name:col1','Berg'0 row (s) in 0.0870 secondshbase (main): 017userinfo','row1','name:col1','Berg'0 row 0 > put 'userinfo','row1','age:col2','22'0 row (s) in 0.0180 secondshbase (main): 018main 0 > put' userinfo','row2','name:col1','hadoophbase'0 row (s) in 0.0190 secondshbase (main): 019userinfo','row1','name:col1','Berg'0 row 0 > put 'userinfo','row2','age:col2' '20 row (s) in 0.0180 seconds

two。 Full table scan: scan

Hbase (main): 001scan 0 > userinfo'ROW COLUMN+CELL row1 column=age:col2, timestamp=1463066528653, value=22 row1 column=name:col1, timestamp=1463066505217 Value=Berg row2 column=age:col2, timestamp=1463066598770, value=20 row2 column=name:col1, timestamp=1463066577206, value=hadoophbase

3. To get all the data of a row is to get all the data of a row name.

Hbase (main): 003 userinfo', 0 > get 'userinfo',' row1'COLUMN CELL age:col2 timestamp=1463066528653 Value=22 name:col1 timestamp=1463066505217, value=Berg

4. Get all the data for a row, a column family, a column

Hbase (main): 004userinfo','row1','name:col1'COLUMN CELL name:col1 timestamp=1463066505217 0 > get 'userinfo','row1','name:col1'COLUMN CELL name:col1 timestamp=1463066505217, value=Berg 1 row (s) in 0.0190 seconds

5. Update a record: put (the value of name:col1 is changed to: BergBergBerg)

Hbase (main): 009 userinfo','row2','name:col1','BergBergBerg'0 row 0 > put 'userinfo','row2','name:col1','BergBergBerg'0 row (s) in 0.0720 seconds

Get the updated value:

Hbase (main): 011userinfo','row2','name:col1'COLUMN CELL name:col1 timestamp=1463067259346 0 > get 'userinfo','row2','name:col1'COLUMN CELL name:col1 timestamp=1463067259346, value=BergBergBerg 1 row (s) in 0.0280 seconds

6. Query how many rows are in the table: count

Hbase (main): 012userinfo'2 row 0 > count 'userinfo'2 row (s) in 0.0450 seconds= > 2

7. Delete the value of a row and a column family: delete

Hbase (main): 023userinfo','row2','age:col2'0 row 0 > delete 'userinfo','row2','age:col2'0 row (s) in 0.0140 secondshbase (main): 024userinfo','row2','age:col2'0 row 0 > scan' userinfo'ROW COLUMN+CELL row1 column=age:col2, timestamp=1463066528653 Value=22 row1 column=name:col1, timestamp=1463066505217, value=Berg row2 column=name:col1, timestamp=1463067259346, value=BergBergBerg 2 row (s) in 0.0300 seconds

8. Delete the value of the entire row: deleteall

Hbase (main): 026userinfo','row2'0 row 0 > deleteall 'userinfo','row2'0 row (s) in 0.0190 secondshbase (main): 027userinfo','row2'0 row 0 > scan' userinfo'ROW COLUMN+CELL row1 column=age:col2, timestamp=1463066528653 Value=22 row1 column=name:col1, timestamp=1463066505217, value=Berg 1 row (s) in 0.0320 seconds

9. Give the age column to row1 and increment it with counter: incr (well, it's a little weird when you do it here, for no other reason, the column family name doesn't get good. )

Hbase (main): 024in 0 > incr 'userinfo','row1','age:id'COUNTER VALUE = 10 row (s) in 0.0170 secondshbase (main): 025 in 0 > incr' userinfo','row1','age:id'COUNTER VALUE = 20 row (s) in 0.0210 secondshbase (main): 026 in 0 > incr 'userinfo','row1','age:id'COUNTER VALUE = 30 row (s) in 0.1270 seconds

Gets the value of the current counter:

Hbase (main): 027main 0 > get_get_auths get_counter get_splits get_tablehbase (main): 027get_get_auths get_counter get_splits get_tablehbase 0 > get_counter 'userinfo','row1','age:id'COUNTER VALUE = 3

10. Empty the entire table: truncate

Hbase (main): 028 userinfo'Truncating 0 > truncate 'userinfo'Truncating' userinfo' table (it may take a while):-Disabling table... -Truncating table...0 row (s) in 4.3360 secondshbase (main): 029main 0 > scan 'userinfo'ROW COLUMN+CELL 0 row (s) in 0.3490 seconds about "what are the common HBase shell commands?" Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

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