Advanced
Тема интерфейса

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.

You can get started by reading the following topics:

  1. Preparing an MRS Cluster
  2. Installing the HBase Client
  3. Creating a Table Using the HBase Client

Preparing an MRS Cluster

  1. Buying a Cluster

    1. Click the Custom Config tab.

  2. Set the following parameters and click Next .

    • Region : Select a region as required.
    • Cluster Name : Enter mrs_demo or specify a name according to naming rules.
    • Cluster Type : Select Analysis Cluster .
    • Cluster Version : Select MRS 3.1.0 .
    • Component : Select the HBase component.

  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

    VPC

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

    Subnet

    Retain the default value.

    Security Group

    Select Auto Create .

    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.

  4. Configure advanced options.

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

      Parameter

      Example Value

      Kerberos Authentication

      Disable this function.

      Password

      Enter a password.

      Confirm Password

      -

      Login Mode

      Password

      Password

      Enter a password.

      Confirm Password

      -

    2. Click Create Now . A page is displayed, indicating that the task is submitted.
    3. Click Back to Cluster List . You can view the status of the cluster on the Active Clusters page.
    4. 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 Active Clusters in the navigation pane on the left. On the Active Clusters page, click the cluster named mrs_demo to go to its details page.
  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.
  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.
  4. Log in to the active management node as user root .
  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 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.
    2. Click Remote Login in the upper right corner of the page to log in to the Master1 node as user root . The password is the one set when the cluster is created.

  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

    Note

    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'