Yang, Tong 6182f91ba8 MRS component operation guide_normal 2.0.38.SP20 version
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>
2022-12-09 14:55:21 +00:00

140 lines
16 KiB
HTML

<a name="mrs_01_2345"></a><a name="mrs_01_2345"></a>
<h1 class="topictitle1">Using ClickHouse from Scratch</h1>
<div id="body1604391372180"><p id="mrs_01_2345__p60515119">ClickHouse is a column-based database oriented to online analysis and processing. It supports SQL query and provides good query performance. The aggregation analysis and query performance based on large and wide tables is excellent, which is one order of magnitude faster than other analytical databases.</p>
<div class="section" id="mrs_01_2345__section19493164011271"><h4 class="sectiontitle">Prerequisites</h4><p id="mrs_01_2345__p1797113171213">You have installed the client, for example, in the <strong id="mrs_01_2345__b333512265199">/opt/hadoopclient</strong> 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.</p>
</div>
<div class="section" id="mrs_01_2345__section10873172642318"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_2345__ol11471534103911"><li id="mrs_01_2345__li10269200102512"><span>Log in to the node where the client is installed as the client installation user.</span></li><li id="mrs_01_2345__li4269903251"><span>Run the following command to go to the client installation directory:</span><p><p id="mrs_01_2345__p1526916017259"><strong id="mrs_01_2345__b426990122515">cd /opt/hadoopclient</strong></p>
</p></li><li id="mrs_01_2345__li172699012517"><span>Run the following command to configure environment variables:</span><p><p id="mrs_01_2345__p172694017259"><strong id="mrs_01_2345__b16269180122520">source bigdata_env</strong></p>
</p></li><li id="mrs_01_2345__li1910333418475"><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 ClickHouse tables. If Kerberos authentication is disabled for the current cluster, skip this step.</span><p><ol type="a" id="mrs_01_2345__ol105001049105617"><li id="mrs_01_2345__li548233014217">Run the following command if it is an MRS 3.1.0 cluster:<p id="mrs_01_2345__p19505331423"><a name="mrs_01_2345__li548233014217"></a><a name="li548233014217"></a><strong id="mrs_01_2345__b5766124418552">export CLICKHOUSE_SECURITY_ENABLED=true</strong></p>
</li><li id="mrs_01_2345__li89311551185611"><strong id="mrs_01_2345__b138092211013">kinit</strong> <em id="mrs_01_2345__i1338116224014">Component service user</em><p id="mrs_01_2345__p23600116552">Example: <strong id="mrs_01_2345__b5415656172418">kinit clickhouseuser</strong></p>
</li></ol>
</p></li><li id="mrs_01_2345__li4140746493"><span>Run the client command of the ClickHouse component.</span><p><p id="mrs_01_2345__p810916801">Run the <strong id="mrs_01_2345__b12230959202120">clickhouse -h</strong> command to view the command help of ClickHouse.</p>
<p id="mrs_01_2345__p7654143617221">The command output is as follows:</p>
<pre class="screen" id="mrs_01_2345__screen7455131342216">Use one of the following commands:
clickhouse local [args]
clickhouse client [args]
clickhouse benchmark [args]
clickhouse server [args]
clickhouse performance-test [args]
clickhouse extract-from-config [args]
clickhouse compressor [args]
clickhouse format [args]
clickhouse copier [args]
clickhouse obfuscator [args]
...</pre>
<p id="mrs_01_2345__p5413219205">Run the <strong id="mrs_01_2345__b5876333141">clickhouse client</strong> command to connect to the ClickHouse serverif MRS 3.1.0 or later.</p>
<ul id="mrs_01_2345__ul14596144004313"><li id="mrs_01_2345__li8264734203213">Command for using SSL to log in to a ClickHouse cluster with Kerberos authentication disabled<p id="mrs_01_2345__p32645349321"><a name="mrs_01_2345__li8264734203213"></a><a name="li8264734203213"></a><strong id="mrs_01_2345__b726413418329">clickhouse client --host </strong><em id="mrs_01_2345__i102642344327">IP address of the ClickHouse instance</em><strong id="mrs_01_2345__b3264103463212">--user </strong><em id="mrs_01_2345__i5264123412328">Username</em><strong id="mrs_01_2345__b1726473414323"> --password</strong><strong id="mrs_01_2345__b22644349320"> --port </strong>9440 <strong id="mrs_01_2345__b102651734153220">--secure</strong></p>
<p id="mrs_01_2345__p433157193319"><em id="mrs_01_2345__i18827480348">Enter the user password.</em></p>
</li></ul>
<ul id="mrs_01_2345__ul4226164219439"><li id="mrs_01_2345__li11226942134315">Using SSL for login when Kerberos authentication is enabled for the current cluster:<p id="mrs_01_2345__p16251311718"><a name="mrs_01_2345__li11226942134315"></a><a name="li11226942134315"></a>You must create a user on Manager because there is no default user.</p>
<p id="mrs_01_2345__p19768858465">After the user authentication is successful, you do not need to carry the <strong id="mrs_01_2345__b1076732417325">--user</strong> and <strong id="mrs_01_2345__b207681124193211">--password</strong> parameters when logging in to the client as the authenticated user.</p>
<p id="mrs_01_2345__p676815581061"><strong id="mrs_01_2345__b18768155811613">clickhouse client --host </strong><em id="mrs_01_2345__i1876820581565">IP address of the ClickHouse instance</em><strong id="mrs_01_2345__b15768158168"> --port </strong>9440 <strong id="mrs_01_2345__b1676811581064">--secure</strong></p>
<p id="mrs_01_2345__p320316519213">The following table describes the parameters of the <strong id="mrs_01_2345__b338016219179">clickhouse client</strong> command.</p>
</li></ul>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_2345__table119111511421" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters of the <strong id="mrs_01_2345__b1336617718159">clickhouse client</strong> command</caption><thead align="left"><tr id="mrs_01_2345__row20911551726"><th align="left" class="cellrowborder" valign="top" width="17.4%" id="mcps1.3.3.2.5.2.7.2.3.1.1"><p id="mrs_01_2345__p139119514212">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="82.6%" id="mcps1.3.3.2.5.2.7.2.3.1.2"><p id="mrs_01_2345__p69113512213">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_2345__row109120510213"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p149129515210">--host</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p391265116215">Host name of the server. The default value is <strong id="mrs_01_2345__b1478972055616">localhost</strong>. You can use the host name or IP address of the node where the ClickHouse instance is located.</p>
<div class="note" id="mrs_01_2345__note1375961741617"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="mrs_01_2345__p8386192542315">You can log in to FusionInsight Manager and choose <strong id="mrs_01_2345__b1792453918358">Cluster</strong> &gt; <strong id="mrs_01_2345__b1692523993511">Services</strong> &gt; <strong id="mrs_01_2345__b992623983513">ClickHouse</strong> &gt; <strong id="mrs_01_2345__b1892643910358">Instance</strong> to obtain the service IP address of the ClickHouseServer instance.</p>
</div></div>
</td>
</tr>
<tr id="mrs_01_2345__row16912115113219"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p6912135116212">--port</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p14912155110214">Port for connection.</p>
<ul id="mrs_01_2345__ul591217510216"><li id="mrs_01_2345__li591214518214">If the SSL security connection is used, the default port number is <strong id="mrs_01_2345__b44303742324930">9440</strong>, the parameter <strong id="mrs_01_2345__b20983564724930">--secure</strong> must be carried. For details about the port number, search for the <span class="parmname" id="mrs_01_2345__parmname155751648123819"><b>tcp_port_secure</b></span> parameter in the ClickHouseServer instance configuration.</li><li id="mrs_01_2345__li14912155111219">If non-SSL security connection is used, the default port number is <strong id="mrs_01_2345__b45734768724930">9000</strong>, the parameter <strong id="mrs_01_2345__b203335843724930">--secure</strong> does not need to be carried. For details about the port number, search for the <strong id="mrs_01_2345__b6203392054">tcp_port</strong> parameter in the ClickHouseServer instance configuration.</li></ul>
</td>
</tr>
<tr id="mrs_01_2345__row69122514219"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p891210511522">--user</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p209121751323">Username.</p>
<p id="mrs_01_2345__p119121251324">You can create the user on Manager and bind a role to the user.</p>
<ul id="mrs_01_2345__ul189139517212"><li id="mrs_01_2345__li129135511823">If Kerberos authentication is enabled for the current cluster and the user authentication is successful, you do not need to carry the <strong id="mrs_01_2345__b115325324715">--user</strong> and <strong id="mrs_01_2345__b13832195614473">--password</strong> parameters when logging in to the client as the authenticated user. You must create a user with this name on Manager because there is no default user in the Kerberos cluster scenario.</li><li id="mrs_01_2345__li1991355118219">If Kerberos authentication is not enabled for the current cluster, you can specify a user and its password created on Manager when logging in to the client. If the user and password parameters are not carried, user <strong id="mrs_01_2345__b1950520185716">default</strong> is used for login by default.<p id="mrs_01_2345__p5542613182515">The user in normal mode (Kerberos authentication disabled) is the default user, or you can create an administrator using the open source capability provided by the ClickHouse community. You cannot use the users created on FusionInsight Manager.</p>
</li></ul>
</td>
</tr>
<tr id="mrs_01_2345__row8913175113212"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p891375117214">--password</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p16922351923">Password. The default password is an empty string. This parameter is used together with the <strong id="mrs_01_2345__b630883965320">--user</strong> parameter. You can set a password when creating a user on Manager.</p>
</td>
</tr>
<tr id="mrs_01_2345__row1092265118219"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p119225512214">--query</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p179223516217">Query to process when using non-interactive mode.</p>
</td>
</tr>
<tr id="mrs_01_2345__row1592217511225"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p19221551421">--database</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p8922151827">Current default database. The default value is <strong id="mrs_01_2345__b1397432910355">default</strong>, which is the default configuration on the server.</p>
</td>
</tr>
<tr id="mrs_01_2345__row6922115116212"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p199224511022">--multiline</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p1092220511625">If this parameter is specified, multiline queries are allowed. (<strong id="mrs_01_2345__b1579724834019">Enter</strong> only indicates line feed and does not indicate that the query statement is complete.)</p>
</td>
</tr>
<tr id="mrs_01_2345__row1992245115217"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p49236511726">--multiquery</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p15923251226">If this parameter is specified, multiple queries separated with semicolons (;) can be processed. This parameter is valid only in non-interactive mode.</p>
</td>
</tr>
<tr id="mrs_01_2345__row1792314519216"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p1192320511621">--format</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p1192314511221">Specified default format used to output the result.</p>
</td>
</tr>
<tr id="mrs_01_2345__row99236515210"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p392311512214">--vertical</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p13923851528">If this parameter is specified, the result is output in vertical format by default. In this format, each value is printed on a separate line, which helps to display a wide table.</p>
</td>
</tr>
<tr id="mrs_01_2345__row1923105118211"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p69239516220">--time</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p14923251123">If this parameter is specified, the query execution time is printed to <strong id="mrs_01_2345__b740611214012">stderr</strong> in non-interactive mode.</p>
</td>
</tr>
<tr id="mrs_01_2345__row1292318515213"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p15923185117213">--stacktrace</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p17923551123">If this parameter is specified, stack trace information will be printed when an exception occurs.</p>
</td>
</tr>
<tr id="mrs_01_2345__row2923195117220"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p2923165115217">--config-file</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p59231751824">Name of the configuration file.</p>
</td>
</tr>
<tr id="mrs_01_2345__row169231511325"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p1492312511129">--secure</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p1892316518213">If this parameter is specified, the server will be connected in SSL mode.</p>
</td>
</tr>
<tr id="mrs_01_2345__row129231511426"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p20923105119211">--history_file</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p992319510214">Path of files that record command history.</p>
</td>
</tr>
<tr id="mrs_01_2345__row169231151920"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.7.2.3.1.1 "><p id="mrs_01_2345__p209231151825">--param_&lt;name&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.7.2.3.1.2 "><p id="mrs_01_2345__p292345113211">Query with parameters. Pass values from the client to the server. </p>
</td>
</tr>
</tbody>
</table>
</div>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_2344.html">Using ClickHouse</a></div>
</div>
</div>