Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page
Help Center/ MapReduce Service/ Component Operation Guide (Normal)/ Using HBase/ Quickly Using HBase for Offline Data Analysis

Quickly Using HBase for Offline Data Analysis

Updated on 2024-10-08 GMT+08:00

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 use the client to create tables, insert data into tables, modify tables, read and delete table data, and delete tables.

Background

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 titles to the table.
  • Query user names and addresses by user ID.
  • Query information by user name.
  • Deregister users and delete user data from the user information table.
  • Delete the user information table after service A ends.
Table 1 User information

ID

Name

Gender

Age

Address

12005000201

A

Male

19

City A

12005000202

B

Female

23

City B

12005000203

C

Male

26

City C

12005000204

D

Male

18

City D

12005000205

E

Female

21

City E

12005000206

F

Male

32

City F

12005000207

G

Female

29

City G

12005000208

H

Female

30

City H

12005000209

I

Male

26

City I

12005000210

J

Male

25

City J

Prerequisites

The client has been installed in a directory, for example, /opt/client. The client directory in the following operations is only an example. Change it to the actual installation directory. Before using the client, download and update the client configuration file, and ensure that the active management node of Manager is available.

Procedure

For MRS clusters earlier than version 3.x, perform the following steps:

  1. Download the client configuration file.

    1. Log in to MRS Manager. For details, see Accessing Manager. Then, choose Services.
    2. Click Download Client.

      Set Client Type to Only configuration files, Download To to Server, and click OK to generate the client configuration file. The generated file is saved in the /tmp/MRS-client directory on the active management node by default. You can customize the file path.

      Figure 1 Downloading the client configuration file

  2. Log in to the active management node of MRS Manager.

    1. On the Node tab page, view the Name parameter. The node that contains master1 in its name is the Master1 node. The node that contains master2 in its name is the Master2 node.

      The active and standby management nodes of MRS Manager are installed on Master nodes by default. Because Master1 and Master2 are switched over in active and standby mode, Master1 is not always the active management node of MRS Manager. Run a command in Master1 to check whether Master1 is active management node of MRS Manager. For details about the command, see 2.d.

    2. Log in to the Master1 node using the password as user root. For details, see section Logging In to an ECS.
    3. Run the following commands to switch to user omm:

      sudo su - root

      su - omm

    4. Run the following command to check the active management node of MRS Manager:

      sh ${BIGDATA_HOME}/om-0.0.1/sbin/status-oms.sh

      In the command output, the node whose HAActive is active is the active management node, and the node whose HAActive is standby is the standby management node. In the following example, mgtomsdat-sh-3-01-1 is the active management node, and mgtomsdat-sh-3-01-2 is the standby management node.

      Ha mode
      double
      NodeName              HostName                      HAVersion          StartTime                HAActive             HAAllResOK           HARunPhase 
      192-168-0-30          mgtomsdat-sh-3-01-1           V100R001C01        2019-11-18 23:43:02      active               normal               Actived    
      192-168-0-24          mgtomsdat-sh-3-01-2           V100R001C01        2019-11-21 07:14:02      standby              normal               Deactived
    5. Log in to the active management node, for example, 192-168-0-30 of MRS Manager as user root, and run the following command to switch to user omm:

      sudo su - omm

  3. Run the following command to switch to the client installation directory, for example, /opt/client:

    cd /opt/client

  4. Run the following command to update the client configuration for the active management node.

    sh refreshConfig.sh /opt/client Full path of the client configuration file package

    For example, run the following command:

    sh refreshConfig.sh /opt/client /tmp/MRS-client/MRS_Services_Client.tar

    If the following information is displayed, the configurations have been updated successfully.

    ReFresh components client config is complete.
    Succeed to refresh components client config.
    NOTE:

    You can refer to steps 1 to 4 or Method 2 in Updating a Client.

  5. Use the client on a Master node.

    1. On the active management node where the client is updated, for example, node 192-168-0-30, run the following command to go to the client directory:

      cd /opt/client

    2. Run the following command to configure environment variables:

      source bigdata_env

    3. If Kerberos authentication has been enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables. For details about how to configure a role with the corresponding permissions, see Creating a Role. To bind a role to a user, see Creating a User. If Kerberos authentication is disabled for the current cluster, skip this step.

      kinit MRS cluster user

      For example, kinit hbaseuser.

    4. Run the following HBase client command:

      hbase shell

  6. Run the following commands on the HBase client to implement service A.

    1. Create the user_info user information table according to Table 1 and add 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','City A'

    2. 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'

    3. Query user names 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']}

    4. Query information by user name.

      For example, to query information about user A, run the following command:

      scan'user_info',{FILTER=>"SingleColumnValueFilter('i','name',=,'binary:A')"}

    5. 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'

    6. Delete the user information table.

      disable'user_info'

      drop 'user_info'

For MRS 3.x or later clusters, perform the following steps:

  1. Use the client on the active management node.

    1. Install the client. For details, see Installing a Client.
    2. Log in to the node where the client is installed as the client installation user and run the following command to switch to the client directory:

      cd /opt/client

    3. Run the following command to configure environment variables:

      source bigdata_env

    4. If Kerberos authentication has been enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables. For details about how to configure a role with the corresponding permissions, see Creating HBase Roles. To bind a role to a user, see Creating a User. If Kerberos authentication is disabled for the current cluster, skip this step.

      kinit MRS cluster user

      For example, kinit hbaseuser.

    5. Run the following HBase client command:

      hbase shell

  2. Run the following commands on the HBase client to implement service A.

    1. Create the user_info user information table according to Table 1 and add 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','City A'

    2. 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'

    3. Query user names 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']}

    4. Query information by user name.

      For example, to query information about user A, run the following command:

      scan'user_info',{FILTER=>"SingleColumnValueFilter('i','name',=,'binary:A')"}

    5. 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 all data fields of the user whose ID is 12005000201 in sequence. The following uses the age field as an example:

        delete 'user_info','12005000201','i:age'

      • Remove all the data of the user whose ID is 12005000201.

        deleteall 'user_info','12005000201'

    6. Delete the user information table.

      disable'user_info'

      drop 'user_info'

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback