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
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

Compiling and Running an HBase Application When a Client Is Installed

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

HBase applications can run in a Linux environment where an HBase client is installed. After application code development is complete, you can upload a JAR file to the Linux environment to run applications.

Prerequisites

  • You have installed an HBase client.
  • You have installed a JDK in the Linux environment. The version of the JDK must be consistent with that of the JDK used by Eclipse to export the JAR file.
  • If the host where the client is installed is not a node in the cluster, the mapping between the host name and the IP address must be set in the hosts file on the node where the client locates. The host names and IP addresses must be mapped one by one.

Procedure

  1. Modify the sample code.

    1. Currently, there are three types of HBase APIs in the sample code: common API, HFS API (no longer supported in MRS 1.9.x), and REST API. When commissioning different APIs to operate HBase, you can comment out the invoking of other APIs. In this example, common APIs are used to operate HBase and the main method contains only the following code snippet.
      public static void main(String[] args) {
        try {
          init();
          login();
        } catch (IOException e) {
            LOG.error("Failed to login because ", e);
            return;
        }
        // getDefaultConfiguration();
        conf = HBaseConfiguration.create();
        // test hbase API
        HBaseExample oneSample;
        try {
          oneSample = new HBaseExample(conf);
          oneSample.test();
        } catch (Exception e) {
          LOG.error("Failed to test HBase because ", e);
        }
        LOG.info("-----------finish HBase-------------------");
      }
    2. When you call HFS APIs (no longer supported in MRS 1.9.x) and RESTful APIs, you need to copy the inputfile.txt and hbaseclient.properties files in the src\main\resources directory in the sample project to the HBase/hbase/conf directory of the client (for example, the client directory is /opt/client), and modify the hbaseclient.properties file. userKeytabName and krb5ConfName indicate the file addresses obtained in 2. If you need to modify rest.server.info when using REST APIs, make it correspond to ip:port (default port: 21309) of the rest server.
      rest.server.info=10.10.10.10:21309
      user.name=hbaseuser
      userKeytabName=user.keytab
      krb5ConfName=krb5.conf
      NOTE:

      The HFSSample sample project is removed from MRS 1.9.x. Pay attention to the current cluster version.

  2. Run the mvn package command to generate a JAR file, for example, hbase-examples-mrs-2.0.jar. Obtain the JAR file from the target directory in the project directory, and upload it to the /opt/client/HBase/hbase/lib directory.
  3. Run the JAR file.

    1. Before running the JAR file on the Linux client, run the following command to switch to the client directory as the user that is used for installation:

      cd $BIGDATA_CLIENT_HOME/HBase/hbase

      NOTE:

      $BIGDATA_CLIENT_HOME indicates the client installation directory.

    2. Run the following command:

      source $BIGDATA_CLIENT_HOME/bigdata_env

      NOTE:

      After the multi-instance function is enabled, you also need to run the following command to switch to the client of the specified service instance before developing applications for the HBase service instance, for example, HBase2: source /opt/client/HBase2/component_env.

    3. Copy the JAR package generated in 2 and the krb5.conf and user.keytab files obtained in Preparing an HBase Application Development User to the HBase/hbase/conf directory in the client running environment, for example, /opt/client/HBase/hbase/conf. Create the hbaseclient.properties file in the /opt/client/HBase/hbase/conf directory if the file does not exist. In the file, user.name corresponds to the new user hbaseuser, and the values of userKeytabName and krb5ConfName correspond to the authentication-related file names obtained in Preparing an HBase Application Development User (skip this step if Kerberos authentication is not enabled for the cluster).
      user.name=hbaseuser
      userKeytabName=user.keytab
      krb5ConfName=krb5.conf
    4. Run the following command to execute the JAR package:

      hbase com.huawei.bigdata.hbase.examples.TestMain /opt/client/HBase/hbase/conf

      com.huawei.bigdata.hbase.examples.TestMain is used as an example. Use the actual code instead.

      /opt/client/HBase/hbase/conf corresponds to the path of files such as user.keytab and krb5.conf mentioned above.

      NOTE:

      For MRS 1.9.2 or later, run the hbase com.huawei.bigdata.hbase.examples.TestMain /opt/client/HBase/hbase/conf command.

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