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
Help Center/ GeminiDB/ GeminiDB Cassandra API/ HBase-Compatible Instance/ Connecting to a GeminiDB HBase Instance

Connecting to a GeminiDB HBase Instance

Updated on 2025-01-26 GMT+08:00

This section describes how to connect to a GeminiDB HBase instance using a private IP address and Java.

Prerequisites

  • A GeminiDB HBase instance has been created and is running normally. For details about how to create a GeminiDB HBase instance, see Buying a GeminiDB HBase Instance.
  • For details about how to create an ECS, see Purchasing an ECS in Getting Started with Elastic Cloud Server.
  • JDK has been installed on the ECS.
  • Download the HBase client. Click a directory of the latest version 2.6.X and download hbase-2.6.X-client-bin.tar.gz. For example, if the latest version is 2.6.1, click that directory and download hbase-2.6.1-client-bin.tar.gz. HBase 1.X is not recommended due to compatibility issues.

Viewing the IP Address of an Instance

  1. Log in to the Huawei Cloud console.
  2. On the Instances page, click the name of the target instance.

    Method 1

    In the Node Information area on the Basic Information page, view the private IP address of each node in the GeminiDB HBase instance.

    NOTE:

    Public IP addresses cannot be bound to GeminiDB HBase instances.

    Figure 1 Viewing the IP address

    In the Network Information area, you can view the port of the GeminiDB HBase instance. The default port displayed on the page is 8635, but the default port in use is 2181.

    Figure 2 Viewing the port number

    Method 2

    In the navigation pane on the left, click Connections.

    Figure 3 Viewing the IP addresses and port number

Connecting to an Instance over a Private Network

  1. Log in to ECS.

    For details, see Logging In to an ECS in Getting Started with Elastic Cloud Server.

  2. Upload the HBase client installation package to the ECS.
  3. Run the following command to decompress the package:

    tar -xvf hbase-2.6.1-client-bin.tar.gz

  4. Add the following configurations to conf/hbase-site.xml in the client directory and set value to the IP address of your instance. Use commas (,) to separate multiple IP addresses. The private IP address can be obtained by following Viewing the IP Address of an Instance.

    <configuration> 
      <property>
        <name>hbase.zookeeper.quorum</name>
        <value>127.0.0.1,127.0.0.2,127.0.0.3</value>
      </property>
    </configuration>

  5. Go to the bin directory of the decompressed client and run the following command to connect to the instance: Replace YOUR_USERNAME and YOUR_PASSWORD with the user password set during instance creation. The username is fixed to rwuser.

    export HADOOP_PROXY_USER="YOUR_USERNAME"
    export HADOOP_USER_NAME="YOUR_PASSWORD"
    ./hbase shell

  6. If information similar to the following is displayed, the connection was successful.

    hbase:001:0>

Connecting to an Instance Using Java

  1. Obtain the private IP address and port number of the instance.

    For details about how to obtain the private IP address and port number, see Viewing the IP Address of an Instance.

  2. Log in to the ECS. For details, see Logging In to an ECS in Getting Started with Elastic Cloud Server.
  3. Add the following Maven dependencies to your project. HBase 1.X is not recommended due to compatibility issues.

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <version>2.6.1</version>
    </dependency>

  4. Edit the code for connecting to the instance.

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.TableName;
    import org.apache.hadoop.hbase.client.*;
    import org.apache.hadoop.hbase.util.Bytes;
    
    import java.io.IOException;
    
    public class HBaseExample {
        public static void main(String[] args) throws IOException {
            // Creates a configuration object and sets HBase connection parameters.
            Configuration config = HBaseConfiguration.create();
            config.set("hbase.zookeeper.quorum", "your_hbase_instance_quorum");
            config.set("hbase.zookeeper.property.clientPort", "your_hbase_instance_port");
    
            // Enters a username and password.
            UserGroupInformation ugi = UserGroupInformation.createProxyUser("your_user_name",   UserGroupInformation.createRemoteUser("your_password"));
    
            // Establishes a connection to the HBase instance.
            Connection connection = ConnectionFactory.createConnection(config, User.create(ugi));
    
            try {
                // Obtains table objects.
                TableName tableName = TableName.valueOf("your_table_name");
                Table table = connection.getTable(tableName);
    
                // Inserts data.
                Put put = new Put(Bytes.toBytes("row_key"));
                put.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("col"), Bytes.toBytes("value"));
                table.put(put);
    
                // Obtains a single row of data.
                Get get = new Get(Bytes.toBytes("row_key"));
                Result result = table.get(get);
                byte[] value = result.getValue(Bytes.toBytes("cf"), Bytes.toBytes("col"));
                System.out.println("Value: " + Bytes.toString(value));
    
            } finally {
               // Closes the connection.
                connection.close();
            }
        }
    }

  5. Run the sample code to check whether the result is normal.

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