HBase Common examples of shell commands __hbase

Source: Internet
Author: User

1, hbase shell into the hbase[Hadoop@mdw ~]$ HBase Shell
HBase Shell; Enter ' help<return> ' for list of supported commands.
Type "exit<return>" to leave the HBase Shell
Version 0.94.16, r1557241, Fri 20:10:24 UTC 2014

2, WhoAmI view the current access to HBase usersHBase (main):001:0> WhoAmI Hadoop
3, version view the current hbase versions of informationHBase (main):002:0> version 0.94.16, r1557241, Fri out of ten 20:10:24 UTC 2014
4. Status View current HBase stateHBase (main):003:0> status 2 servers, 0 dead, 1.0000 average load can also be viewed by adding parameters, status ' simple ' to view easy information, status ' summary ' View summary information, status ' detailed ' view details
5. CREATE TABLEHBase (main):007:0> create ' member ', ' member_id ', ' address ', ' info ' 0 row (s) in 1.1590 seconds

6, List view the table in the databaseHBase (main):008:0> list TABLE member 1 row (s) in 0.0280 seconds

7, describe table name to view the information of the table HBase (main):009:0> describe member nameerror:undefined local variable or method ' member ' for #<object:0x453c47> HBase (main):010:0> describe ' member ' DESCRIPTION                                                       &N Bsp                                   &NB Sp                      enabled           &NB Sp                   ' member ', {NAME => ' address ', data_block_encoding => ' NONE ', BLOOMF    true                         &NBSP ;        ilter => ' NONE ', Replication_scope => ' 0 ', versions => ' 3 ', compres     &NBS P                                sion => ' NONE ' , min_versions => ' 0 ', TTL => ' 2147483647 ', Keep_dele                                      ted_cells => ' false ', BLOCKSIZE => ' 65536 ', in _memory => ' false ', E                                      ncode_on_disk => ' true ', Blockcache => ' true '}, {NAME => ' info ', DA   &N Bsp                                  ta_b Lock_encoding => ' None ', Bloomfilter => ' None ', Replication_sco               &NB Sp                      pe => ' 0 ', versions => ' 3 ', COMPRESSION => ' NONE ', MIn_versions =>                                         ' 0 ', TTL => ' 2147483647 ', Keep_deleted_cells => ' false ', BLOCKSIZE                                       &NB Sp;=> ' 65536 ', in_memory => ' false ', Encode_on_disk => ' true ', BLOCKCA                                      che => ' true '}, {NAME => ' member_id ', data_block_encoding => ' NONE '                                     &nbsp, bloomfilter => ' NONE ', Replication_scope => ' 0 ', versions => ' 3 ',                                       COMpression => ' NONE ', min_versions => ' 0 ', TTL => ' 2147483647 ', K                                      eep_deleted_cells => ' false ', block SIZE => ' 65536 ', in_memory => ' F                                      alse ', Encode_on_disk => ' true ', Blockcache => ' true '}   &nbsp ;                                   &NB Sp           1 row (s) in 0.0450 seconds HBase (main):011:0>
8, delete the column family Deleting a column family requires you to disable the table before you report the following error: HBase (main):006:0>  alter ' member ',name=> ' member_id ',method=> ' delete ' ERROR: Org.apache.hadoop.hbase.TableNotDisabledException:org.apache.hadoop.hbase.TableNotDisabledException:member         at org.apache.hadoop.hbase.master.HMaster.checkTableModifiable (hmaster.java:1525)         at org.apache.hadoop.hbase.master.handler.tableeventhandler.<init> ( tableeventhandler.java:72)         at Org.apache.hadoop.hbase.master.handler.tabledeletefamilyhandler.<init> (TableDeleteFamilyHandler.java:41)         at Org.apache.hadoop.hbase.master.HMaster.deleteColumn (hmaster.java:1430)     & nbsp   at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)         at Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)         at Sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingmethodACCESSORIMPL.JAVA:25)         at Java.lang.reflect.Method.invoke (method.java:597)     & nbsp   at Org.apache.hadoop.hbase.ipc.writablerpcengine$server.call (writablerpcengine.java:323)         at Org.apache.hadoop.hbase.ipc.hbaseserver$handler.run (hbaseserver.java:1426)
The correct way to delete a column family: First disable the table: HBase (Main):007:0> disable ' member ' 0 row (s) in 1.1690 seconds
Then delete the column family (note NAME and method to capitalize): HBase (Main):008:0> alter ' member ',name=> ' member_id ',method=> ' delete ' updating All regions with the new schema ... 1/1 regions updated. Done. 0 row (s) in 1.1640 seconds
Delete the column family and then enable the table: HBase (Main):009:0> enable ' member ' 0 row (s) in 1.2250 seconds
Once you see the table information again, you can see that member_id has been deleted hbase (main):010:0> describe ' member ' DESCRIPTION           &NBSP ;                                   &NB Sp                                   &NB Sp                                   &NB Sp                                   &NB Sp                                enabled &NB Sp                                   &NB Sp                 ' member ', {NAME => ' address ', data_block_encoding => ' NONE ', Bloomfilter => ' NONE ', Replication_scope => '     true                                                 &NB Sp       0 ', versions => ' 3 ', COMPRESSION => ' NONE ', min_versions => ' 0 ', TTL => ' 2147483647 ' , Keep_deleted_cells =                             & nbsp                               > ' false ' , BLOCKSIZE => ' 65536 ', in_memory => ' false ', Encode_on_disk => ' true ', Blockcache => ' true '}, {N   &nbsp ;                                   &NB Sp                     ame => ' info ', data_block_encoding => ' N One ', BLOomfilter => ' NONE ', Replication_scope => ' 0 ', versions =>               &NBSP ;                                   &NB Sp           ' 3 ', COMPRESSION => ' NONE ', min_versions => ' 0 ', TTL => ' 2147483647 ', Keep_del Eted_cells => ' false ', Bloc                                                            &nbs P Ksize => ' 65536 ', in_memory => ' false ', Encode_on_disk => ' true ', Blockcache => ' true '}       & nbsp                                   &NB Sp                                   1 R OW (s)In 0.0420 seconds

