Help Center> CloudTable Service> User Guide> Cluster Mode> Using HBase> Using HBase Shell to Access a Cluster

Using HBase Shell to Access a Cluster

You can use the HBase shell to access a cluster by deploying a client in one click or manually installing a client on an ECS. Deploying a Client in One Click is recommended.

Deploying a Client in One Click

  1. Prepare a Linux ECS.

    Using a one-click client deployment tool. The recommended Linux ECS operating systems are EulerOS, CentOS, Ubuntu, and SUSE. For details, see Preparing an ECS.

  2. Download the one-click client deployment tool.

    Use the SSH login tool (such as PuTTY) to remotely log in to the Linux ECS through the EIP and run the following command to obtain the one-click deployment tool.

    curl -O -k "http://cloudtable-publish.obs.myhwclouds.com/quick_start_hbase_shell.sh"

  3. Obtain a cluster access address.

    Log in to the CloudTable management console and choose Cluster Mode. In the cluster list, locate the required cluster and obtain its ZK link in the ZK Link column. The parameter value is the cluster access address, as shown in Figure 1.

    Figure 1 ZK link

  4. Use the tool to deploy the client.

    • Clusters with IAM authentication disabled
      Replace $zookeeper_address in the following command with the ZK link you obtained in 3. Then, run the command on the CLI of the ECS to deploy the client in one click.
      source quick_start_hbase_shell.sh $zookeeper_address
    • Clusters with IAM authentication enabled

      Specify account information for IAM authentication in the following command, and then run this command to deploy the client in one click.

      source quick_start_hbase_shell.sh $zookeeper_address $user_name $access_key $secret_key
      • $zookeeper_address: Replace it with the ZK link obtained in 3.
      • $user_name: Username used for creating a cluster. If the cluster is created using an account, set $user_name to an account name. If the cluster is created using an IAM user under an account, set $user_name to the IAM username.account name. An account and an IAM user are in a parent-child relationship.

        For a cluster with IAM authentication enabled, $user_name must be set to the username used for creating the cluster and cannot be updated after the cluster is created. To update the username, submit a work order to the O&M personnel.

      • $access_key and $secret_key: Access keys. Set $access_key to the AK plaintext and $secret_key to the SK plaintext. You can move your cursor over your account in the upper right corner of the management console and choose My Credential. Click Access Keys tab. On the Access Keys tab page, you can view the existing access keys or click Add Access Key to add an access key.

      The IAM authentication mode provides better security than the normal mode. Therefore, you are advised to enable IAM authentication for the CloudTable cluster and use IAM authentication in client or application code to connect to the cluster.

  5. Start the shell to access the cluster.

    After you run the source command to automatically deploy the client, the HBase shell is automatically started. You can also run the bin/hbase shell command to start the HBase shell to access the cluster.

Manually Installing a Client

  1. Prepare a Linux ECS.

    For details, see the following content in Preparing an ECS.

    1. Preparing an ECS
    2. Configuring the DNS Address and hosts File for the Linux ECS

  2. Download a client.

    Log in to the CloudTable management console, click Help in the left navigation pane, and click Download Client on the right to download the client installation package.

    Figure 2 Downloading the client

  3. Install the client.

    1. Use a file transfer tool (such as WinSCP) to upload the client installation package to the Linux ECS.
    2. Use the SSH login tool (such as PuTTY) to log in to the Linux ECS through the EIP.

      For details about how to log in to the ECS, see Login Using an SSH Password in the Elastic Cloud Server User Guide.

      Run the following command to decompress the client installation package:

      cd <Path of the client installation package>
      tar xzvf hbase-1.3.1-bin.tar.gz

      <Path of the client installation package>: Replace it with the actual path.

    3. Configure the ZooKeeper address in a configuration file.

      In the decompression directory of the client installation package, open the hbase/conf/hbase-site.xml file and set the following parameters:

      • hbase.zookeeper.quorum: The value of this parameter is the ZK link of the cluster found in the cluster list.

        Log in to the CloudTable management console and choose Cluster Mode. In the cluster list, locate the required cluster and obtain its ZK link in the ZK Link column. See the following figure.

        Figure 3 ZK link
      • mapreduce.cluster.local.dir: Check whether the configuration item exists. If the configuration item does not exist, add it.

      The configuration example is as follows:

      <configuration>
      <property>
      <name>hbase.zookeeper.quorum</name>
      <value>xxx-zk1.cloudtable.com,xxx-zk2.cloudtable.com,xxx-zk3.cloudtable.com</value>
      </property>
      
      <property>
      <name>mapreduce.cluster.local.dir</name>
      <value>${hadoop.tmp.dir}/mapred/local</value>
      </property>
      </configuration>

  4. (Optional) Set security mode parameters.

    Perform this step only when IAM authentication is enabled during cluster creation. Otherwise, skip this step.

    1. Open the hbase/conf/hbase-site.xml file in the client installation directory.
    2. Uncomment the security parameters except hbase.zookeeper.quorum and mapreduce.cluster.local.dir.

      By default, the security parameters in the hbase-site.xml file are commented out. You need to uncomment the security parameters before configuring them.

    3. Configure the username, accesskey, and secretkey.
      • cloudtable.iam.username: Username used for creating a cluster. If the cluster is created using an account, set $user_name to an account name. If the cluster is created using an IAM user under an account, set $user_name to the IAM username.account name. An account and an IAM user are in a parent-child relationship.
      • cloudtable.iam.accesskey: AK plaintext
      • cloudtable.iam.secretkey: SK plaintext

        You can move your cursor over your account in the upper right corner and choose My Credential. Click the Access Keys tab and then the Add Access Key button to add an access key. After the access key is generated, you must download and save the key file that contains the AK plaintext and SK plaintext.

        If you fail to query the AK plaintext and SK plaintext on the interface after the generation of the access key due to some reasons, for example, loss of the AK plaintext and SK plaintext, you can add another access key to make the previous one become invalid.

      Retain the default values of other parameters.

      The configuration example is as follows:

      <configuration>
      <property>
      <name>hbase.zookeeper.quorum</name>
      <value>xxx-zk1.cloudtable.com,xxx-zk2.cloudtable.com,xxx-zk3.cloudtable.com</value>
      </property>
      
      <property>
      <name>mapreduce.cluster.local.dir</name>
      <value>${hadoop.tmp.dir}/mapred/local</value>
      </property>
      
        <property>
          <name>cloudtable.iam.username</name>
          <value></value>
        </property>
        <property>
          <name>cloudtable.iam.accesskey</name>
          <value></value>
        </property>
        <property>
          <name>cloudtable.iam.secretkey</name>
          <value></value>
        </property>
        <property>
          <name>hbase.security.authorization</name>
          <value>true</value>
        </property>
        <property>
          <name>hbase.security.authentication</name>
          <value>digest</value>
        </property>   
        <property>
          <name>hbase.rpc.protection</name>
          <value>authentication</value>
        </property>
        <property> 
          <name>cloudtable.iam.service.password.encrypted</name>  
          <value>false</value> 
        </property>  
        <property> 
          <name>hbase.client.userprovider.class</name>  
          <value>org.apache.hadoop.hbase.security.UserProviderExtend</value> 
        </property>  
        <property> 
          <name>hbase.zookeeper.custom.auth.enabled</name>  
          <value>true</value> 
        </property>  
        <property> 
          <name>hbase.zookeeper.authProvider.scheme</name>  
          <value>IAM_AK_SK</value> 
        </property>

  5. Start the shell to access the cluster.

    Run the bin/hbase shell command to start the shell to access the cluster.