forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
89 lines
11 KiB
HTML
89 lines
11 KiB
HTML
<a name="bakmrs_01_0368"></a><a name="bakmrs_01_0368"></a>
|
|
|
|
<h1 class="topictitle1">Using an HBase Client</h1>
|
|
<div id="body1589421623016"><div class="section" id="bakmrs_01_0368__sa6f26f4d73194c3aac199d5a2504b08f"><h4 class="sectiontitle">Scenario</h4><p id="bakmrs_01_0368__a80ed03e166a14d7a9e27f1ab5764815b">This section describes how to use the HBase client in an O&M scenario or a service scenario. </p>
|
|
</div>
|
|
<div class="section" id="bakmrs_01_0368__s575f22d757a24b5a85a68692161d0106"><h4 class="sectiontitle">Prerequisites</h4><ul id="bakmrs_01_0368__uce02bcdf50bd49c2a1001424a760b54d"><li id="bakmrs_01_0368__l2913522dc1fe42828e88d99a723b4425">The client has been installed. For example, the installation directory is <strong id="bakmrs_01_0368__b1924363120212">/opt/hadoopclient</strong>. The client directory in the following operations is only an example. Change it to the actual installation directory.</li><li id="bakmrs_01_0368__li7951192245213">Service component users are created by the administrator as required.<p id="bakmrs_01_0368__p19651142335210"><a name="bakmrs_01_0368__li7951192245213"></a><a name="li7951192245213"></a>A machine-machine user needs to download the <strong id="bakmrs_01_0368__b13981165245914">keytab</strong> file and a human-machine user needs to change the password upon the first login.</p>
|
|
</li><li id="bakmrs_01_0368__lec21f4a28e144c91a3ac3e06df7378c3">If a non-<strong id="bakmrs_01_0368__b2518355135919">root</strong> user uses the HBase client, ensure that the owner of the HBase client directory is this user. Otherwise, run the following command to change the owner.<p id="bakmrs_01_0368__a2f48aa1f1a4645759a151003f23702e0"><strong id="bakmrs_01_0368__b1958219203019">chown user:group -R</strong> <em id="bakmrs_01_0368__i15829201108">Client installation directory</em><strong id="bakmrs_01_0368__b145824201003">/HBase</strong></p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="bakmrs_01_0368__section639319572712"><h4 class="sectiontitle">Using the HBase Client (Versions Earlier Than MRS 3.x)</h4><ol id="bakmrs_01_0368__ol76958414108"><li id="bakmrs_01_0368__li10695204119102"><span><span id="bakmrs_01_0368__ph44771027132215">Log in to the node where the client is installed as the client installation user.</span></span></li><li id="bakmrs_01_0368__li136952418109"><span>Run the following command to go to the client directory:</span><p><p id="bakmrs_01_0368__p1269510411103"><strong id="bakmrs_01_0368__b869512411101">cd </strong><strong id="bakmrs_01_0368__b157211325183516">/opt/hadoopclient</strong></p>
|
|
</p></li><li id="bakmrs_01_0368__li19695641171013"><span>Run the following command to configure environment variables:</span><p><p id="bakmrs_01_0368__p196957418108"><strong id="bakmrs_01_0368__b069513417106">source bigdata_env</strong></p>
|
|
</p></li><li id="bakmrs_01_0368__li469524110108"><span>If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables. If Kerberos authentication is disabled for the current cluster, skip this step.</span><p><p id="bakmrs_01_0368__p17695194111019"><strong id="bakmrs_01_0368__b1715425013334">kinit</strong> <em id="bakmrs_01_0368__i131541250123316">Component service user</em></p>
|
|
<p id="bakmrs_01_0368__p15695541101011">For example, <strong id="bakmrs_01_0368__b883514496253">kinit hbaseuser</strong>.</p>
|
|
</p></li><li id="bakmrs_01_0368__li2696141171010"><span>Run the following HBase client command:</span><p><p id="bakmrs_01_0368__p8696441111019"><strong id="bakmrs_01_0368__b1696164151011">hbase shell</strong></p>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="bakmrs_01_0368__section3155145073312"><h4 class="sectiontitle">Using the HBase Client (MRS 3.x or Later)</h4><ol id="bakmrs_01_0368__ol19318181333814"><li id="bakmrs_01_0368__li194307243615"><span><span id="bakmrs_01_0368__ph143175231703">Log in to the node where the client is installed as the client installation user.</span></span></li><li id="bakmrs_01_0368__li531819136388"><span>Run the following command to go to the client directory:</span><p><p id="bakmrs_01_0368__p982511593812"><strong id="bakmrs_01_0368__b315455003318">cd </strong><strong id="bakmrs_01_0368__b153863129369">/opt/hadoopclient</strong></p>
|
|
</p></li><li id="bakmrs_01_0368__li19319113103813"><span>Run the following command to configure environment variables:</span><p><p id="bakmrs_01_0368__p3781918183810"><strong id="bakmrs_01_0368__b915445016330">source bigdata_env</strong></p>
|
|
</p></li><li id="bakmrs_01_0368__li17257440185215"><span>If you use the client to connect to a specific HBase instance in a scenario where multiple HBase instances are installed, run the following command to load the environment variables of the instance. Otherwise, skip this step. For example, to load the environment variables of the HBase2 instance, run the following command:</span><p><p id="bakmrs_01_0368__p17601184675220"><strong id="bakmrs_01_0368__b960284613521">source HBase2/component_env</strong></p>
|
|
</p></li><li id="bakmrs_01_0368__li15319191383810"><span>If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables. If Kerberos authentication is disabled for the current cluster, skip this step.</span><p><p id="bakmrs_01_0368__p2294112143814"><strong id="bakmrs_01_0368__b1542189069">kinit</strong> <em id="bakmrs_01_0368__i255069682">Component service user</em></p>
|
|
<p id="bakmrs_01_0368__p13135324163810">For example, <strong id="bakmrs_01_0368__b253865026">kinit hbaseuser</strong>.</p>
|
|
</p></li><li id="bakmrs_01_0368__li15319111315384"><span>Run the following HBase client command:</span><p><p id="bakmrs_01_0368__p18581162753813"><strong id="bakmrs_01_0368__b11551509336">hbase shell</strong></p>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="bakmrs_01_0368__section105048910387"><h4 class="sectiontitle">Common HBase client commands</h4><div class="p" id="bakmrs_01_0368__p153791717133810">The following table lists common HBase client commands.
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="bakmrs_01_0368__table25854914381" frame="border" border="1" rules="all"><caption><b>Table 1 </b>HBase client commands</caption><thead align="left"><tr id="bakmrs_01_0368__row558413963813"><th align="left" class="cellrowborder" valign="top" width="19.36%" id="mcps1.3.5.2.1.2.3.1.1"><p id="bakmrs_01_0368__p458415973817">Command</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="80.64%" id="mcps1.3.5.2.1.2.3.1.2"><p id="bakmrs_01_0368__p115847943810">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="bakmrs_01_0368__row185847917385"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p155840910385">create</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p175845943820">Used to create a table, for example, <strong id="bakmrs_01_0368__b13584139193813">create 'test', 'f1', 'f2', 'f3'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row1358513910387"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p358439103812">disable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p155841199381">Used to disable a specified table, for example, <strong id="bakmrs_01_0368__b458417912388">disable 'test'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row11585129193811"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p175854917387">enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p165851097380">Used to enable a specified table, for example, <strong id="bakmrs_01_0368__b1358559123820">enable 'test'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row45856911382"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p95852916383">alter</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p75857915383">Used to alter the table structure. You can run the <strong id="bakmrs_01_0368__b3837104620281">alter</strong> command to add, modify, or delete column family information and table-related parameter values, for example, <strong id="bakmrs_01_0368__b15851999389">alter 'test', {NAME => 'f3', METHOD => 'delete'}</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row1058515923811"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p55856933811">describe</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p05851792382">Used to obtain the table description, for example, <strong id="bakmrs_01_0368__b05852918380">describe 'test'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row558599203810"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p758599133812">drop</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p17585993386">Used to delete a specified table, for example, <strong id="bakmrs_01_0368__b76131127182911">drop 'test'</strong>. Before deleting a table, you must stop it.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row1658510943814"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p15858916383">put</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p1558516912386">Used to write the value of a specified cell, for example, <strong id="bakmrs_01_0368__b4313135020296">put 'test','r1','f1:c1','myvalue1'</strong>. The cell location is unique and determined by the table, row, and column.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row125859913382"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p45854903813">get</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p35851093384">Used to get the value of a row or the value of a specified cell in a row, for example, <strong id="bakmrs_01_0368__b558549153819">get 'test','r1'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="bakmrs_01_0368__row16585129193817"><td class="cellrowborder" valign="top" width="19.36%" headers="mcps1.3.5.2.1.2.3.1.1 "><p id="bakmrs_01_0368__p175859963812">scan</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80.64%" headers="mcps1.3.5.2.1.2.3.1.2 "><p id="bakmrs_01_0368__p65859983811">Used to query table data, for example, <strong id="bakmrs_01_0368__b8350142019312">scan 'test'</strong>. The table name and scanner must be specified in the command.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0500.html">Using HBase</a></div>
|
|
</div>
|
|
</div>
|
|
|