HBase is a column-based distributed storage system that features high reliability, performance, and scalability. This section describes how to use HBase from scratch, including how to update the client on the Master node in the cluster, create a table using the client, insert data in the table, modify the table, read data from the table, delete table data, and delete the table.
Suppose a user develops an application to manage users who use service A in an enterprise. The procedure of operating service A on the HBase client is as follows:
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 |
The client has been installed. For example, the client is installed in the /opt/client directory. The client directory in the following operations is only an example. Change it to the actual installation directory. Before using the client, download and update the client configuration file, and ensure that the active management node of Manager is available.
For versions earlier than MRS 3.x, perform the following operations:
Set Client Type to Only configuration files, Download To 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. You can customize the file path.
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 active management node of MRS Manager. For details about the command, see 2.d.
sudo su - root
su - omm
sh ${BIGDATA_HOME}/om-0.0.1/sbin/status-oms.sh
In the command output, the node whose HAActive is active is the active management node, and the node whose HAActive is standby is the standby management node. In the following example, mgtomsdat-sh-3-01-1 is the active management node, and mgtomsdat-sh-3-01-2 is the standby management node.
Ha mode double NodeName HostName HAVersion StartTime HAActive HAAllResOK HARunPhase 192-168-0-30 mgtomsdat-sh-3-01-1 V100R001C01 2019-11-18 23:43:02 active normal Actived 192-168-0-24 mgtomsdat-sh-3-01-2 V100R001C01 2019-11-21 07:14:02 standby normal Deactived
sudo su - omm
cd /opt/client
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 configurations have been updated successfully.
ReFresh components client config is complete. Succeed to refresh components client config.
cd /opt/client
For example, kinit hbaseuser.
create 'user_info',{NAME => 'i'}
For example, to add information about the user whose ID is 12005000201, run the following commands:
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'
For example, to add educational background and title information about user 12005000201, run the following commands:
put 'user_info','12005000201','i:degree','master'
put 'user_info','12005000201','i:pose','manager'
For example, to query the name and address of user 12005000201, run the following command:
scan'user_info',{STARTROW=>'12005000201',STOPROW=>'12005000201',COLUMNS=>['i:name','i:address']}
For example, to query information about user A, run the following command:
scan'user_info',{FILTER=>"SingleColumnValueFilter('i','name',=,'binary:A')"}
All user data needs to be deleted. For example, to delete data of user 12005000201, run the following command:
delete'user_info','12005000201','i'
drop 'user_info'
For MRS 3.x or later, perform the following operations:
For example, kinit hbaseuser.
create 'user_info',{NAME => 'i'}
For example, to add information about the user whose ID is 12005000201, run the following commands:
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'
For example, to add educational background and title information about user 12005000201, run the following commands:
put 'user_info','12005000201','i:degree','master'
put 'user_info','12005000201','i:pose','manager'
For example, to query the name and address of user 12005000201, run the following command:
scan'user_info',{STARTROW=>'12005000201',STOPROW=>'12005000201',COLUMNS=>['i:name','i:address']}
For example, to query information about user A, run the following command:
scan'user_info',{FILTER=>"SingleColumnValueFilter('i','name',=,'binary:A')"}
All user data needs to be deleted. For example, to delete data of user 12005000201, run the following command:
delete'user_info','12005000201','i'
drop 'user_info'