Quickly Creating an HBase Cluster and Querying Offline Data
HBase is a column-based distributed storage system that features high reliability, performance, and scalability. This section describes how to use HBase from scratch. For example, how to run the HBase shell command to create tables, insert data into tables, modify tables, read and delete table data, and delete tables.
Background Information
Suppose a user develops an application to manage users who use service A in an enterprise. The procedure of operating service A on the HBase client is as follows:
- Create the user_info table.
- Add users' educational backgrounds and professional titles to the table.
- Query usernames and addresses by user ID.
- Query information by username.
- Deregister users and delete user data from the user information table.
- Delete the user information table after service A ends.
ID |
Name |
Gender |
Age |
Address |
---|---|---|---|---|
12005000201 |
A |
Male |
19 |
IPA, IPB |
12005000202 |
B |
Female |
23 |
IPC, IPD |
12005000203 |
C |
Male |
26 |
IPE, IPF |
12005000204 |
D |
Male |
18 |
IPG, IPH |
12005000205 |
E |
Female |
21 |
IPI, IPJ |
12005000206 |
F |
Male |
32 |
IPK, IPL |
12005000207 |
G |
Female |
29 |
IPM, IPN |
12005000208 |
H |
Female |
30 |
IPO, IPP |
12005000209 |
I |
Male |
26 |
IPQ, IPR |
12005000210 |
J |
Male |
25 |
IPS, IPT |
Preparations
- Sign up for a HUAWEI ID and enable Huawei Cloud services. For details, see Signing Up for a HUAWEI ID and Enabling Huawei Cloud Services. The account cannot be in arrears or frozen.
- Create a VPC and subnet. For details, see Creating a VPC and Subnet.
Step 1: Buying an HBase Cluster
- Log in to the CloudTable console.
- Select a region in the upper left corner.
- Click Cluster Management.
- Click Buy Cluster in the upper right corner of the Cluster Management page and set related parameters. For details about how to configure ports for security group rules, see HBase security group rules.
- Click Buy Now. On the displayed page, confirm the specifications and click Finish.
- Return to the cluster list to view the cluster creation progress. If the cluster status is Running, the cluster is successfully created. For details, see Creating an HBase Cluster.
Table 2 HBase security group rules Direction
Protocol
Port/Range
Source/Security Group
Usage
Outbound
All
All
0.0.0.0/0
Permit in the outbound direction
Inbound
TCP
16000
Security group of the CloudTable HBase cluster
HMaster RPC port
TCP
16020
RegionServer RPC port
TCP
2181
ZooKeeper client connection monitoring port
TCP
2888
Follower connection monitoring port
TCP
3888
ZooKeeper election port
TCP
2000
HAgent access port
Step 2: Preparing an ECS
- Purchase an ECS and log in to the ECS console.
- Select a region in the upper left corner.
- In the service list on the left, choose Computing > Elastic Cloud Server. The Elastic Cloud Server page is displayed.
- Click Buy ECS in the upper right corner. The parameter configuration page is displayed.
- Configure ECS parameters, including basic settings, instance, OS, storage replica, network, security group, public access, ECS management, advanced settings, and quantity.
- Check the configurations, select the agreement, and click Submit. After the ECS is created, it will be started by default.
For details, see Purchasing an ECS.
To ensure successful connection of the cluster to the VPC, the security group configurations must align with those of the ECS.
Step 3: Adding a Security Group
- Obtain the IP address of the local host. Press Win+R. The Run dialog box is displayed.
- Enter cmd in the text box and click OK. The cmd window is displayed.
- Enter ipconfig in the command window and press Enter to query the IP address of the local host.
- Log in to the ECS console.
- On the ECS list page, click the ECS name. On the Basic Information tab page, click the Security Group tab. On the displayed page, click Inbound Rules.
- Click Add Rule in the upper right corner of the page.
- Enter the local IP address obtained in 3 as the source IP address. Click OK. The security group is added.
Step 4: Installing the Client and Verifying the Client
This part introduces how to manually install the client. You can also choose the one-click client deployment method.
- Download the one-click client deployment tool. Use the SSH login tool (such as PuTTY) to log in to the Linux ECS through the EIP.
For details about how to log in to the ECS, see "Remotely Logging In to a Linux ECS (Using an SSH Password)" in Logging In to a Linux ECS of the Elastic Cloud Server User Guide.
Then run the following command to obtain the one-click client deployment tool:curl -O -k "https://cloudtable-publish.obs.myhuaweicloud.com/quick_start_hbase_shell.sh"
This command applies to HBase 1.x.
curl -O -k "https://cloudtable-publish.obs.myhuaweicloud.com/cloudtable-client/quick_start_hbase_shell.sh"
- This command applies to HBase 2.x.
- The verification file is contained in the one-click deployment package.
- Obtain the cluster access address.
- Log in to the CloudTable console and go to the Cluster Management page.
- Click the cluster name. On the displayed page, click Details.
- Obtain the value of ZK Link (Intranet), which is the cluster access address.
- Use the tool to deploy the client. Replace $zookeeper_address in the following command with the ZK link you obtained in 2. Then, run the command on the CLI of the ECS to deploy the client in one click.
- Commands for one-click client deployment of a common cluster:
source quick_start_hbase_shell.sh $zookeeper_address
- Commands for one-click deployment of a security cluster:
source quick_start_hbase_shell $zookeeper_address enable
- Commands for one-click client deployment of a common cluster:
- Start the shell to access the cluster.
After you run the source command to automatically deploy the client, the HBase shell is automatically started. You can also run the bin/hbase shell command to start the HBase shell to access the cluster.
Step 5: Running the HBase Client Command to Implement Service A
- Create the user_info table according to Table 1 and add related data to it.
create 'user_info',{NAME => 'i'}
For example, to add information about the user whose ID is 12005000201, run the following commands:
put 'user_info','12005000201','i:name','A' put 'user_info','12005000201','i:gender','Male' put 'user_info','12005000201','i:age','19' put 'user_info','12005000201','i:address','IPA, IPB'
- Add users' educational backgrounds and titles to the user_info table.
For example, to add educational background and title information about user 12005000201, run the following commands:
put 'user_info','12005000201','i:degree','master' put 'user_info','12005000201','i:pose','manager'
- Query usernames and addresses by user ID.
For example, to query the name and address of user 12005000201, run the following command:
scan 'user_info',{STARTROW=>'12005000201',STOPROW=>'12005000201',COLUMNS=>['i:name','i:address']}
- Query information by username.
For example, to query information about user A, run the following command:
scan 'user_info',{FILTER=>"SingleColumnValueFilter('i','name',=,'binary:A')"}
- Delete user data from the user information table.
All user data needs to be deleted. For example, to delete data of user 12005000201, run the following command:
delete 'user_info','12005000201','i'
- Delete the user information table.
disable 'user_info';drop 'user_info'
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot