Help Center > > User Guide> MRS Cluster Component Operation Guide> Using HBase> Using HBase from Scratch

Using HBase from Scratch

Updated at: Apr 28, 2020 GMT+08:00

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.

Prerequisites

You have administrator rights on MRS Manager.

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 and update the client configuration 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 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 Custom Purchase of a Cluster.
    2. Click Components.

      For MRS 2.0.1 or earlier, log in to MRS Manager. For details, see Accessing MRS Manager. Then, choose Services.

    3. Click Download Client.

      Set Client Type to Only configuration files, set Save Path to Server, and click OK to generate the client configuration file. The generated file is saved in the /tmp/MRS-client directory on the active management node by default.

      Figure 1 Downloading client configuration files

  2. Log in to the active management node.

    1. In the Cluster List > mrs_20160907 area, select Node to view the Name parameter. The node that contains master1 in its name is the Master1 node. The node that contains master2 in its name is the Master2 node.

      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. Run a command in Master1 to check whether Master1 is the active management node of MRS Manager. For details about the command, see 2.d.

    2. Log in to the Master1 node using a password as user root. For details, see Logging In to an ECS in the User Guide.
    3. Run the following command to switch to user omm.

      sudo su - root

      su - omm

    4. Run the following command to confirm the active and standby management nodes.

      sh ${BIGDATA_HOME}/om-0.0.1/sbin/status-oms.sh | grep Actived

      For example, the following information is displayed. node-master2-LJXDj indicates the name of the active management node.

      192-168-1-17                             node-master2-LJXDj                       V100R001C01              2016-10-01 06:58:41      active               normal               Actived

      If the Master1 node to which you have logged in is the standby management node and you need to log in to the active management node, run the following command:

      ssh IP address of the Master2 node

      ssh name of the active management node

      For example, run the following command: ssh node-master2-LJXDj

    5. Log in to the active management node, for example, node node-master2-LJXDj, 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.

    For clusters of MRS 1.8.5 or later, you can also refer to method 2 in Updating a Client to perform operations in 1 to 4.

  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 Kerberos authentication has been enabled for the current cluster, run the following command to authenticate the current user. The current user must have a permission to create HBase tables. For details about how to configure a role with the corresponding permission, see Creating a Role. For details about how to bind a role to a user, see Creating a User. If the Kerberos authentication is disabled for the current cluster, skip this step.

      kinit MRS cluster user

      For example, kinit admin.

    4. Run the client command of the HBase component directly.

      hbase shell

  6. Run the HBase client command 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.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel