Miss Zhu 2022-02-13 08:38:32 阅读数:812
adopt hbase shell command , Have access to HBase Command line interface .
As shown in the figure below ：
see HBase Version number ：
see HBase Status of each cluster ：
Be careful , If you execute HBase Shell When ordered , There is ：
Server is not running yet abnormal , It should be closed Hadoop Security mode of
hadoop dfsadmin -safemode leave
And restart Hadoop、ZooKeeper、HBase colony .
attach Hadoop Safe mode other common commands ：
# Enter safe mode hadoop dfsadmin -safemode enter # View current mode hadoop dfsadmin -safemode get
HBase Shell In the syntax , All string parameters must be enclosed in single quotes , And case sensitive .
establish Student surface , There are two column families in the table ： Stulnfo and Grades
list Command to view all tables ：
exists ‘ Table name ’ Check to see if there is this table
describe ‘ Table name ’, You can view all column families in the table
to Student Add a new table hobby Column family of
Delete hobby Column family
Want to delete table , You have to disable the table first , Then delete
disable 'Student' drop 'Student'
Here is an example
The new data
Note that a new addition is a new addition to a cell
put 'Student', '0001', 'StuInfo:Name', 'Tom Green', 1
The first parameter Student Is the name of the watch ;
The second parameter 0001 Is the name of the row key , Is a string type ;
The third parameter StuInfo:Name Name the column family and column , The middle is separated by a colon . The family name must be created , otherwise HBase Will report a mistake ; Column names are temporarily defined , Therefore, the columns in the column family can be expanded at will ;
Fourth parameter Tom Green Is the value of the cell . stay HBase in , All data is in the form of a string ;
Last parameter 1 For timestamps , If you do not set the timestamp , Then the system will automatically insert the current time as the timestamp .
Want to add data, such as in the icon , You need to continue to execute the following statement
put 'Student', '0001', 'StuInfo:Name', 'Tom Green', 1 put 'Student', '0001', 'StuInfo:Age', '18' put 'Student', '0001', 'StuInfo:Sex', 'Male' put 'Student', '0001', 'StuInfo:BigData', '80' put 'Student', '0001', 'Grades:Computer', '90' put 'Student', '0001', 'Grades:Math', '85'
If put The cell in the statement already exists , Instant key 、 Column families and column names already exist , Without considering the timestamp , perform put sentence , Then you can update the data .
put 'Student', '0001', 'StuInfo:Name', 'Jim Green'
If the timestamp is set to n, You can save n Data .
It is divided into deleting cell data and row data
Delete cell data ：
Delete Student The row key in the table is 0001,Grades Column family members are Math, Timestamp is less than or equal to 2 The data of ：`
delete 'Student', '0001', 'Grades:Math', 2`
Delete 0002 Row data ：
delete 'Student', '0002', 'Grades'
according to rowid Query row data
get 'student', '0001'
Query full table data ：
copyright：author[Miss Zhu]，Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130838300857.html