Hadoop cluster (phase 13th) _hbase Common shell commands

Source: Internet
Author: User
Tags compact

Enter hbase shell console
$ HBASE_HOME / bin / hbase shell
If there is kerberos authentication, you need to use the corresponding keytab to perform authentication (using the kinit command). After successful authentication, use the hbase shell to enter. You can use the whoami command to view the current user
hbase (main)> whoami
Table management
1) See what tables are available
hbase (main)> list
2) Create a table

# Syntax: create <table>, {NAME => <family>, VERSIONS => <VERSIONS>} # For example: create table t1, there are two family names: f1, f2, and the number of versions are 2 hbase (main) > create 't1', {NAME => 'f1', VERSIONS => 2}, {NAME => 'f2', VERSIONS => 2}
3) delete the table
In two steps: first disable, then drop
For example: delete table t1

hbase (main)> disable ‘t1‘ hbase (main)> drop ‘t1’
4) View the structure of the table

# Syntax: describe <table> # Example: View the structure of table t1 hbase (main)> describe ‘t1’
5) Modify the table structure
To modify the table structure, you must first disable

# Syntax: alter 't1', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'} # For example: modify the cf of the table test1 to 180 days for cf hbase (main)> disable 'test1' hbase (main)> alter 'test1', {NAME => 'body', TTL => '15552000'}, {NAME => 'meta', TTL => '15552000'} hbase (main)> enable 'test1'
authority management
1) Assign permissions
# Syntax: grant <user> <permissions> <table> <column family> <column qualifier> Parameters are separated by commas. # Permissions are represented by five letters: "RWXCA". # READ ('R'), WRITE ('W '), EXEC (' X '), CREATE (' C '), ADMIN (' A ') # For example, assign the user' test 'read and write permissions on table t1, hbase (main)> grant' test ' , 'RW', 't1'
2) View permissions

# Syntax: user_permission <table> # For example, view the permission list of table t1 hbase (main)> user_permission ‘t1’
3) Withdrawal of authority

# Similar to assigning permissions, syntax: revoke <user> <table> <column family> <column qualifier> # For example, revoke test user permissions on table t1 hbase (main)> revoke ‘test’, ‘t1’
Addition, deletion, modification, and checking of table data
1) Add data
# Syntax: put <table>, <rowkey>, <family: column>, <value>, <timestamp> # For example: add a row to table t1: rowkey is rowkey001, family name: f1, column name: col1, value: value01, timestamp: system default hbase (main)> put 't1', 'rowkey001', 'f1: col1', 'value01' Usage is relatively single.
2) Query data
a) Query a row of records

# Syntax: get <table>, <rowkey>, [<family: column>, ....] # For example: lookup table t1, the value of col1 under f1 in rowkey001 hbase (main)> get 't1', 'rowkey001', 'f1: col1' # Or: hbase (main)> get 't1', 'rowkey001', {COLUMN => 'f1: col1'} # Query all column values under f1 in table t1, rowke002 hbase (main)> get 't1', 'rowkey001'
b) scan table

# Syntax: scan <table>, {COLUMNS => [<family: column>, ....], LIMIT => num} # In addition, you can add advanced functions such as STARTROW, TIMERANGE, and FITLER # For example: scan table t1 The first 5 pieces of data hbase (main)> scan 't1', {LIMIT => 5}
c) the number of data rows in the query table

# Syntax: count <table>, {INTERVAL => intervalNum, CACHE => cacheNum} # INTERVAL sets the number of rows to be displayed once and the corresponding rowkey, the default is 1000; the size of the cache area that CACHE fetches each time, the default is 10. Parameter can increase the query speed # For example, the number of rows in the query table t1 is displayed every 100, and the cache area is 500 hbase (main)> count 't1', {INTERVAL => 100, CACHE => 500}
3) Delete data
a) Delete a column value in a row

# Syntax: delete <table>, <rowkey>, <family: column>, <timestamp>, must specify the column name # For example: delete the data of table t1, f1: col1 in rowkey001 hbase (main)> delete 't1' , 'rowkey001', 'f1: col1'
Note: all versions of the f1: col1 column will be deleted.
b) delete line

# Syntax: deleteall <table>, <rowkey>, <family: column>, <timestamp>, you can delete the entire row of data without specifying the column name # For example: delete the data of table t1, rowk001 hbase (main)> deleteall 't1 ',' rowkey001 '
c) delete all data in the table

# Syntax: truncate <table> # The specific process is: disable table-> drop table-> create table # For example: delete all data of table t1 hbase (main)> truncate ‘t1’
Region management
1) Mobile region
# Syntax: move 'encodeRegionName', 'ServerName' # encodeRegionName refers to the encoding after regioName, ServerName refers to the list of Region-servers for master-status # Example hbase (main)> move '4343995a58be8e5bbc739af1e91cd72d', 'db-41.xxx. xxx.org, 60020,1390274516739 '
2) Turn on / off the 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 'r1', ' c1 '#Compact a single column family within a table: #hbase> major_compact' t1 ',' c1 '
Configuration management and node restart
1) Modify the hdfs configuration
hdfs configuration location: / etc / hadoop / conf
# Sync hdfs configuration cat / home / hadoop / slaves | xargs -i -t scp /etc/hadoop/conf/hdfs-site.xml [email protected] {}: / etc / hadoop / conf / hdfs-site.xml # Close: cat / home / hadoop / slaves | xargs -i -t ssh [email protected] {} "sudo /home/hadoop/cdh4/hadoop-2.0.0-cdh4.2.1/sbin/hadoop-daemon.sh- config / etc / hadoop / conf stop datanode "#Start: cat / home / hadoop / slaves | xargs -i -t ssh [email protected] {}" sudo /home/hadoop/cdh4/hadoop-2.0.0-cdh4. 2.1 / sbin / hadoop-daemon.sh --config / etc / hadoop / conf start datanode "
2) Modify hbase configuration
hbase configuration location:

# Sync hbase configuration cat / home / hadoop / hbase / conf / regionservers | xargs -i -t scp /home/hadoop/hbase/conf/hbase-site.xml [email protected] {}: / home / hadoop / hbase / conf / hbase-site.xml # graceful restart cd ~ / hbase bin / graceful_stop.sh --restart --reload --debug inspurXXX.xxx.xxx.org
Hadoop Cluster (Issue 13) _HBase Common Shell Commands

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.