9, DROP table name Delete tableYou also need to disable the table before you delete the table, otherwise you will be able to create a temporary table (user table) and then delete the user table HBase (main):019:0> create ' user ', ' name ', ' age ' 0 row (s) in 1.0900 seconds
The user table is not disabled, delete directly, and report the following error: HBase (main):020:0> drop ' user ' error:table user is enabled. Disable it. ' Here's some help for this command:drop the named table. Table must the disabled:e.g. "Hbase> drop ' T1 '"
The correct removal method is as follows: First disable the table: HBase (Main):021:0> disable ' user ' 0 row (s) in 1.1660 seconds then delete the table: HBase (Main):022:0> drop ' user ' 0 row (s) in 1.0710 seconds HBase (main):023:0>
10, exists table name to see if a table existsHBase (main):023:0> exists ' user ' Table user does not exist 0 row (s) in 0.0230 seconds
HBase (main):024:0> exists ' member ' Table member does exist 0 row (s) in 0.0750 seconds
11, is_enabled Determine whether the table to enableHBase (Main):025:0> is_enabled ' member ' true 0 row (s) in 0.0160 seconds
12, is_disabled judge whether the table disableHBase (Main):026:0> is_disabled ' member ' false 0 row (s) in 0.0220 seconds
13, put insert dataHBase (main):076:0> put "member", ' Xueba ', ' info:age ', ' 0 row (s) in 0.0170 seconds
To facilitate the use of the commands below, insert some more data here:

Put ' member ', ' Xueba ', ' info:age ', ' 25 '

Put ' member ', ' Xueba ', ' info:birthday ', ' 1989-06-19 '

Put ' member ', ' Xueba ', ' info:company ', ' tecent '

Put ' member ', ' Xueba ', ' address:contry ', ' the '

Put ' member ', ' Xueba ', ' address:province ', ' Guangdong '

Put ' member ', ' Xueba ', ' address:city ', ' Shenzhen '

Put ' member ', ' xiaoming ', ' info:age ', ' 24 '

Put ' member ', ' xiaoming ', ' info:birthday ', ' 1990-03-22 '

Put ' member ', ' xiaoming ', ' info:company ', ' tecent '

Put ' member ', ' xiaoming ', ' info:favorite ', ' movie '

Put ' member ', ' xiaoming ', ' address:contry ', ' the '

Put ' member ', ' xiaoming ', ' address:province ', ' Guangdong '

Put ' member ', ' xiaoming ', ' address:city ', ' Guangzhou '
14. Get FETCH table Data obtain Xueba information: hbase (Main):090:0> gets ' member ', ' Xueba ' COLUMN CELL Address:city timestamp=1436932081705, value             =shenzhen address:contry timestamp=1436932081662, Value=china &n

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.