In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1. Course introduction this article will first introduce the HBase command line, and then introduce the java code to add, delete, modify and query the tables in hbase. All commands in this article are run and passed in CentOS-6.4-x86_64,hadoop-2.5.2,jdk1.8.0_152,zookeeper-3.4.11,hbase-1.2.6. In order to reduce the impact of linux permissions on beginners, all commands are operated under the root permissions of linux. 2. Theoretical Review HBase is a highly reliable, high-performance, column-oriented and scalable distributed storage system, and it is the most commonly used NoSQL database in the industry. The premise that HBase works correctly is that Hadoop is installed. Hadoop technology itself includes HDFS and Map/Reduce. HDFS is used for mass data storage, and M chart R is used for massive data calculation. HDFS contains namenode and datanode. Namenode indexes the data in datanode. As a coordination service, zookeeper provides high availability for namenode. 3. Basic command line operation
Note:
confirms that the following components are started successfully before executing the following command: zookeeper, hdfs, yarn, hbase.
is under bin in the hbase installation directory, execute the following command to enter the hbase command line:
3.1 create a regular table
The syntax for creating a regular table in step 1 is: create 'name of the table', 'name of the column family'.
Enter the command:
Table "t_info" was created successfully.
Step 2-list function: see how many common tables there are in the system.
From this we can see that there are already three tables in the system.
3.2Create namespace
The syntax for creating a namespace is: create_namespace 'name'.
Step 1 create a table under the specified namespace
Create the table under the specified namespace: name of create 'namespace: table name', 'column family'.
Step 2 View the table under the specified namespace
Look at the table under the specified namespace: name of list_namespace_tables' namespace'.
3.3 increase data
Add data: put 'name of table', 'name of RowKey',' column', 'specific assignment'.
Enter the information of a 40-year-old man named Kobe who lives in Los Angeles into the table "cga_info":
3.4 query data in get mode
Step 1 get function: precise query.
Query exactly what is stored in a RowKey: get 'name of the table', 'RowKey'
Step 2 query exactly what is stored in a cell in a RowKey.
Syntax: get 'name of the table', 'RowKey',' column name'
3.5 query data in scan mode
Step 1 query the information of all columns under a column family in the table: scan 'name of the table', {Columns= > 'column'}
Step 2 queries the information stored in a specific column in the table.
Syntax: scan 'name of table', {Columns= > 'specific name of column'}
3.6 specify conditions to query data
Step 0 add Yao Ming information to the database
Step 1 queries the data in RowKey "123001" and "123002".
Step 2 queries the information stored in cells with column names name in Rowkey of "123001" and "123002".
3.7 Update data
Step 1 first look up the age information in the table with a Rowkey of 123001.
Step 2 change the age information with a Rowkey of 123001 in the table.
Step 3 query the age information with a Rowkey of 123001 in the table again.
Compared with the results of steps 2 and 3, the age information has been updated.
Delete data (1) use delete to delete a column of data
Step 1 first look up the information in the table with a Rowkey of 123001.
Step 2 use delete to delete the data stored in the age column in 123001.
Step 3 again query the information in the table with a Rowkey of 123001.
Compared with the results of steps 1 and 3, the age information has been deleted.
(2) use deleteall to delete the whole row of data
Step 1 use deleteall to delete 123001 of the entire row of data in table cga_info.
Step 2 query the table again for information with a Rowkey of 123001.
At this time, there is no information with a RowKey of 123001 in the table, indicating that the row data was deleted successfully.
(3) use drop to delete the data table
Step 1 first disable the name of the table, and then delete the data table using the name of the drop table.
Step 2 query the table under the current namespace.
The result shows that the table t_info has been deleted.
3.9 filtering data
Filter allows certain filtering conditions to be set during the Scan process, and only the qualified user data will be returned, and all the filters will take effect on the server side to ensure that the filtered data will not be transmitted to the client.
Example 1: query people aged 38.
Example 2: query for someone named Yao.
Example 3: query gender information for all people in the table.
Example 4: look up the address information of everyone in the table and find out who lives in Shanghai.
Fliter can filter data according to more conditions such as column family, column, version, and so on. Here only four filtering methods are demonstrated. RPC query requests with filter conditions will distribute the filter to each RegionServer, which can reduce the pressure of network transmission.
4. Summary
HBase can be read in real time while storing millions of columns and billions of rows, which is worthy of our in-depth use and research. Later, we will serialize a series of big data blogs. Welcome to follow and communicate.
all the installation software and other benefits in this article, please join the group and get it from the administrator.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.