Help Center> MapReduce Service> Getting Started> Using HBase from Scratch
Updated on 2023-08-29 GMT+08:00

Using HBase from Scratch

MRS provides Hadoop-based high-performance big data components, such as Spark, HBase, and Kafka.

This section uses a cluster with Kerberos authentication disabled as an example to describe how to log in to the HBase client, create a table, insert data into the table, and modify the table.

Video Tutorial

This video uses an MRS 3.1.0 cluster (with Kerberos authentication disabled) as an example to describe how to use an HBase client to create a table, insert data into the table, and modify table data. For details about how to use an HBase client to create a table, see Using an HBase Client.

The UI may vary depending on the version. The video tutorial is for reference only.

Preparing an MRS Cluster

  1. Purchase an MRS cluster.

    1. Go to the Buy Cluster page.
    2. Click the Custom Config tab.

  2. Set the following parameters and click Next.

    • Region: Select a region as required.
    • Billing Mode: Select Pay-per-use.
    • Cluster Name: Enter mrs_demo or specify a name according to naming rules.
    • Version Type: Select Normal.
    • Cluster Version: Select MRS 3.1.0.
      Figure 1 Configure Software page
    • Cluster Type: Select Analysis Cluster and select HBase.
      Figure 2 Selecting the cluster type and components

  3. On the Configure Hardware page, set the parameters by referring to Table 1, and click Next.

    Table 1 MRS cluster hardware configuration

    Parameter

    Example Value

    AZ

    AZ2

    Enterprise Project

    default

    VPC

    Retain the default value. You can also click View VPC to create a VPC.

    EIP

    You can select an existing EIP from the drop-down list. If no EIP is available in the drop-down list, click Manage EIP to access the EIPs page to create one.

    Figure 3 Hardware configurations

  4. Configure advanced options.

    1. On the Set Advanced Options page, configure the parameters according to Table 2, and click Next.
      Table 2 MRS cluster advanced options

      Parameter

      Example Value

      Kerberos Authentication

      Disable this function.

      Password

      Test@!123456

      Confirm Password

      Test@!123456

      Login Mode

      Password

      Password

      Test@#123456

      Confirm Password

      Test@#123456

      Figure 4 Set Advanced Options
    2. On the Confirm Configuration page, check the cluster configuration information. If you need to adjust the configuration, click to go to the corresponding tab page and configure parameters again.
    3. Select Enable for Secure Communications. Click Buy Now. A page is displayed, indicating that the task is submitted successfully.
    4. Click Back to Cluster List. You can view the status of the cluster on the Active Clusters page.
    5. Wait for the cluster creation to complete. The initial status of the cluster is Starting. After the cluster has been created successfully, the cluster status becomes Running.

Installing the HBase Client

  1. Choose Clusters > Active Clusters and click mrs_demo. The cluster information page is displayed.
  2. Click Access Manager next to MRS Manager. On the displayed page, configure the EIP information and click OK. Enter the username and password to access FusionInsight Manager.

    Figure 5 Logging in to FusionInsight Manager from the management console

  3. Choose Cluster > Services > HBase, and select Download Client from the More drop-down list. Select Complete Client, the corresponding platform type, and Save to path, and click OK.

    Figure 6 Downloading the cluster client

  4. Log in to the active management node as user root.

    To identify the active and standby management nodes, see Determining Active and Standby Management Nodes of Manager

  5. Go to the directory where the installation package is stored and run the following commands to decompress and verify the installation package, and decompress the obtained installation file:

    cd /tmp/FusionInsight-Client

    tar -xvf FusionInsight_Cluster_1_HBase_Client.tar

    sha256sum -c FusionInsight_Cluster_1_HBase_ClientConfig.tar.sha256

    tar -xvf FusionInsight_Cluster_1_HBase_ClientConfig.tar

  6. Go to the directory where the installation package is stored, and run the following command to install the client to a specified directory (an absolute path), for example, /opt/hbaseclient:

    cd /tmp/FusionInsight-Client/FusionInsight_Cluster_1_HBase_ClientConfig

    Run the ./install.sh /opt/hbaseclient command and wait until the client installation is complete.

  7. Check whether the client is successfully installed.

    cd /opt/hbaseclient

    source bigdata_env

    hbase shell

    If the command is successfully executed, the HBase client is successfully installed.

Creating a Table Using the HBase Client

  1. Log in to the master node using VNC.

    1. On the MRS console, choose Clusters > Active Clusters, and select mrs_demo from the cluster list. Click Nodes, and click the node whose name contains master1 to access its ECS details page.
      Figure 7 Nodes tab page where the Master1 node is
    2. Click Remote Login in the upper right corner of the page to log in to the master node as user root. The password is the one set when the cluster is purchased.
      Figure 8 Remotely logging in to the Master1 node

  2. Run the following command to go to the client directory:

    cd /opt/hbaseclient

  3. Run the following command to configure environment variables:

    source bigdata_env

    If Kerberos authentication is enabled for the cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables.

    For example:

    kinit hbaseuser

  4. Run the following command to access the HBase shell CLI:

    hbase shell

  5. Run the HBase client command to create the user_info table.

    1. Create the user_info table and add related data.

      create 'user_info',{NAME => 'i'}

      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 professional titles to the user_info table.

      put 'user_info','12005000201','i:degree','master'

      put 'user_info','12005000201','i:pose','manager'

    3. Query user names and addresses by user ID.

      scan'user_info',{STARTROW=>'12005000201',STOPROW=>'12005000201',COLUMNS=>['i:name','i:address']}

      ROW                                      COLUMN+CELL                                                                                                           
       12005000201                             column=i:address, timestamp=2021-10-30T10:21:42.196, value=City A                                                     
       12005000201                             column=i:name, timestamp=2021-10-30T10:21:18.594, value=A                                                             
      1 row(s)
      Took 0.0996 seconds 
    4. Query information by user name.

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

      ROW                                      COLUMN+CELL                                                                                                           
       12005000201                             column=i:address, timestamp=2021-10-30T10:21:42.196, value=City A                                                     
       12005000201                             column=i:age, timestamp=2021-10-30T10:21:30.777, value=19                                                             
       12005000201                             column=i:degree, timestamp=2021-10-30T10:21:53.284, value=master                                                      
       12005000201                             column=i:gender, timestamp=2021-10-30T10:21:18.711, value=Male                                                        
       12005000201                             column=i:name, timestamp=2021-10-30T10:21:18.594, value=A                                                             
       12005000201                             column=i:pose, timestamp=2021-10-30T10:22:07.152, value=manager                                                       
      1 row(s)
      Took 0.2158 seconds 
    5. Delete user data from the user information table.

      delete'user_info','12005000201','i'

    6. Delete the user information table.

      disable 'user_info'

      drop 'user_info'