Use HBase and Hbase use help
1) into HBase
#使用命令进入HBase Shell $ hbase shell The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added. For more on the HBase Shell, see http://hbase.apache.org/book.html hbase(main):003:0>
2) using HBase help
HBase provides a lot of help files, just use the command help in HBase HBase will be able to view the help of all keywords
hbase(main):003:0> help HBase Shell, version 1.1.3, r72bc50f5fafeb105b2139e42bbee3d61ca724989, Sat Jan 16 18:29:00 PST 2016 Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command. Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group. COMMAND GROUPS: Group name: general Commands: status, table_help, version, whoami Group name: ddl Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, show_filters Group name: namespace Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables Group name: dml Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve ...
If you do not know how to use a keyword, then only need to be built directly into the keyword in Hbase:
hbase(main):004:0> put ERROR: wrong number of arguments (0 for 4) Here is some help for this command: Put a cell 'value' at specified table/row/column and optionally timestamp coordinates. To put a cell value into table 'ns1:t1' or 't1' at row 'r1' under column 'c1' marked with the time 'ts1', do: hbase> put 'ns1:t1', 'r1', 'c1', 'value' hbase> put 't1', 'r1', 'c1', 'value' hbase> put 't1', 'r1', 'c1', 'value', ts1 hbase> put 't1', 'r1', 'c1', 'value', {ATTRIBUTES=>{'mykey'=>'myvalue'}} hbase> put 't1', 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}} hbase> put 't1', 'r1', 'c1', 'value', ts1, {VISIBILITY=>'PRIVATE|SECRET'} The same commands also can be run on a table reference. Suppose you had a reference t to table 't1', the corresponding command would be: hbase> t.put 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
In HBase, if you enter the wrong content, use the Backspace key is no good, you must use the Ctrl + Backspace key job.
3), create tables, insert data, query data
Enter hbase shell Console $ HBASE_HOME / bin / hbase shell if kerberos authentication is required in advance with the corresponding keytab conduct some authentication (using the kinit command), then use hbase shell after successful authentication enter can use the whoami command to view the current user hbase (main )> whoami management table 1) to see which tables HBase (main)> List 2) create the table # syntax: Create <table>, {NAME => <Family>, the VERSIONS => <the VERSIONS>} # example: Create table t1, there are two family name: f1, f2, and version number are 2 HBase (main)> Create 'T1', {nAME => 'F1', the vERSIONS => 2}, {nAME => 'F2', = the VERSIONS> 2} . 3) delete the table in two steps: first, disable, and then drop , for example: deleting the table T1 HBase (main)> disable 'T1' HBase (main)> drop 'T1' structure 4) See table # syntax: describe <table> # For example: See table t1 structure hbase (main)> describe 't1 ' 5) to modify the table structure Modified table structure must disable # Syntax: ALTER 'T1', {NAME => 'F1'}, {NAME => 'F2', the METHOD => 'Delete'} # example: modify a table test1 of cf the TTL 180 days HBase (main)> disable 'test1' HBase (main)> ALTER 'test1', {NAME => 'body', the TTL => '15.552 million'}, {NAME => 'Meta', the TTL => '15.552 million' } HBase (main)> enable 'test1' rights management 1) assigned permissions # syntax: grant <user> <permissions> <table> <column family> <column qualifier> with a comma after the parameter represented by five letters # permissions: "RWXCA." # the READ ( 'R & lt'), the WRITE ( 'W is'), EXEC ( 'X-'), the CREATE ( 'C'), the ADMIN ( 'A') # for example, to a user 'test'Have read and write permissions assigned to the table T1, HBase (main)> Grant 'Test', 'RW', 'T1' 2) View permissions # Syntax: user_permission <Table> . 3) to recover competence # For example, to view the list of permissions tables t1 hbase (main)> user_permission 't1 ' similar # and assigned permissions syntax: REVOKE <User> <Table> <column Family> <column qualifier on> # For example, to recover the test user table permissions on T1 HBase (main)> REVOKE 'test', 't1' deletions table data change search 1) add data # syntax: PUT <table>, <RowKey>, <Family: column>, <value>, <timestamp> # example: added to the table t1 a row: rowkey is rowkey001, family name: f1, column name: col1, value: value01, timestamp: default hbase (main)> put 't1 ', 'rowkey001', 'f1: col1', 'value01' Comparative usage single. 2) query data a) a query rows # Syntax: GET <Table>, <RowKey>, [<Family: column>, ....] # for example: a lookup table t1, col1 under rowkey001 value of f1 hbase (main)> HBase (main)> GET 'T1', 'rowkey001', {the COLUMN => 'F1: col1'} # syntax: delete <table>, <rowkey>, <family: column>, <timestamp>, column name must be specified HBase (main)> GET 'T1', 'rowkey001' B) scan table # Syntax: Scan <Table>, {the COLUMNS => [<Family: column>, ....], the LIMIT => NUM} # Further, may also be added STARTROW, TIMERANGE and FITLER advanced features such as # example: the first 5 data of the scan table t1 hbase (main)> scan 't1 ', {LIMIT => 5} rows c) a lookup table number # syntax: COUNT <Table>, {the INTERVAL => intervalNum, the cACHE => cacheNum} # set the INTERVAL how many lines and a corresponding display RowKey default 1000; cACHE each fetch buffer area size, default is 10, the parameter adjustment can be improved query speed # e.g., query the number of rows in table t1, the display every 100, the buffer area is 500 HBase (main)> COUNT 't1', {the INTERVAL => 100, the cACHE => 500} . 3) delete the data a) delete rows of a column value b) Delete Row # Example: drop table t1, rowkey001 in f1: col1 data hbase (main)> delete 't1 ', 'rowkey001', 'f1: col1' Note: will delete diverted f1: col1 column for all versions of the data # exemplary # Syntax: deleteall <table>, <rowkey >, <family: column>, <timestamp>, may not specify the column name, delete the entire row of data # example: delete tables t1, rowk001 data hbase (main)> deleteall 't1 ',' rowkey001 ' C) deleting all the data in the table # syntax: TRUNCATE <table> # the specific process is: disable table -> drop table -> Create table # example: deleting the table t1 all data hbase (main)> TRUNCATE 'T1' Region Manager . 1) Region # syntax: move 'encodeRegionName', 'ServerName' # encodeRegionName means behind regioName coding, ServerName refers to a master-status of Region Servers list # syntax: balance_switch to true | false HBase (main)> balance_switch hbase(main)>move '4343995a58be8e5bbc739af1e91cd72d', 'db-41.xxx.xxx.org,60020,1390274516739' 2)开启/关闭region # Configuration Synchronization hdfs 3) Manual Split # Syntax: Split 'regionName', 'splitKey' . 4) manual trigger compaction Major # Syntax: #Compact All Regions in Table A: #hbase> major_compact 'T1' #Compact AN Entire Region: #hbase> major_compact ' R1 ' #Compact column Family WITHIN A SINGLE Region A: #hbase> major_compact' R1 ',' C1 ' #Compact WITHIN A SINGLE column Family Table A: #hbase> major_compact' T1 ',' C1 ' configuration management and node restart 1 ) modify hdfs arranged hdfs arrangement positions: / etc / Hadoop / the conf CAT / Home / Hadoop / slaves | xargs -i -t SCP /etc/hadoop/conf/hdfs-site.xml Hadoop} {@: / etc / Hadoop / conf / HDFS-the site.xml # off: cat /home/hadoop/slaves|xargs -i -t ssh hadoop@{} "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 hadoop@{} "sudo /home/hadoop/cdh4/hadoop-2.0.0-cdh4.2.1/sbin/hadoop-daemon.sh --config /etc/hadoop/conf start datanode" 2)修改hbase配置 hbase配置位置: # 同步hbase配置 cat /home/hadoop/hbase/conf/regionservers|xargs -i -t scp /home/hadoop/hbase/conf/hbase-site.xml hadoop@{}:/home/hadoop/hbase/conf/hbase-site.xml # graceful重启 cd ~/hbase bin/graceful_stop.sh --restart --reload --debug inspurXXX.xxx.xxx.org