@@ -6,7 +6,7 @@ By going through this tutorial you'll learn how to set up basic ClickHouse clust
## Single Node Setup
To postpone complexities of distributed environment, we'll start with deploying ClickHouse on a single server or virtual machine. ClickHouse is usually installed from [deb](index.md#from-deb-packages) or [rpm](index.md#from-rpm-packages) packages, but there are [alternatives](index.md#from-docker-image) for the operating systems that do no support them.
To postpone complexities of distributed environment, we'll start with deploying ClickHouse on a single server or virtual machine. ClickHouse is usually installed from [deb](index.md#install-from-deb-packages) or [rpm](index.md#from-rpm-packages) packages, but there are [alternatives](index.md#from-docker-image) for the operating systems that do no support them.
For example, you have chosen `deb` packages and executed:
Data compression settings for [MergeTree](../table_engines/mergetree.md)-engine tables.
!!! warning
Don't use it if you have just started using ClickHouse.
The configuration looks like this:
Configuration template:
```xml
<compression>
<case>
<parameters/>
<min_part_size>...</min_part_size>
<min_part_size_ratio>...</min_part_size_ratio>
<method>...</method>
</case>
...
</compression>
```
You can configure multiple sections `<case>`.
`<case>` fields:
Block field `<case>`:
-`min_part_size` – The minimum size of a data part.
-`min_part_size_ratio` – The ratio of the data part size to the table size.
-`method` – Compression method. Acceptable values: `lz4` or `zstd`.
-``min_part_size`` – The minimum size of a table part.
-``min_part_size_ratio`` – The ratio of the minimum size of a table part to the full size of the table.
-``method`` – Compression method. Acceptable values : ``lz4`` or ``zstd``(experimental).
You can configure multiple `<case>` sections.
ClickHouse checks `min_part_size` and `min_part_size_ratio` and processes the `case` blocks that match these conditions. If none of the `<case>` matches, ClickHouse applies the `lz4` compression algorithm.
Actions when conditions are met:
- If a data part matches a condition set, ClickHouse uses the specified compression method.
- If a data part matches multiple condition sets, ClickHouse uses the first matched condition set.
If no conditions met for a data part, ClickHouse uses the `lz4` compression.
**Example**
...
...
@@ -140,10 +147,10 @@ Settings:
- interval – The interval for sending, in seconds.
- timeout – The timeout for sending data, in seconds.
- root_path – Prefix for keys.
- metrics – Sending data from a[system.metrics](../system_tables.md#system_tables-metrics) table.
- events – Sending deltas data accumulated for the time period from a[system.events](../system_tables.md#system_tables-events) table.
- events_cumulative – Sending cumulative data from a[system.events](../system_tables.md#system_tables-events) table.
- asynchronous_metrics – Sending data from a[system.asynchronous_metrics](../system_tables.md#system_tables-asynchronous_metrics) table.
- metrics – Sending data from the[system.metrics](../system_tables.md#system_tables-metrics) table.
- events – Sending deltas data accumulated for the time period from the[system.events](../system_tables.md#system_tables-events) table.
- events_cumulative – Sending cumulative data from the[system.events](../system_tables.md#system_tables-events) table.
- asynchronous_metrics – Sending data from the[system.asynchronous_metrics](../system_tables.md#system_tables-asynchronous_metrics) table.
You can configure multiple `<graphite>` clauses. For instance, you can use this for sending different data at different intervals.
ClickHouse uses multiple threads when reading from [MergeTree](../table_engines/mergetree.md) tables. This setting turns on/off the uniform distribution of reading tasks over the working threads. The algorithm of the uniform distribution aims to make execution time for all the threads approximately equal in a `SELECT` query.
If the number of rows to be read from a file of a [MergeTree](../table_engines/mergetree.md) table exceeds `merge_tree_min_rows_for_concurrent_read` then ClickHouse tries to perform a concurrent reading from this file on several threads.
@@ -129,7 +129,7 @@ Defines storage time for values. Can be specified only for MergeTree-family tabl
### Column Compression Codecs {#codecs}
By default, ClickHouse applies the compression method, defined in [server settings](../operations/server_settings/settings.md#compression), to columns. You can also define the compression method for each individual column in the `CREATE TABLE` query.
By default, ClickHouse applies the `lz4` compression method. For `MergeTree`-engine family you can change the default compression method in the [compression](../operations/server_settings/settings.md#server-settings-compression) section of a server configuration. You can also define the compression method for each individual column in the `CREATE TABLE` query.
```sql
CREATETABLEcodec_example
...
...
@@ -151,10 +151,10 @@ If a codec is specified, the default codec doesn't apply. Codecs can be combined
Compression is supported for the following table engines:
-[MergeTree](../operations/table_engines/mergetree.md) family
-[Log](../operations/table_engines/log_family.md) family
-[Set](../operations/table_engines/set.md)
-[Join](../operations/table_engines/join.md)
-[MergeTree](../operations/table_engines/mergetree.md) family. Supports column compression codecs and selecting the default compression method by [compression](../operations/server_settings/settings.md#server-settings-compression) settings.
-[Log](../operations/table_engines/log_family.md) family. Uses the `lz4` compression method by default and supports column compression codecs.
-[Set](../operations/table_engines/set.md). Only supported the default compression.
-[Join](../operations/table_engines/join.md). Only supported the default compression.
ClickHouse supports common purpose codecs and specialized codecs.
-`port` – The port on the MySQL server. You can specify it for all replicas, or for each one individually (inside `<replica>`).
-`user` – Name of the MySQL user. You can specify it for all replicas, or for each one individually (inside `<replica>`).
-`password` – Password of the MySQL user. You can specify it for all replicas, or for each one individually (inside `<replica>`).
-`replica` – Section of replica configurations. There can be multiple sections.
-`replica/host` – The MySQL host.
\* `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority.
- `replica/host` – The MySQL host.
- `replica/priority` – The replica priority. When attempting to connect, ClickHouse traverses the replicas in order of priority. The lower the number, the higher the priority.
-`db` – Name of the database.
-`table` – Name of the table.
-`where ` – The selection criteria. Optional parameter.
-`where ` – The selection criteria. The syntax for conditions is the same as for `WHERE` clause in MySQL, for example, `id > 10 AND id < 20`. Optional parameter.
-`invalidate_query` – Query for checking the dictionary status. Optional parameter. Read more in the section [Updating dictionaries](external_dicts_dict_lifetime.md).
MySQL can be connected on a local host via sockets. To do this, set `host` and `socket`.
This query tries to initialize an unscheduled merge of data parts for tables with a table engine from the [MergeTree](../operations/table_engines/mergetree.md) family. Other kinds of table engines aren't supported.
This query tries to initialize an unscheduled merge of data parts for tables with a table engine from the [MergeTree](../operations/table_engines/mergetree.md) family.
The `OPTMIZE` query is also supported for the [MaterializedView](../operations/table_engines/materializedview.md) and the [Buffer](../operations/table_engines/buffer.md) engines. Other table engines aren't supported.
When `OPTIMIZE` is used with the [ReplicatedMergeTree](../operations/table_engines/replication.md) family of table engines, ClickHouse creates a task for merging and waits for execution on all nodes (if the `replication_alter_partitions_sync` setting is enabled).
@@ -107,7 +107,7 @@ The `FROM` clause specifies the source to read data from:
`ARRAY JOIN` and the regular `JOIN` may also be included (see below).
Instead of a table, the `SELECT` subquery may be specified in parenthesis.
In contrast to standard SQL, a synonym does not need to be specified after a subquery. For compatibility, it is possible to write `AS name` after a subquery, but the specified name isn't used anywhere.
In contrast to standard SQL, a synonym does not need to be specified after a subquery.
To execute a query, all the columns listed in the query are extracted from the appropriate table. Any columns not needed for the external query are thrown out of the subqueries.
If a query does not list any columns (for example, `SELECT count() FROM t`), some column is extracted from the table anyway (the smallest one is preferred), in order to calculate the number of rows.
-`port` - порт сервера MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`user` - имя пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`password` - пароль пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`replica` - блок конфигурации реплики. Блоков может быть несколько.
- `replica/host` - хост MySQL.
\* `replica/priority` - приоритет реплики. При попытке соединения ClickHouse обходит реплики в соответствии с приоритетом. Чем меньше цифра, тем выше приоритет.
-`invalidate_query` - запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external_dicts_dict_lifetime.md).
-`port` — порт сервера MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`user` — имя пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`password` — пароль пользователя MySQL. Можно указать для всех реплик или для каждой в отдельности (внутри `<replica>`).
-`replica` — блок конфигурации реплики. Блоков может быть несколько.
- `replica/host` — хост MySQL.
- `replica/priority` — приоритет реплики. При попытке соединения ClickHouse обходит реплики в соответствии с приоритетом. Чем меньше цифра, тем выше приоритет.
-`db` — имя базы данных.
-`table` — имя таблицы.
-`where` — условие выбора. Синтаксис условия совпадает с синтаксисом секции `WHERE` в MySQL, например, `id > 10 AND id < 20`. Необязательный параметр.
-`invalidate_query` — запрос для проверки статуса словаря. Необязательный параметр. Читайте подробнее в разделе [Обновление словарей](external_dicts_dict_lifetime.md).
MySQL можно подключить на локальном хосте через сокеты, для этого необходимо задать `host` и `socket`.