Getting started with HBase - the use of basic commands of hbase in experiment 2

Getting Started with HBase - Experiment 2

Experimental content

Use the HBase shell commands provided by Hadoop to complete the following tasks:

  • List the relevant information of all tables in current HBase, such as table name, creation time, etc.;

  • Create a table of textbook table 4-4 (storage of web page summary information), and insert data;

  • Count the number of rows in the created table

Experimental procedure

First open all required environments:

ssh localhost
start-dfs.sh
start-hbase.sh
# 进入 hbase shell 命令行
hbase shell

Note: The commands we will follow here are all run under the command line of the hbase shell

We can use the list syntax that comes with hbase to view all the contents of the current table:

list

Then we need to create this table on the command line:

Here we directly use the create command to create the table:

create '实例' , '行键' , '时间戳' , '列族contents' , '列族anchor'
# 这里的第一个变量是我们要创建的表名,其余的是列

After we execute the above command, we query again, and we can see that we have created a table:

Next we start inserting data;

put '实例','row1','行键','com.cnn.www'
put '实例','row1','时间戳','t5'
put '实例','row1','时间戳','t4'
put '实例','row1','列族anchor','anchor.cnnsi.com=CNN'
put '实例','row1','列族anchor','anchor.my.look.ca=CNN.com'

Then we can use the query command to query the data we just created:

Here if we want to delete the table, we need to deprecate the table first, and then delete it:

# 先弃用
disable '表名'
# 再删除
drop '表名'

If we want to query all history records in the table:

scan '表名' , {RAW=>TRUE,VERSIONS=>3,TIMERANGE=>[1,2]}
# 这里 {} 中的两个变量如下:
# RAW=>TRUE 表示显示列名
# VERSIONS=>3 表示最多显示统一行,同一列下我们的最新的三次列值变化,也就是最近三次时间戳我们对当前值的改变
# TIMERANGE 表示查看时间戳1到2的值

Guess you like

Origin blog.csdn.net/m0_59161987/article/details/129701366