Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the common Shell operations in HBase

Shulou Source: shulou.com Published: 2022-05-31 21:25:43 10月02日 Update

This article will explain in detail what Shell operations are commonly used in HBase. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

HBase provides a Shell terminal for users to interoperate, and help information can be obtained through the "help get" command.

[query related]

1. Enter hbase shell console

$HBASE_HOME/bin/hbase shell

two。 Check which tables are available

List

3. View full table data

Scan 'tablename'

View LIMIT data

Scan 'tablename', {LIMIT= > 10}

4. View table description

Describe 'table'

5. View statu

Hbase (main): 004VR 0 > status

30 servers, 0 dead, 242.7000 average load

6. Get a single-line value

Get 'tablename',' rowkey' (notice a comma)

Gets the value of a column cluster in a single row:

Get 'tablename','rowkey','family'

Gets the value of a column in a column cluster in a single row:

Get 'tablename','rowkey','family:column'

Get two versions of the data through timestamp:

Get 'tablename',' rowkey', {COLUMN= > 'family:column',TIMESTAMP= > 1321586238965}

Query a single record through the prefix of rowKey:

Scan 'YK.VVCOUNT_VID_LIST', {FILTER= > "PrefixFilter ('-1001808375')"}

Results:-1001808375199894794 column=v:vids, timestamp=1457892147304, value=199503532,199503519

7. View the total number of records in the table

Count 'tablename'

8. Determine whether the table is disable

Is_disabled 'tablename'

9. Determine whether the table is enable

Is_enabled 'tablename'

10. Determine whether the table exists or not

Exists' tablename'

11. Get the current count

[add / create]

1. Create a tabl

(1) the simplest

Create 'TD.VVCOUNT_PLAYLIST_VV', {NAME = >' v'}

(2) data expires in 7 days

Create 'TD.VVCOUNT_DAY_PLAYLIST_VV', {NAME = >' true', BLOOMFILTER = > 'ROWCOL', COMPRESSION = >' SNAPPY', TTL = > '604800', BLOCKSIZE = > '32768', METADATA = > {'ENCODE_ON_DISK' = >' true'}}

Simplified version:

Create 'YK.VVCOUNT_VIDEO_REAL_VV', {NAME = >' vested, TTL = > '604800'}

(3) contains multiple column families

Create 'user','v','f'

two。 Insert data

Put 'testtable',' myrow-1', 'colfaml:q1',' value-1'

Put 'testtable',' myrow-2', 'colfaml:q2',' value-2'

Put 'testtable',' myrow-2', 'colfaml:q3',' value-3'

You can see that there are two line keys myrow-1 and myrow-2, so there are two lines. Colfaml is the column cluster name, and Q1, Q2, Q3 is the column name

[modify]

1. Update a record

Put "member','scutshuxue','info:age',"

[delete]

1. Drop table

Disable 'tablename'

Drop 'tablename'

two。 Empty the whole table

Truncate 'tablename'

3. Delete the entire row

Deleteall 'tablename','rowkey'

4. Delete a column cluster

Disable the table first (if there is data in the table before, it will empty the data.

Disbale 'tablename'

Is_enabled 'tablename'

Alter 'tablename', {NAME= >' mechod > 'delete'}

Enable 'tablename'

5. Delete a column in a row

Delete 'testtable',' myrow-2', 'colfaml:q2'

[management related]

1. Region management

(1) Mobile Region

# syntax: move 'encodeRegionName',' ServerName'

# encodeRegionName refers to the coding after regioName, and ServerName refers to the Region Servers list of master-status

# exampl

Hbase (main) > move '4343995a58be8e5bbc739af1e91cd72dbath,' db-41.xxx.xxx.org,60020,1390274516739'

(2) enable / disable Region

# Syntax: balance_switch true | false

Hbase (main) > balance_switch

(3) Manual split

# syntax: split 'regionName',' splitKey'

(4) manually trigger major compaction

# Syntax:

# Compact all regions in a table:

# hbase > major_compact 't1'

# Compact an entire region:

# hbase > major_compact 'r1'

# Compact a single column family within a region:

# hbase > major_compact 'r1regions, 'c1'

# Compact a single column family within a table:

# hbase > major_compact 't1percent, 'c1'

two。 Authority management

(1) View permissions

# Syntax: user_permission

# for example, view the permission list of table T1

Hbase (main) > user_permission 't1'

(2) assign permissions

# Syntax: grant parameters are separated by commas

# permissions are denoted by five letters: "RWXCA".

# READ ('R'), WRITE ('W'), EXEC ('X'), CREATE ('C'), ADMIN ('A')

# for example, assign user 'test' access to read and write to table T1

Hbase (main) > grant 'test','RW','t1'

(3) recall permission

# similar to assigning permissions, syntax: revoke

# for example, revoke the permissions of the test user on table T1

Hbase (main) > revoke 'test','t1'

This is the end of this article on "what are the common Shell operations in HBase?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Permissions data syntax users articles assignment management commonly used two name manual more comma help query good practical information content prefix Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS MySQL Microsoft OPPO Reno