• MapReduce Service

mrs
  1. Help Center
  2. MapReduce Service
  3. User Guide
  4. Using MRS
  5. Using HBase from Scratch

Using HBase from Scratch

HBase is a scalable column-based distributed storage system. It features high reliability and high performance.

You can update the client on a Master node in the mrs_20160907 cluster. The client can be used to create a table, data can be inserted to, read, and deleted from the table, and the table can be modified and deleted.

Background

After an MRS cluster has been successfully created, the original client is by default stored in the /opt/client directory on all nodes in the cluster. Before using the client, download the client file, update the client, and locate the active management node of MRS Manager.

For example, if a user develops an application to manage information about users who use service A in an enterprise, the operation processes of service A using the HBase client are as follows:

  • Create a user information table.
  • Add diplomas and titles of users to the table.
  • Query usernames and addresses by user ID.
  • Query information by username.
  • Deregister users and delete user data.
  • Delete the user information table after service A ends.
Table 1 User information

ID

Name

Gender

Age

Address

12005000201

A

Male

19

City A

12005000202

B

Female

23

City B

12005000203

C

Male

26

City C

12005000204

D

Male

18

City D

12005000205

E

Female

21

City E

12005000206

F

Male

32

City F

12005000207

G

Female

29

City G

12005000208

H

Female

30

City H

12005000209

I

Male

26

City I

12005000210

J

Male

25

City J

Procedure

  1. Download the client file or the client configuration file.

    1. Log in to the MRS management console. In the navigation tree on the left, choose Clusters > Active Clusters and click the cluster named mrs_20160907. The mrs_20160907 cluster was created in section Creating a Cluster.
    2. In the Cluster List > mrs_20160907 area, click View to open MRS Manager.
    3. Click Service, and click Download Client.

      Set Client Type to All client files or Only configuration files, set Download Path to Server, and click OK to generate the client file or the client configuration file. The generated file is saved in the /tmp/MRS-client directory on the active management node by default. You can modify the file save path as required.

  2. Log in to the active management node.

    1. In the Cluster List > mrs_20160907Choose Clusters > Active Clusters and click the cluster named mrs_20160907. In the Cluster List > mrs_20160907 area to view the Active Master Node IP Address parameter. Active Master Node IP Address is the IP address of the active Master node in a cluster, which is also the IP address of the active management node of MRS Manager.

      The active and standby management nodes of MRS Manager are installed on Master nodes by default. Because Master1 and Master2 are switched over in active and standby mode, Master1 is not always the active management node of MRS Manager.

    2. Log in to the Master1 node using a password as user linux. For details, see Logging In to an ECS Using VNC in the User Guide.

      The Master node supports Cloud-init. The preset username for Cloud-init is linux. The password is randomly generated and is displayed on the VNC login page by default. If you have changed the password, log in to the node using the new password. See "How Do I Log In to an ECS Once All Images Support Cloud-Init?" in the Elastic Cloud Server User Guide (FAQs > Login FAQs > How Do I Log In to an ECS Once All Images Support Cloud-Init?).

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

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

    After an MRS cluster is successfully created, the client is installed in the /opt/client directory by default.

    cd /opt/client

  4. Run the following command to update the client configuration for the active management node.

    Switch to user omm.

    sudo su - omm

    sh refreshConfig.sh /opt/client Full path of the client configuration file package

    For example, run the following command:

    sh refreshConfig.sh /opt/client /tmp/MRS-Client/MRS_Services_Client.tar

    If the following information is displayed, the configuration is updated successfully.

    ReFresh components client config is complete.
    Succeed to refresh components client config.

  5. Use the client on a Master node.

    1. On the active management node where the client is updated, for example, node-master2-LJXDj, run the following command to go to the client directory.

      cd /opt/client

    2. Run the following command to configure environment variables.

      source bigdata_env

    3. If the Kerberos authentication is enabled for the current cluster, run the following command to authenticate users. If the Kerberos authentication is disabled for the current cluster, skip this step.

      kinit MRS cluster user

      For example, kinit admin.

    4. Run an HBase component client command directly.

      hbase shell

  6. Run commands on the HBase client to implement service A.

    1. Create a user information table according to Table 1 and add data to it.

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

      For example, to add data of user 12005000201, run the following commands in sequence:

      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 degree and title information about the user to the table.

      For example, to add degree and title information about user 12005000201, run the following commands:

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

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

    3. Query usernames and addresses by user ID.

      For example, to query the username and address of user 12005000201, run the following command:

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

    4. Query information by username.

      For example, to query information about user A, run the following command:

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

    5. Delete user data from the user information table.

      All user data needs to be deleted. For example, to delete data of user 12005000201, run the following command:

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

    6. Run the following command to delete the user information table.

      disable'user_info';drop 'user_info'

  7. Terminate a cluster.

    For details, see Terminating a Cluster in the User Guide.