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>
136 lines
19 KiB
HTML
136 lines
19 KiB
HTML
<a name="mrs_01_2345"></a><a name="mrs_01_2345"></a>
|
|
|
|
<h1 class="topictitle1">Using ClickHouse from Scratch</h1>
|
|
<div id="body32001227"><p id="mrs_01_2345__en-us_topic_0000001173470770_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__en-us_topic_0000001173470770_section19493164011271"><h4 class="sectiontitle">Prerequisites</h4><p id="mrs_01_2345__en-us_topic_0000001173470770_p1797113171213">You have installed the client, for example, in the <strong id="mrs_01_2345__en-us_topic_0000001173470770_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__en-us_topic_0000001173470770_section10873172642318"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_2345__en-us_topic_0000001173470770_ol11471534103911"><li id="mrs_01_2345__en-us_topic_0000001173470770_li10269200102512"><span>Log in to the node where the client is installed as the client installation user.</span></li><li id="mrs_01_2345__en-us_topic_0000001173470770_li4269903251"><span>Run the following command to go to the client installation directory:</span><p><p id="mrs_01_2345__en-us_topic_0000001173470770_p1526916017259"><strong id="mrs_01_2345__en-us_topic_0000001173470770_b426990122515">cd /opt/hadoopclient</strong></p>
|
|
</p></li><li id="mrs_01_2345__en-us_topic_0000001173470770_li172699012517"><span>Run the following command to configure environment variables:</span><p><p id="mrs_01_2345__en-us_topic_0000001173470770_p172694017259"><strong id="mrs_01_2345__en-us_topic_0000001173470770_b16269180122520">source bigdata_env</strong></p>
|
|
</p></li><li id="mrs_01_2345__en-us_topic_0000001173470770_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. For details about how to bind a role to the user, see <a href="mrs_01_24057.html">ClickHouse User and Permission Management</a>. If Kerberos authentication is disabled for the current cluster, skip this step.</span><p><p id="mrs_01_2345__en-us_topic_0000001173470770_p137512579492"><strong id="mrs_01_2345__en-us_topic_0000001173470770_b1520521045010">kinit</strong> <em id="mrs_01_2345__en-us_topic_0000001173470770_i1133611425013">Component service user</em></p>
|
|
<p id="mrs_01_2345__en-us_topic_0000001173470770_p77201452184920">Example: <strong id="mrs_01_2345__en-us_topic_0000001173470770_b5415656172418">kinit clickhouseuser</strong></p>
|
|
</p></li><li id="mrs_01_2345__en-us_topic_0000001173470770_li4140746493"><span>Run the client command of the ClickHouse component.</span><p><p id="mrs_01_2345__en-us_topic_0000001173470770_p810916801">Run the <strong id="mrs_01_2345__en-us_topic_0000001173470770_b12230959202120">clickhouse -h</strong> command to view the command help of ClickHouse.</p>
|
|
<p id="mrs_01_2345__en-us_topic_0000001173470770_p7654143617221">The command output is as follows:</p>
|
|
<pre class="screen" id="mrs_01_2345__en-us_topic_0000001173470770_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__en-us_topic_0000001173470770_p512181516012">The following table describes the parameters when the <strong id="mrs_01_2345__en-us_topic_0000001173470770_b118871959182213">clickhouse client</strong> command is used to connect to the ClickHouse server.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_2345__en-us_topic_0000001173470770_table646417462051" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters of the clickhouse client command</caption><thead align="left"><tr id="mrs_01_2345__en-us_topic_0000001173470770_row446411461751"><th align="left" class="cellrowborder" valign="top" width="17.4%" id="mcps1.3.3.2.5.2.5.2.3.1.1"><p id="mrs_01_2345__en-us_topic_0000001173470770_p6464346752">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="82.6%" id="mcps1.3.3.2.5.2.5.2.3.1.2"><p id="mrs_01_2345__en-us_topic_0000001173470770_p64642461255">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_2345__en-us_topic_0000001173470770_row164645467513"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p946412461259">--host</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p11464104618514">Host name of the server. The default value is <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1478972055616">localhost</strong>. You can use the host name or IP address of the node where the ClickHouse instance is located.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row3464134617515"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p94649461356">--port</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p7891216173520">Port for connection.</p>
|
|
<ul id="mrs_01_2345__en-us_topic_0000001173470770_ul55751848193817"><li id="mrs_01_2345__en-us_topic_0000001173470770_li1357512485381">If the SSL security connection is used, the default port number is <strong id="mrs_01_2345__en-us_topic_0000001173470770_b44303742324930">9440</strong>, the parameter <strong id="mrs_01_2345__en-us_topic_0000001173470770_b20983564724930">--secure</strong> must be carried. For details about the port number, search for the <span class="parmname" id="mrs_01_2345__en-us_topic_0000001173470770_parmname155751648123819"><b>tcp_port_secure</b></span> parameter in the ClickHouseServer instance configuration.</li><li id="mrs_01_2345__en-us_topic_0000001173470770_li65752048133816">If non-SSL security connection is used, the default port number is <strong id="mrs_01_2345__en-us_topic_0000001173470770_b45734768724930">9000</strong>, the parameter <strong id="mrs_01_2345__en-us_topic_0000001173470770_b203335843724930">--secure</strong> does not need to be carried. For details about the port number, search for the <strong id="mrs_01_2345__en-us_topic_0000001173470770_b6203392054">tcp_port</strong> parameter in the ClickHouseServer instance configuration.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row11464446658"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p246417461559">--user</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p18880426194017">Username.</p>
|
|
<p id="mrs_01_2345__en-us_topic_0000001173470770_p19464134619511">You can create the user on Manager and bind a role to the user. For details, see <a href="mrs_01_24057.html">ClickHouse User and Permission Management</a>.</p>
|
|
<ul id="mrs_01_2345__en-us_topic_0000001173470770_ul157443218395"><li id="mrs_01_2345__en-us_topic_0000001173470770_li1560565519488">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__en-us_topic_0000001173470770_b115325324715">--user</strong> and <strong id="mrs_01_2345__en-us_topic_0000001173470770_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__en-us_topic_0000001173470770_li534717528426">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 is used for the first time, you need to log in to Manager to change the password. If the user and password parameters are not carried, user <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1950520185716">default</strong> is used for login by default.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row12464446959"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p174641461151">--password</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1198318751314">Password. The default password is an empty string. This parameter is used together with the <strong id="mrs_01_2345__en-us_topic_0000001173470770_b630883965320">--user</strong> parameter. You can set a password when creating a user on Manager.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row346494610516"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1246419468511">--query</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p030452011318">Query to process when using non-interactive mode.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row1746418464512"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p16464946450">--database</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p11464746559">Current default database. The default value is <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1397432910355">default</strong>, which is the default configuration on the server.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row1746444616514"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1464134618519">--multiline</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p5464846358">If this parameter is specified, multiline queries are allowed. (<strong id="mrs_01_2345__en-us_topic_0000001173470770_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__en-us_topic_0000001173470770_row746419461659"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p134643461555">--multiquery</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1246484613510">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__en-us_topic_0000001173470770_row134641446156"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p15464124611517">--format</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p104641046959">Specified default format used to output the result.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row44642462512"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1646416462051">--vertical</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p124649462515">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__en-us_topic_0000001173470770_row74647461857"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p15464046857">--time</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p11464124610516">If this parameter is specified, the query execution time is printed to <strong id="mrs_01_2345__en-us_topic_0000001173470770_b740611214012">stderr</strong> in non-interactive mode.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row44641846357"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p14648461951">--stacktrace</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p6464104611515">If this parameter is specified, stack trace information will be printed when an exception occurs.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row746416461951"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p94652468518">--config-file</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1546514467510">Name of the configuration file.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row10465246250"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p1246518460517">--secure</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p64652461557">If this parameter is specified, the server will be connected in SSL mode.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row15465246851"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p10465246550">--history_file</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p946520469510">Path of files that record command history.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2345__en-us_topic_0000001173470770_row836913351275"><td class="cellrowborder" valign="top" width="17.4%" headers="mcps1.3.3.2.5.2.5.2.3.1.1 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p7370143514711">--param_<name></p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="82.6%" headers="mcps1.3.3.2.5.2.5.2.3.1.2 "><p id="mrs_01_2345__en-us_topic_0000001173470770_p73707351879">Query with parameters. Pass values from the client to the server. </p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<ul id="mrs_01_2345__en-us_topic_0000001173470770_ul14596144004313"><li id="mrs_01_2345__en-us_topic_0000001173470770_li1059615403432">Using SSL for login when Kerberos authentication is disabled for the current cluster:<p id="mrs_01_2345__en-us_topic_0000001173470770_p6172164415715"><a name="mrs_01_2345__en-us_topic_0000001173470770_li1059615403432"></a><a name="en-us_topic_0000001173470770_li1059615403432"></a><strong id="mrs_01_2345__en-us_topic_0000001173470770_b122033551571">clickhouse client --host </strong><em id="mrs_01_2345__en-us_topic_0000001173470770_i5203175595712">IP address of the ClickHouse instance </em><strong id="mrs_01_2345__en-us_topic_0000001173470770_b1177415569458">--user </strong><em id="mrs_01_2345__en-us_topic_0000001173470770_i19151577459">Username</em><strong id="mrs_01_2345__en-us_topic_0000001173470770_b1131903461"> --password </strong><em id="mrs_01_2345__en-us_topic_0000001173470770_i223412020465">Password</em><strong id="mrs_01_2345__en-us_topic_0000001173470770_b1831302464"> --port </strong>9440 <strong id="mrs_01_2345__en-us_topic_0000001173470770_b33551029125815">--secure</strong></p>
|
|
</li></ul>
|
|
<ul id="mrs_01_2345__en-us_topic_0000001173470770_ul4226164219439"><li id="mrs_01_2345__en-us_topic_0000001173470770_li11226942134315">Using SSL for login when Kerberos authentication is enabled for the current cluster:<p id="mrs_01_2345__en-us_topic_0000001173470770_p16251311718"><a name="mrs_01_2345__en-us_topic_0000001173470770_li11226942134315"></a><a name="en-us_topic_0000001173470770_li11226942134315"></a>You must create a user on Manager because there is no default user. For details, see <a href="mrs_01_24057.html">ClickHouse User and Permission Management</a>.</p>
|
|
<p id="mrs_01_2345__en-us_topic_0000001173470770_p19768858465">After the user authentication is successful, you do not need to carry the <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1076732417325">--user</strong> and <strong id="mrs_01_2345__en-us_topic_0000001173470770_b207681124193211">--password</strong> parameters when logging in to the client as the authenticated user.</p>
|
|
<p id="mrs_01_2345__en-us_topic_0000001173470770_p676815581061"><strong id="mrs_01_2345__en-us_topic_0000001173470770_b18768155811613">clickhouse client --host </strong><em id="mrs_01_2345__en-us_topic_0000001173470770_i1876820581565">IP address of the ClickHouse instance</em><strong id="mrs_01_2345__en-us_topic_0000001173470770_b15768158168"> --port </strong>9440 <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1676811581064">--secure</strong></p>
|
|
</li></ul>
|
|
<div class="note" id="mrs_01_2345__en-us_topic_0000001173470770_note1375961741617"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_2345__en-us_topic_0000001173470770_p8386192542315">You can log in to FusionInsight Manager and choose <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1792453918358">Cluster</strong> > <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1692523993511">Services</strong> > <strong id="mrs_01_2345__en-us_topic_0000001173470770_b992623983513">ClickHouse</strong> > <strong id="mrs_01_2345__en-us_topic_0000001173470770_b1892643910358">Instance</strong> to obtain the service IP address of the ClickHouseServer instance.</p>
|
|
</div></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>
|
|
|