Big data learning: basic operations of Hbase shell

     HBase's command line tool, the simplest interface, is suitable for HBase management. You can use shell commands to query the details of data in HBase. After installing HBase, start the hadoop cluster (using hdfs storage), start zookeeper, use the start-hbase.sh command to start the hbase service, and finally execute the hbase shell in the shell to enter the command line interface

  The help of Habse shell has a complete introduction to the grammar. The operations of the hbase shell are divided into 10 categories. This article only introduces the first 4 commonly used categories, namely: general, ddl, namespace, dml

  1. Gerneral

  status: Query the current server status.

  


  Version: View the current version

  


  Whoami: Query the current hbase user

  


  Table_help: A reference to a table, by obtaining a reference to a table to add and delete data to this table, etc., it is not recommended now

  2. DDL

  Create: create a table

  ###Create a table named qianfeng, cf is the column family

  create 'qianfeng','cf'

  


  list: List all tables of HBase

  


  disable: disable a table

  ##disable table 'qianfeng'

  · disable 'qianfeng'

  is_disabled: Whether the table is disabled

  ##Verify if table 'qianfeng' is disabled

  · is_disabled ‘qianfeng’

  ·


  enable: enable a table

  ##Enable table 'qianfeng'

  · enable 'qianfeng'

  is_enabled: Whether the table is enabled

  ##Verify if table 'qianfeng' is enabled

  · is_enabled ‘qianfeng’

  ·


  describe: View the description of the table

  ##View the description information of the 'qianfeng' table

  · describe 'qianfeng'

  ·


  alter: modify the structure of the table

  ##Add a column family 'cf1' to table 'qianfeng'

  · alter 'qianfeng', 'cf1'

  ·


  exists: Verify that the table exists

  ##Verify that table 'qianfeng' exists

  · exists ‘qianfeng’

  ·


  drop: drop the table, the table needs to be disabled before it can be dropped

  ## delete table 'qianfeng'

  · disable 'qianfeng'

  · drop 'qianfeng'

  ·


  disable_all: disable multiple tables

  drop_all: delete multiple tables, the table needs to be disabled before it can be deleted

  3. Namespace

  create_namespace: Create a namespace, which is equivalent to creating a database in a relational database

  ##Create a namespace named 'qf' and add attributes

  create_namespace ‘qf’, {'PROPERTY_NAME'=>'PROPERTY_VALUE'}

  alter_namespace: modify, add, delete attributes of namespace

  ##Set the properties of the namespace qf

  alter_namespace 'qf', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}

  ##Remove attributes of namespace qf

  alter_namespace 'qf', {METHOD => 'unset', NAME=>'PROPERTY_NAME'}

  describe_namespace: Get the description of the namespace

  ##Get description information of namespace 'qf'

  describe_namespace ‘qf’

  


  drop_namespace: delete the namespace

  ## delete namespace 'qf'

  drop_namespace ‘qf’

  list_namespace: view all namespaces

  


  list_namespace_tables: View all tables under the namespace

  ##View all tables under namespace 'ns1'

  list_namespace_tables ‘ns1’


  4. DML

  First create a table test under the namespace 'qianfeng' (if there is no such namespace, create this namespace first), the column family is 'cf' as a test

  create 'qianfeng:test','cf'

  put: add cell (data)

  # #Add data to the column family where the rowkey of the table test in the namespace qianfeng is r1

  put 'qianfeng:test','r1','cf:uname','zhangsan'

  scan: scan the entire table

  scan 'qianfeng:test'

  


  get: Get the data of a column or cell.

  ##Add data to the column family where the rowkey of the table test in the namespace qianfeng is r1

  put 'qianfeng:test','r1','cf:age','23'

  ##Get all data with rowkey r1 under column family cf

  get 'qianfeng:test','r1'

  


  ##Get the data whose rowkey is r1 and the column name is uname under the column family cf (get a cell)

  get 'qianfeng:test','r1','cf:uname'

  


  truncate: clear the table without disable (just clear the data)

  ##Empty table 'qianfeng:test'

  truncate 'qianfeng:test'

  


  View all tables under 'qianfeng'

  


  The above is the basic operation of hbase shell script, which should be mastered. Learning the java api of hbase on the basis of mastering the hbase shell script will be more effective with less effort.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325930195&siteId=291194637