Hbase data structures and operation of shell

Hbase data structure
basic elements: namespace, tables, rows, columns, cells, Region, timestamp.
1. namespace: the role of NameSpaces
Table: table, all tables are named after members of the space, that table will belong to a namespace, if not specified, the default default namespace.
RegionServer group: namespace contains the default RegionServer Group.
Permission: Permissions, namespaces can define access control list ACL (Access Control List). For example, create a table, the table read, delete, update, etc. operations.
Quota: quota, you can force a region of space containing the number of names.
Table 2: Table can be understood as a relational database concept.
3. OK: OK key rowkey unique identification element row, the data storage table are sorted according to the row key, the data is accessed by the row key.
4. Column :( column family: the column name) of each column of the table, belongs to a family row, column family is part of the schema of the table (not listed) must be defined before using the table and column names to column group prefix; e.g. info: name, info: age,info belongs to the column group.
The cell: cell stored in the cell is an integral byte array, each cell has version information, if the version is not inserted in the data set, or the default version.
6.region: region horizontal division table, Hbase cluster is the smallest unit of data distribution, all regions of the line would constitute a table of contents.
7. timestamp: Hbase each cell are stored in a plurality of versions of the same data, indexed by timestamp version, can set the value of the time stamp is inserted into the data, if not set the default time stamp is generated.
Hbase Shell operators
use hbase shell on any node to connect to the host Hbase instance has been started:

  1 # hbase shell

hbaseshell001
Enter help to display the help document content, status Hbase can view the status of the cluster:

  1 > help

hbaseshell002
hbaseshell003
status offer HBase states:

  1 > status

hbaseshell004
version is being used to provide Hbase version:

  1 > version

hbaseshell005
create to create a table, you must specify the table name and ColumnFamily name when you create:

  1 > create 'testtable','infofamily'

hbaseshell006
list to view all the tables in HBase:

  1 > list

hbaseshell007
describe command to view a table of information:

  1 > describe 'testtable'

hbaseshell008
alter modify a table, for example, add a column group:

  1 > alter 'testtable',NAME=>'basic'

hbaseshell009

Use the describe command to view the table information added after the column family: Use alter command to delete the column family:
hbaseshell010


  1 > alter 'testtable',NAME=>'basic','METHOD'=>'delete'

hbaseshell011

hbaseshell012
Use the disable command to disable the table, delete the table or in doing other operations, the need to operate in the case of a disabled table, use the enable command to re-enable a disabled table:

  1 > disable 'testtable'


  1 > enable 'testtable'

hbaseshell013
Use the drop command to delete the disabled list (you must first disable the table, otherwise it will report an error prompt):

  1 > disable 'testtable'
  2 > drop 'testtable'

hbaseshell014
hbaseshell015
Then create a table testtableone:

  1 > create 'testtableone','info'

Using the put command to add data to the table, put command Format:

  . 1 > PUT 'table', 'OK button', 'Group columns: Column name', 'of VALUE'

  1 > put 'testtableone','row1','info:name','Jack'

hbaseshell016
Use get command can see a row of data:

  1 > get 'testtableone','row1'

hbaseshell017
Use scan can view the data information table of all lines:

  1 > scan 'testtableone'

hbaseshell018
delete means for deleting the cell value in the table, delete command format:

  . 1 > Delete 'table', 'OK button', 'Group columns: Column name', timestamps

Inserted into the first few multi-table data.
Note: This data is inserted in first row insertion row2 data Bob, since when the subsequent insertion of data, row2 row of keys has not changed, so the data is directly replaced Bob Lucy. Delete Jack's class cell data:
hbaseshell019
hbaseshell020


  1 > delete 'testtableone','row1','info:class',1566182654321

hbaseshell021
deleteall used to delete all the cells in a given row:

  . 1 > Delete 'table', 'OK button'

All cells delete data row1 line:

  1 > deleteall 'testtableone','row1'

hbaseshell022
for counting a count value in the table and returns the rows:

  1 > count 'testtableone'

hbaseshell023
Thus commonly used commands enumeration is complete.

Guess you like

Origin www.cnblogs.com/Dcl-Snow/p/11433031.html