Hbase Common shell commands

Source: Internet
Author: User
Tags compact

Enter HBASE Shell Console$hbase_home/bin/HBase Shell If you have Kerberos authentication, you need to use the appropriate keytab for authentication (using the Kinit command), and then use the HBase shell to enter the certificate successfully. You can use the WhoAmI command to view the current user hbase ( Main)>Management of WhoAmI tables1) See what Table HBase (main)>List2) CREATE TABLE # syntax: create<table> {NAME = <family>, VERSIONS = <VERSIONS>}# For example: CREATE table T1 with two family name:f1,f2 and version number 2hbase (main)> Create'T1', {NAME ='F1', VERSIONS =2},{name ='F2', VERSIONS =2}3Delete a table in two steps: First disable, then drop for example: Delete Table t1hbase (main)> Disable'T1'hbase (Main)> Drop'T1'4) View the structure of the table # syntax: Describe<table># Example: View the structure of the table T1 HBase (main)> Describe'T1'5Modify the table structure to modify the table structure must first disable# syntax: Alter'T1', {NAME ='F1'}, {NAME ='F2', METHOD ='Delete'}# For example: Modify Table test1 The TTL of CF is 180 days hbase (main)> Disable'test1'hbase (Main)> Alter'test1',{name=>'Body',ttl=>'15552000'},{name=>'Meta', ttl=>'15552000'}hbase (Main)> Enable'test1'Rights Management1) Assign permissions # syntax: Grant<user> <permissions> <table> <column family> <column qualifier>The parameter is followed by a comma-delimited # permission denoted by five letters:"Rwxca". # READ ('R'), WRITE ('W'), EXEC ('X'), CREATE ('C'), ADMIN ('A') # For example, give the user ' test'assign permissions to read and write to the table T1HBase (main) > Grant'Test','RW','T1'2) View Permissions # syntax: User_permission<table># For example, view the list of permissions for the table T1 hbase (main)> user_permission'T1'3) Revoke permissions # similar to assigning permissions, syntax: Revoke<user> <table> <column family> <column qualifier># For example, retract the test user's permissions on table T1 hbase (main)> Revoke'Test','T1'table Data Deletion and modification1Add Data # syntax: Put<table>,<rowkey>,<family:column>,<value>,<timestamp># 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. 2query data A) query a line record # syntax:Get<table>,<rowkey>,[<family:column>,....] # example: Query the value of col1 under F1 in table t1,rowkey001 hbase (main)>Get 'T1','rowkey001','F1:col1'# or: HBase (main)>Get 'T1','rowkey001', {column=>'F1:col1'}# All column values under F1 in the query table t1,rowke002 hbase (main)>Get 'T1','rowkey001'b) Scan table # Syntax: scan<table>, {COLUMNS = [<family:column>,....], LIMIT =num}# Plus, you can add advanced features such as StartRow, Timerange, and Fitler # for example: first 5 data hbase (main) of the scan table T1> Scan'T1',{limit=>5}c) The number of data rows in the query table # syntax: Count<table> {INTERVAL = Intervalnum, CACHE =cachenum}# interval Set how many lines to display once and corresponding Rowkey, the default 1000;cache each buffer size, the default is 10, adjust this parameter to improve the query speed # For example, query table T1 in the number of rows, every 100 bars, Buffer is 500hbase (main)> Count'T1', {INTERVAL = -, CACHE = -}3Delete Data A) Delete a column value in a row # syntax: Delete<table>, <rowkey>, <family:column>, <timestamp>, you must specify a column name # For example: Delete f1:col1 data in table t1,rowkey001 hbase (main)> Delete'T1','rowkey001','F1:col1'Note: The row f1:col1 column will be deleted all versions of data B) Delete line # syntax: DeleteAll<table>, <rowkey>, <family:column>, <timestamp>, you can delete entire rows of data without specifying a column name # For example: Delete data for table t1,rowk001 hbase (main)> DeleteAll'T1','rowkey001'c) Delete all data in the table # syntax: Truncate<table># Its specific process is: Disable tabledrop tableCreate table# For example: Delete all data for table T1 HBase (main)> Truncate'T1'Region Management1) Move region# syntax: move'Encoderegionname','ServerName'# Encoderegionname refers to the regioname behind the code, servername refers to the master-Status of Region Servers List # example hbase (main)>move'4343995a58be8e5bbc739af1e91cd72d','db-41.xxx.xxx.org,60020,1390274516739'2Openclose region# Syntax: Balance_switchtrue|falsehbase (Main)>Balance_switch3) Manual split# syntax: Split'Regionname','Splitkey'4) manual Trigger major compaction# syntax: #Compact all regionsincha 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 restart1To Modify the HDFs configuration, configure the HDFs configuration location:/etc/hadoop/conf# Synchronous HDFS configuration Cat/home/hadoop/slaves|xargs-i-t scp/etc/hadoop/conf/hdfs-site.xml [email protected]{}:/etc/hadoop/conf/hdfs-site.xml# off: 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 "#启动: 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 "2Modify HBase Configuration hbase Configuration location: # Synchronize 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~/Hbasebin/graceful_stop.sh--restart--reload--debug inspurXXX.xxx.xxx.org

Balance_switch true to turn on load balancing

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.