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>
217 lines
32 KiB
HTML
217 lines
32 KiB
HTML
<a name="mrs_01_0442"></a><a name="mrs_01_0442"></a>
|
|
|
|
<h1 class="topictitle1">Using Hive from Scratch</h1>
|
|
<div id="body1589421621794"><p id="mrs_01_0442__p117571659182510">Hive is a data warehouse framework built on Hadoop. It maps structured data files to a database table and provides SQL-like functions to analyze and process data. It also allows you to quickly perform simple MapReduce statistics using SQL-like statements without the need of developing a specific MapReduce application. It is suitable for statistical analysis of data warehouses.</p>
|
|
<div class="section" id="mrs_01_0442__section316983143915"><h4 class="sectiontitle">Background</h4><p id="mrs_01_0442__aa6bb651d9fdc48249b2e258e8dd36987">Suppose a user develops an application to manage users who use service A in an enterprise. The procedure of operating service A on the Hive client is as follows: </p>
|
|
<p id="mrs_01_0442__p1571519492538"><strong id="mrs_01_0442__b1113472918172">Operations on common tables</strong>:</p>
|
|
<ul id="mrs_01_0442__ufb6be56b34b24b42b414a82f147e9483"><li id="mrs_01_0442__le7f87bd280e6448fb638db9a748aefdf">Create the <strong id="mrs_01_0442__b1433713308170">user_info</strong> table.</li><li id="mrs_01_0442__lee40db3e7049462584b60ba65919ab05">Add users' educational backgrounds and professional titles to the table.</li><li id="mrs_01_0442__l4f59951cb9de4db4a0920a457495ebba">Query user names and addresses by user ID. </li><li id="mrs_01_0442__l0caa82526a5a4227909b3c75691ae936">Delete the user information table after service A ends. </li></ul>
|
|
|
|
<div class="tablenoborder"><a name="mrs_01_0442__en-us_topic_0037446806_table27353390"></a><a name="en-us_topic_0037446806_table27353390"></a><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_0442__en-us_topic_0037446806_table27353390" frame="border" border="1" rules="all"><caption><b>Table 1 </b>User information</caption><thead align="left"><tr id="mrs_01_0442__en-us_topic_0037446806_row32789387"><th align="left" class="cellrowborder" valign="top" width="19.998000199980005%" id="mcps1.3.2.5.2.6.1.1"><p id="mrs_01_0442__en-us_topic_0037446806_p38694667"><strong id="mrs_01_0442__b1249433513170">ID</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="15.678432156784321%" id="mcps1.3.2.5.2.6.1.2"><p id="mrs_01_0442__en-us_topic_0037446806_p22689808"><strong id="mrs_01_0442__b1048316383176">Name</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="17.558244175582445%" id="mcps1.3.2.5.2.6.1.3"><p id="mrs_01_0442__en-us_topic_0037446806_p32089967"><strong id="mrs_01_0442__b73261939111719">Gender</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="15.2984701529847%" id="mcps1.3.2.5.2.6.1.4"><p id="mrs_01_0442__en-us_topic_0037446806_p39701876"><strong id="mrs_01_0442__b157564402174">Age</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="31.46685331466853%" id="mcps1.3.2.5.2.6.1.5"><p id="mrs_01_0442__en-us_topic_0037446806_p18747312"><strong id="mrs_01_0442__b205791941161712">Address</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_0442__en-us_topic_0037446806_row43691456"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p49347015">12005000201</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p37685299">A</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p32610412">Male</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p24197721">19</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p13858403">City A</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row57616766"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p36446461">12005000202</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p66482253">B</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p16353430">Female</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p49559423">23</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p54890288">City B</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row24250547"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p18137316">12005000203</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p59836530">C</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p14920772">Male</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p623043">26</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p50466518">City C</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row51545483"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p14434584">12005000204</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p28350637">D</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p14700275">Male</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p49871633">18</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p13070512">City D</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row50525752"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p66054074">12005000205</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p48779793">E</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p58849189">Female</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p2055005">21</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p32237730">City E</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row21704116"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p13202999">12005000206</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p62809978">F</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p54443429">Male</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p47841633">32</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p49967061">City F</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row47050372"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p52983808">12005000207</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p63830089">G</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p2854726">Female</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p29906272">29</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p6488958">City G</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row58400626"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p32830290">12005000208</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p42007851">H</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p47192740">Female</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p64515557">30</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p58377623">City H</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row55636561"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__en-us_topic_0037446806_p10267631">12005000209</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__en-us_topic_0037446806_p26371793">I</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__en-us_topic_0037446806_p55740512">Male</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__en-us_topic_0037446806_p18687619">26</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__en-us_topic_0037446806_p37302179">City I</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_0442__en-us_topic_0037446806_row175293"><td class="cellrowborder" valign="top" width="19.998000199980005%" headers="mcps1.3.2.5.2.6.1.1 "><p id="mrs_01_0442__p20275141018126">12005000210</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.678432156784321%" headers="mcps1.3.2.5.2.6.1.2 "><p id="mrs_01_0442__p7273191071210">J</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="17.558244175582445%" headers="mcps1.3.2.5.2.6.1.3 "><p id="mrs_01_0442__p12194165416015">Female</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.2984701529847%" headers="mcps1.3.2.5.2.6.1.4 "><p id="mrs_01_0442__p127221061217">25</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="31.46685331466853%" headers="mcps1.3.2.5.2.6.1.5 "><p id="mrs_01_0442__p2270910101219">City J</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="mrs_01_0442__section16880721113918"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_0442__ol11471534103911"><li id="mrs_01_0442__l6b58a848ef0f4fe6a361d4ef0ac39fb8"><a name="mrs_01_0442__l6b58a848ef0f4fe6a361d4ef0ac39fb8"></a><a name="l6b58a848ef0f4fe6a361d4ef0ac39fb8"></a><span>Download the client configuration file.</span><p><ul id="mrs_01_0442__ul67518334192"><li id="mrs_01_0442__li1475123316190">For versions earlier than MRS 3.x, perform the following operations:<ol type="a" id="mrs_01_0442__o10934933c3364550a0be5195fbfc2f32"><li id="mrs_01_0442__li1799392319436">Log in to MRS Manager. For details, see <a href="mrs_01_2123.html">Accessing Manager</a>. Then, choose <strong id="mrs_01_0442__b138441346112116">Services</strong>.</li><li id="mrs_01_0442__le025c1892e7147e290dff3b94a1d0393">Click <span class="uicontrol" id="mrs_01_0442__uicontrol13633146836"><b>Download Client</b></span>.<p id="mrs_01_0442__p6662635987">Set <span class="parmname" id="mrs_01_0442__parmname07231071731"><b>Client Type</b></span> to <span class="parmvalue" id="mrs_01_0442__parmvalue9723671136"><b>Only configuration files</b></span>, <span class="parmname" id="mrs_01_0442__parmname1172418714314"><b>Download to</b></span> to <span class="parmvalue" id="mrs_01_0442__parmvalue772415714316"><b>Server</b></span>, and click <span class="uicontrol" id="mrs_01_0442__uicontrol11724137335"><b>OK</b></span> to generate the client configuration file. The generated file is saved in the <strong id="mrs_01_0442__b872413717315">/tmp/MRS-client</strong> directory on the active management node by default.</p>
|
|
</li></ol>
|
|
</li><li id="mrs_01_0442__li2066134213204">For MRS 3.<em id="mrs_01_0442__i1361819111942">x</em> or later, perform the following operations:<ol type="a" id="mrs_01_0442__ol169871359123614"><li id="mrs_01_0442__li3986195917363">Log in to FusionInsight Manager. For details, see <a href="mrs_01_2124.html">Accessing FusionInsight Manager (MRS 3.x or Later)</a>.</li><li id="mrs_01_0442__li11986125923613">Choose <strong id="mrs_01_0442__b180745429451219">Cluster</strong> > <em id="mrs_01_0442__i12295953251219">Name of the desired cluster</em> > <strong id="mrs_01_0442__b78877487751219">Dashboard</strong> > <strong id="mrs_01_0442__b99905805451219">More</strong> > <strong id="mrs_01_0442__b20987200151219">Download Client</strong>.</li><li id="mrs_01_0442__li3987145913362">Download the cluster client.<p id="mrs_01_0442__p20987105913361"><a name="mrs_01_0442__li3987145913362"></a><a name="li3987145913362"></a>Set <span class="parmname" id="mrs_01_0442__parmname89861359103617"><b>Select Client Type</b></span> to <span class="parmvalue" id="mrs_01_0442__parmvalue1198711591367"><b>Configuration Files Only </b></span>, select a platform type, and click <span class="uicontrol" id="mrs_01_0442__uicontrol1198745973617"><b>OK</b></span> to generate the client configuration file which is then saved in the <strong id="mrs_01_0442__b18808003651219">/tmp/FusionInsight-Client/</strong> directory on the active management node by default.</p>
|
|
</li></ol>
|
|
</li></ul>
|
|
</p></li><li id="mrs_01_0442__li595112919519"><span>Log in to the active management node of Manager.</span><p><ul id="mrs_01_0442__ul166431739132314"><li id="mrs_01_0442__li11643143952314">For versions earlier than MRS 3.x, perform the following operations:<ol type="a" id="mrs_01_0442__oad0dd0b610c34488815d2b07e4656c11"><li id="mrs_01_0442__l52f4be0ff6434297a1b84c6a772a9828">On the MRS console, click <strong id="mrs_01_0442__b1510935112277">Clusters</strong>, choose <strong id="mrs_01_0442__b05255516279">Active Clusters</strong>, and click a cluster name. On the <strong id="mrs_01_0442__b1641925016220">Nodes</strong> tab, view the node names. The node whose name contains <strong id="mrs_01_0442__b2101112610234">master1</strong> is the Master1 node, and the node whose name contains <strong id="mrs_01_0442__b493853692315">master2</strong> is the Master2 node.<p id="mrs_01_0442__a2f41d2e8a2434da2a56a6f48035e2d15">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 <a href="#mrs_01_0442__le8e7045cece741e8b6209b929a50ff22">2.d</a>.</p>
|
|
</li><li id="mrs_01_0442__lad0d75a7717442b68338881c7c895c81">Log in to the Master1 node using the password as user <strong id="mrs_01_0442__b1529118518202">root</strong>. For details, see <a href="https://docs.otc.t-systems.com/en-us/usermanual/mrs/mrs_01_0083.html" target="_blank" rel="noopener noreferrer">Logging In to a Cluster</a>.</li><li id="mrs_01_0442__l96479867566a4bd59da83a86f87373ef">Run the following commands to switch to user <strong id="mrs_01_0442__b1550681893417">omm</strong>:<p id="mrs_01_0442__adbc6f7bd4142423a89ea39d9d7347674"><strong id="mrs_01_0442__b2760121812416">sudo su - root</strong></p>
|
|
<p id="mrs_01_0442__a09516e4f38e44d8085ab1e7b041fddc0"><strong id="mrs_01_0442__b1476592216414">su - omm</strong></p>
|
|
</li><li id="mrs_01_0442__le8e7045cece741e8b6209b929a50ff22"><a name="mrs_01_0442__le8e7045cece741e8b6209b929a50ff22"></a><a name="le8e7045cece741e8b6209b929a50ff22"></a>Run the following command to check the active management node of MRS Manager:<p id="mrs_01_0442__p296913416327"><a name="mrs_01_0442__le8e7045cece741e8b6209b929a50ff22"></a><a name="le8e7045cece741e8b6209b929a50ff22"></a><strong id="mrs_01_0442__b3201818417756">sh ${BIGDATA_HOME}/om-0.0.1/sbin/status-oms.sh</strong></p>
|
|
<p id="mrs_01_0442__a2e14fbc736604468bd7585d96245cd58">In the command output, the node whose <span class="parmname" id="mrs_01_0442__parmname1093914458151"><b>HAActive</b></span> is <span class="parmvalue" id="mrs_01_0442__parmvalue109409453159"><b>active</b></span> is the active management node, and the node whose <span class="parmname" id="mrs_01_0442__parmname7941154517155"><b>HAActive</b></span> is <span class="parmvalue" id="mrs_01_0442__parmvalue179421745181519"><b>standby</b></span> is the standby management node. In the following example, <strong id="mrs_01_0442__b14942345171520">mgtomsdat-sh-3-01-1</strong> is the active management node, and <strong id="mrs_01_0442__b8943845141519">mgtomsdat-sh-3-01-2</strong> is the standby management node.</p>
|
|
<pre class="screen" id="mrs_01_0442__sd906fdd3601748af837ddf8172bd0e75">Ha mode
|
|
double
|
|
NodeName HostName HAVersion StartTime HAActive HAAllResOK HARunPhase
|
|
192-168-0-30 mgtomsdat-sh-3-01-1 V100R001C01 2014-11-18 23:43:02 <strong id="mrs_01_0442__a62984b3e97d740d3bc709bb1da033a2f">active</strong> normal Actived
|
|
192-168-0-24 mgtomsdat-sh-3-01-2 V100R001C01 2014-11-21 07:14:02 <strong id="mrs_01_0442__a31f4111b8e77424caf416a08ed194aa4">standby</strong> normal Deactived</pre>
|
|
</li><li id="mrs_01_0442__lde3b2ea113c34b4687592dfdc8b454c2">Log in to the active management node as user <strong id="mrs_01_0442__b177061416181912">root</strong>, for example, node <span class="parmvalue" id="mrs_01_0442__p4fa8933886834ca8854b5d0617f23f10"><b>192-168-0-30</b></span>.</li></ol>
|
|
</li><li id="mrs_01_0442__li3485185552314">For MRS 3.<em id="mrs_01_0442__i1750117497517">x </em>or later, perform the following operations:<ol type="a" id="mrs_01_0442__ol8987145983618"><li id="mrs_01_0442__li149871159103614">Log in to any node where Manager is deployed as user <strong id="mrs_01_0442__b098755910363">root</strong>.</li><li id="mrs_01_0442__li12987185973617">Run the following command to identify the active and standby nodes:<p id="mrs_01_0442__p17987205912364"><a name="mrs_01_0442__li12987185973617"></a><a name="li12987185973617"></a><strong id="mrs_01_0442__b159872059163610">sh ${BIGDATA_HOME}/om-server/om/sbin/status-oms.sh</strong></p>
|
|
<p id="mrs_01_0442__p17987125916360">In the command output, the value of <strong id="mrs_01_0442__b21377327751219">HAActive</strong> for the active management node is <strong id="mrs_01_0442__b13290356051219">active</strong>, and that for the standby management node is <strong id="mrs_01_0442__b91799915851219">standby</strong>. In the following example, <strong id="mrs_01_0442__b172395939051219">node-master1</strong> is the active management node, and <strong id="mrs_01_0442__b8817160851219">node-master2</strong> is the standby management node.</p>
|
|
<pre class="screen" id="mrs_01_0442__screen39871559163619">HAMode
|
|
double
|
|
NodeName HostName HAVersion StartTime HAActive HAAllResOK HARunPhase
|
|
192-168-0-30 node-master1 V100R001C01 2020-05-01 23:43:02 active normal Actived
|
|
192-168-0-24 node-master2 V100R001C01 2020-05-01 07:14:02 standby normal Deactived </pre>
|
|
</li><li id="mrs_01_0442__li14987145993619">Log in to the primary management node as user <strong id="mrs_01_0442__b2947161654817">root</strong> and run the following command to switch to user <strong id="mrs_01_0442__b12947191624814">omm</strong>:<p id="mrs_01_0442__p17873182683018"><strong id="mrs_01_0442__b16162728194113">sudo su - omm</strong></p>
|
|
</li></ol>
|
|
</li></ul>
|
|
</p></li><li id="mrs_01_0442__li1325114150135"><span>Run the following command to go to the client installation directory:</span><p><p id="mrs_01_0442__p1499713212913"><strong id="mrs_01_0442__b138661758142811">cd /opt/client</strong></p>
|
|
<p id="mrs_01_0442__p924985613282">The cluster client has been installed in advance. The following client installation directory is used as an example. Change it based on the site requirements.</p>
|
|
</p></li><li id="mrs_01_0442__li15639738131312"><a name="mrs_01_0442__li15639738131312"></a><a name="li15639738131312"></a><span>Run the following command to update the client configuration for the active management node.</span><p><p id="mrs_01_0442__p365063812136"><strong id="mrs_01_0442__b9719204219357">sh refreshConfig.sh /opt/client</strong> <i><span class="varname" id="mrs_01_0442__varname1665143881313">Full path of the client configuration file package</span></i></p>
|
|
<p id="mrs_01_0442__p86531138181318">For example, run the following command:</p>
|
|
<p id="mrs_01_0442__p3654193818136"><strong id="mrs_01_0442__b14655103818135">sh refreshConfig.sh /opt/client </strong><strong id="mrs_01_0442__b2054762513449">/tmp/FusionInsight-C</strong><strong id="mrs_01_0442__b146151621525">lient/</strong><strong id="mrs_01_0442__b139102545817">FusionInsight_Cluster_1_Services_Client.tar</strong></p>
|
|
<p id="mrs_01_0442__p9659123820139">If the following information is displayed, the configurations have been updated successfully.</p>
|
|
<pre class="screen" id="mrs_01_0442__screen1866023831317"> ReFresh components client config is complete.
|
|
Succeed to refresh components client config.</pre>
|
|
<div class="note" id="mrs_01_0442__note1971123710424"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_0442__p613218111518">You can refer to Method 2 in <a href="https://docs.otc.t-systems.com/en-us/usermanual/mrs/mrs_01_0089.html" target="_blank" rel="noopener noreferrer">Updating a Client</a> to perform operations in steps <a href="#mrs_01_0442__l6b58a848ef0f4fe6a361d4ef0ac39fb8">1</a> to <a href="#mrs_01_0442__li15639738131312">4</a>.</p>
|
|
</div></div>
|
|
</p></li><li id="mrs_01_0442__l6556791324fa484e91dc201b480e3115"><span>Use the client on a Master node.</span><p><ol type="a" id="mrs_01_0442__od49292eae1f845e8a383e761ce0ce2f7"><li id="mrs_01_0442__led80939ae6024a9ba8841d649d5132b4">On the active management node, for example, <span class="parmvalue" id="mrs_01_0442__pb923e7c26e0f4bffb26f1521910a2c79"><b>192-168-0-30</b></span>, run the following command to switch to the client directory, for example, <strong id="mrs_01_0442__b189531649195119">/opt</strong><strong id="mrs_01_0442__b5953114910511"></strong><strong id="mrs_01_0442__b89531249105119">/client</strong>.<p id="mrs_01_0442__en-us_topic_0037446806_p11191414462"><strong id="mrs_01_0442__b1668485133617">cd /opt</strong><strong id="mrs_01_0442__b17686135173619">/client</strong></p>
|
|
</li><li id="mrs_01_0442__ldf91db8293354ac4beabdf4679eb0034">Run the following command to configure environment variables:<p id="mrs_01_0442__en-us_topic_0037446806_p711917124619"><a name="mrs_01_0442__ldf91db8293354ac4beabdf4679eb0034"></a><a name="ldf91db8293354ac4beabdf4679eb0034"></a><strong id="mrs_01_0442__b10953105010554">source bigdata_env</strong></p>
|
|
</li><li id="mrs_01_0442__li495913245475">If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user:<p id="mrs_01_0442__aeaf76195462f4119af05c698566aba09"><a name="mrs_01_0442__li495913245475"></a><a name="li495913245475"></a><strong id="mrs_01_0442__b09391645217">kinit</strong> <em id="mrs_01_0442__i16939545217">MRS cluster user</em></p>
|
|
<p id="mrs_01_0442__en-us_topic_0037446806_p809043511651">Example: user <strong id="mrs_01_0442__b144573521725">kinit hiveuser</strong></p>
|
|
<p id="mrs_01_0442__p676363144715">The current user must have the permission to create Hive tables. To create a role with the permission, refer to <a href="https://docs.otc.t-systems.com/en-us/usermanual/mrs/mrs_01_0343.html" target="_blank" rel="noopener noreferrer">Creating a Role</a>. To bind the role to the current user, refer to <a href="https://docs.otc.t-systems.com/en-us/usermanual/mrs/mrs_01_0345.html" target="_blank" rel="noopener noreferrer">Creating a User</a>.If Kerberos authentication is disabled, skip this step.</p>
|
|
</li><li id="mrs_01_0442__en-us_topic_0037446806_li8119414469">Run the client command of the Hive component directly.<p id="mrs_01_0442__ae866cfe594424869bd57657b6921e1a8"><a name="mrs_01_0442__en-us_topic_0037446806_li8119414469"></a><a name="en-us_topic_0037446806_li8119414469"></a><strong id="mrs_01_0442__b181391521567">beeline</strong></p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_0442__li2015821418148"><span>Run the Hive client command to implement service A.</span><p><p id="mrs_01_0442__p1185185714716"><strong id="mrs_01_0442__b1596817213318">Operations on internal tables</strong>:</p>
|
|
<ol type="a" id="mrs_01_0442__ol897653825911"><li id="mrs_01_0442__li12976638185912">Create the <strong id="mrs_01_0442__b49282232317">user_info</strong> user information table according to <a href="#mrs_01_0442__en-us_topic_0037446806_table27353390">Table 1</a> and add data to it.<p id="mrs_01_0442__p15654104164819"><strong id="mrs_01_0442__b04501946124816">create table user_info(id string,name string,gender string,age int,addr string);</strong></p>
|
|
<p id="mrs_01_0442__p426392616245">For MRS 1.<em id="mrs_01_0442__i179691855151812">x</em>, MRS 3.<em id="mrs_01_0442__i9249139197">x</em>, or later, perform the following operations:</p>
|
|
<p id="mrs_01_0442__p1165414144811"><strong id="mrs_01_0442__b134741846124818">insert into table user_info(id,name,gender,age,addr) values("12005000201","A","Male",19,"City A");</strong></p>
|
|
<p id="mrs_01_0442__p913802642515">For MRS 2.<em id="mrs_01_0442__i8506322151911">x</em>, perform the following operations:</p>
|
|
<p id="mrs_01_0442__p785884510250"><strong id="mrs_01_0442__b48581645122519">insert into table user_info values("12005000201","A","Male",19,"City A");</strong></p>
|
|
</li><li id="mrs_01_0442__li10684611801">Add users' educational backgrounds and professional titles to the <strong id="mrs_01_0442__b76874461733">user_info</strong> table.<p id="mrs_01_0442__p92235520713">For example, to add educational background and title information about user 12005000201, run the following command: </p>
|
|
<p id="mrs_01_0442__p15797125124918"><strong id="mrs_01_0442__b8436102854919">alter table user_info add columns(education string,technical string);</strong></p>
|
|
</li><li id="mrs_01_0442__li12134202514012">Query user names and addresses by user ID. <p id="mrs_01_0442__p192245520718"><a name="mrs_01_0442__li12134202514012"></a><a name="li12134202514012"></a>For example, to query the name and address of user 12005000201, run the following command:</p>
|
|
<p id="mrs_01_0442__p194503336492"><strong id="mrs_01_0442__b1060310367495">select name,addr from user_info where id='12005000201';</strong></p>
|
|
</li><li id="mrs_01_0442__li83797414013">Delete the user information table.<p id="mrs_01_0442__p7339240174916"><a name="mrs_01_0442__li83797414013"></a><a name="li83797414013"></a><strong id="mrs_01_0442__b629847154912">drop table user_info;</strong></p>
|
|
</li></ol>
|
|
<p id="mrs_01_0442__p122385512717"><strong id="mrs_01_0442__b44911519249">Operations on external partition tables</strong>:</p>
|
|
<p id="mrs_01_0442__p52319551076">Create an external partition table and import data.</p>
|
|
<ol type="a" id="mrs_01_0442__ol1218033011"><li id="mrs_01_0442__li16180193711">Create a path for storing external table data.<p id="mrs_01_0442__p11851851164916"><a name="mrs_01_0442__li16180193711"></a><a name="li16180193711"></a><strong id="mrs_01_0442__b974413532494">hdfs dfs -mkdir /hive/</strong></p>
|
|
<p id="mrs_01_0442__p1399641317440"><strong id="mrs_01_0442__b8996171319445">hdfs dfs -mkdir /hive/</strong><strong id="mrs_01_0442__b9481729104419">user_info</strong></p>
|
|
</li><li id="mrs_01_0442__li106723516">Create a table.<p id="mrs_01_0442__p11899135644918"><a name="mrs_01_0442__li106723516"></a><a name="li106723516"></a><strong id="mrs_01_0442__b17759120155020">create external table user_info(id string,name string,gender string,age int,addr string) partitioned by(year string) row format delimited fields terminated by ' ' lines terminated by '\n' stored as textfile location '/hive/user_info';</strong></p>
|
|
<div class="note" id="mrs_01_0442__n97342fa4140b46079eddb6a5ffc0c15e"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_0442__p664044323711"><strong id="mrs_01_0442__b17870153516414">fields terminated</strong> indicates delimiters, for example, spaces.</p>
|
|
<p id="mrs_01_0442__p164171425173813"><strong id="mrs_01_0442__b13995205517416">lines terminated</strong> indicates line breaks, for example, <strong id="mrs_01_0442__b305561240">\n</strong>.</p>
|
|
<p id="mrs_01_0442__p83014811213"><strong id="mrs_01_0442__b590111591045">/hive/user_info</strong> indicates the path of the data file.</p>
|
|
</div></div>
|
|
</li><li id="mrs_01_0442__li166071145919">Import data.<ol class="substepthirdol" id="mrs_01_0442__ol208399551813"><li id="mrs_01_0442__li790116533110">Execute the insert statement to insert data.<p id="mrs_01_0442__p158281248121814"><a name="mrs_01_0442__li790116533110"></a><a name="li790116533110"></a><strong id="mrs_01_0442__b103946535016">insert into user_info partition(year="2018") values ("12005000201","A","Male",19,"City A");</strong></p>
|
|
</li><li id="mrs_01_0442__li118197628">Run the <strong id="mrs_01_0442__b104308142516">load data</strong> command to import file data.<ol id="mrs_01_0442__ol33451271834"><li id="mrs_01_0442__li1796720241736">Create a file based on the data in <a href="#mrs_01_0442__en-us_topic_0037446806_table27353390">Table 1</a>. For example, the file name is <strong id="mrs_01_0442__b3239172718514">txt.log</strong>. Fields are separated by space, and the line feed characters are used as the line breaks.</li><li id="mrs_01_0442__li1155464714313">Upload the file to HDFS.<p id="mrs_01_0442__p15839722134313"><a name="mrs_01_0442__li1155464714313"></a><a name="li1155464714313"></a><strong id="mrs_01_0442__b6888113920436">hdfs dfs -put txt.log /tmp</strong></p>
|
|
</li><li id="mrs_01_0442__li69096114410">Load data to the table.<p id="mrs_01_0442__p1016010276439"><a name="mrs_01_0442__li69096114410"></a><a name="li69096114410"></a><strong id="mrs_01_0442__b143474354320">load data inpath '/tmp/txt.log' into table user_info partition (year='2011');</strong></p>
|
|
</li></ol>
|
|
</li></ol>
|
|
</li><li id="mrs_01_0442__li14540174717212">Query the imported data.<p id="mrs_01_0442__p17449531124314"><a name="mrs_01_0442__li14540174717212"></a><a name="li14540174717212"></a><strong id="mrs_01_0442__b195591144174310">select * from user_info;</strong></p>
|
|
</li><li id="mrs_01_0442__li7472135717217">Delete the user information table.<p id="mrs_01_0442__p20368335114316"><a name="mrs_01_0442__li7472135717217"></a><a name="li7472135717217"></a><strong id="mrs_01_0442__b6303144674311">drop table user_info;</strong></p>
|
|
</li><li id="mrs_01_0442__li162281716413">Run the following command to exit:<p id="mrs_01_0442__p57652212419"><a name="mrs_01_0442__li162281716413"></a><a name="li162281716413"></a><strong id="mrs_01_0442__b201952141219">!q</strong></p>
|
|
</li></ol>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0581.html">Using Hive</a></div>
|
|
</div>
|
|
</div>
|
|
|