[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for ClickHouse®](../index.md) > FAQ > All questions on one page

# FAQ about Managed Service for ClickHouse®


### General questions {#toc-general}

* [What is Managed Service for ClickHouse®?](#what-is)

* [What is ClickHouse® used for? Which DBMS should I select?](#why-ch)

* [What is the role of Managed Service for ClickHouse® in database management and maintenance?](#services)

* [When to use Managed Service for ClickHouse® and when database VMs?](#mdb-advantage)

* [What is a database host and database cluster?](#what-is-cluster)

* [How do I get started with Managed Service for ClickHouse®?](#quickstart})

* [How many database hosts can there be in a cluster?](#how-many-hosts)

* [How can I access a running database host?](#db-access)

* [How many clusters can I create within a single cloud?](#db-limit)

* [How are database clusters maintained?](#service-window)

* [How do I edit external dictionaries?](#external-dict)

* [Which ClickHouse® version does Managed Service for ClickHouse® use?](#dbms-version)

* [Which ClickHouse® version should I choose?](#choose-version)

* [What happens when a new DBMS version is released?](#new-version)

* [What happens when a DBMS version becomes deprecated?](#dbms-deprecated)

* [How do you calculate usage cost for a database host?](#db-cost)

* [How much does it cost to use my cluster?](#cluster-cost)

* [How can I change the computing resources and storage size for a database cluster?](#resources-change)

* [How can I fix the no permission error when attaching a service account to a cluster?](#attach-service-account)

* [What block size is used on the cluster disks?](#block-size)

* [Does the service comply with the Russian Federal Law 152-FZ on personal data?](#fz-152)

* [How do I get the logs of my activity in the Yandex Cloud services?](#logs)

### Questions about ClickHouse® {#toc-clickhouse}

* [Why should I use ClickHouse® in Managed Service for ClickHouse® rather than my own VM-based installation?](#clickhouse-advantages-vm)

* [When should I use ClickHouse® rather than PostgreSQL?](#clickhouse-advantages-pg)

* [How do I load data into ClickHouse®?](#load-data)

* [How do I load a large data volume into ClickHouse®?](#loadalot)

* [What will happen to my cluster if one of its nodes fails?](#node-out)

* [Can I deploy a ClickHouse® database cluster in multiple availability zones?](#multiple-az)

* [How does replication work for ClickHouse®?](#zookeeper-access)

* [Why does my ClickHouse® cluster use three extra hosts?](#why-does-a-cluster-take-up-3-hosts-more-than-it-should)

* [How does ClickHouse® handles data deletion based on TTL?](#how-ttl-data-processing-works)

* [Can I use JSON data for tables in ClickHouse®?](#how-to-use-json)

* [Why is my cluster slow even though the computing resources are not fully utilized?](#throttling)

### Connection {#toc-connection}

* [Can I connect to individual ClickHouse® hosts?](#connect-node)

* [Is it possible to specify any port for inter-server communication when executing distributed requests?](#connect-port)

* [Why cannot I connect to a host from the internet?](#fail-connection)

* [How do I connect to a non-public host in Yandex Cloud?](#private-host)

* [Can I connect to a public cluster without SSL?](#without-ssl)

* [Why do I get an `UNEXPECTED_PACKET_FROM_SERVER` error when trying to connect?](#unexpected-packet)

* [Can I connect to cluster hosts over SSH or get superuser privileges on hosts?](#connect-ssh)

* [What should I do if I get a revocation check error when obtaining an SSL certificate via PowerShell?](#get-ssl-error)

### Updating a cluster {#toc-cluster-update}

* [How do I add a host to a cluster?](#add-host)

* [Can I set join_use_nulls to 1 using the CLI?](#join-use-nulls)

* [Will my cluster be unavailable during an update?](#update-availability)

* [How do I change the time zone?](#timezone)

* [Will my cluster be unavailable when adding replicas?](#add-replica-availability)

* [How do I grant read-only permissions to a user?](#readonly)

* [How do I increase the memory limit?](#memory-limit)

* [Can I change a network and subnets?](#network)

* [How do I change the distribution of data across shards in a cluster?](#resharding)

### Cluster settings {#toc-cluster-settings}

* [How do I create a user to access a cluster from DataLens with read-only permissions?](#datalens-readonly)

* [How do I grant a user permissions to create and delete tables or databases?](#create-delete-role)

* [How do I find out the internal_replication setting value?](#internal-replication)

* [How do I increase the maximum amount of RAM to run a query?](#max-memory-usage)

* [Why must a Managed Service for ClickHouse® cluster have three or five ZooKeeper hosts?](#zookeeper-hosts-number)

### Moving and restoring a cluster {#toc-cluster-backups}

* [How are ClickHouse® databases backed up?](#backup-overview)

* [Are database host backups enabled by default?](#default-backup)

* [When does a backup run? Is a database cluster available during backups?](#backup-window)

* [How many backups does Managed Service for ClickHouse® store? For how long?](#how-many-backups)

* [Can I delete a backup?](#delete-backup)

* [Can I change the automatic backup retention period?](#backup-retain-days)

* [What does a daily backup include?](#daily-backups)

* [Why does it take a long time to restore a cluster from a backup?](#long-restore)

* [How do I move an existing ClickHouse® cluster to Yandex Cloud?](#migration)

* [Can I restore a shard from a backup into a shard in an existing cluster?](#shard-to-shard)

### Monitoring and logs {#toc-monitoring}

* [What metrics and processes can be monitored?](#monitoring-metrics)

* [How is log storage billed?](#logging-pricing)

* [How longs are logs retained?](#log-keeping)

* [How do I monitor free storage space on ZooKeeper hosts?](#zookeeper-storage)

* [How do I monitor space taken up by data in hybrid storage?](#hybrid)

* [How do I set up an alert to signal when my disk space is a certain percentage full?](#disk-space-percentage)

## General questions {#general}

#### What is Managed Service for ClickHouse®? {#what-is}

Managed Service for ClickHouse® is a solution that helps you create, operate, and scale ClickHouse® databases in the cloud.

With Managed Service for ClickHouse®, you can:
- Create a database with performance tailored to your needs.
- Scale computing power and dedicated storage capacity for your databases as needed.
- Get database logs.

Managed Service for ClickHouse® handles the heavy lifting of ClickHouse® infrastructure management:
- Monitors your resource consumption.
- Performs automated database backups.
- Ensures [high availability](../concepts/high-availability.md) through automatic failover to standby replicas.
- Keeps your database software up-to-date.

You can work with a Managed Service for ClickHouse® database cluster the same way as with your regular local database. Thus, you can manage internal database settings to meet your application requirements.

#### What is ClickHouse® used for? Which DBMS should I select? {#why-ch}

ClickHouse® is designed primarily for analytics (OLAP) and only supports adding and reading data. You can update data but with [certain limitations](https://stackoverflow.com/questions/37901642/updating-data-in-clickhouse). For other purposes, you might want to use another DBMS.

#### What is the role of Managed Service for ClickHouse® in database management and maintenance? {#services}

When you create clusters, Managed Service for ClickHouse® allocates resources, installs the DBMS, and creates databases.

For all created and running databases, Managed Service for ClickHouse® automatically creates backups as well as applies DBMS patches and updates.

Furthermore, Managed Service for ClickHouse® ensures data replication across database hosts, both within and across [availability zones](../../overview/concepts/geo-scope.md), with automatic failover to a standby replica if a failure occurs.

Be mindful of what is managed by the service and what, by the Yandex Cloud customer. Understanding these zones of control makes you an efficient user of cloud resources and helps avoid potential database-related issues. For more information, see [Zones of control between managed database (MDB) service users and Yandex Cloud](../../overview/concepts/mdb-responsibilities.md).

#### When to use Managed Service for ClickHouse® and when to use database VMs? {#mdb-advantage}

Yandex Cloud offers two ways to work with databases:

- With Managed Service for ClickHouse®, you can use template databases, with no administrative effort required.
- With Yandex Compute Cloud virtual machines, you can create and customize your own databases. This approach allows you to use any database management system, connect to databases over SSH, and many more.

#### What is a database host and database cluster? {#what-is-cluster}

A _database host_ is a cloud-based isolated database environment with dedicated computing resources and reserved storage capacity.

A _database cluster_ consists of one or more database hosts with configurable replication across them.

#### How do I get started with Managed Service for ClickHouse®? {#quickstart}

Managed Service for ClickHouse® is available to all registered Yandex Cloud users.

Before creating a database cluster in Managed Service for ClickHouse®, you need to decide on its configuration:

- [Host class](../concepts/instance-types.md) that will determine your computing power, i.e., vCPUs, RAM, and more.
- Storage size (fully reserved when creating the cluster).
- Network for your cluster.
- Number of hosts in your cluster and availability zone for each host.

For more details, see [Getting started](../quickstart.md).

#### How many database hosts can a cluster contain? {#how-many-hosts}


The minimum number of hosts in a cluster depends on the following:
    
  * [Storage type](../concepts/storage.md):

    * At least three hosts for non-replicated SSDs (`network-ssd-nonreplicated`).

    * At least two hosts for local SSDs (`local-ssd`).

    * At least one host for the following disk types:

      * Network HDDs (`network-hdd`)
      * Network SSDs (`network-ssd`)
      * Ultra high-speed network SSDs with three replicas (`network-ssd-io-m3`)

  * Cluster sharding. When sharding is enabled, you need to multiply the minimum number of hosts for the selected disk type by the number of shards.

    For more information on the features and limitations of sharding in ClickHouse®, see [this article](../concepts/sharding.md).


The maximum number of hosts per cluster cannot exceed the set limits.

For more information, see [Quotas and limits](../concepts/limits.md).

#### How can I access a running database host? {#db-access}

You can connect to Managed Service for ClickHouse® databases using conventional DBMS methods.

Learn more about connecting to clusters in [this guide](../operations/connect/index.md).

#### How many clusters can I create within a single cloud? {#db-limit}

To learn more about technical and organizational limitations of MDB, see [Quotas and limits](../concepts/limits.md).

#### How are database clusters maintained? {#service-window}

Maintenance in Managed Service for ClickHouse® includes:

- Automatic installation of DBMS updates and patches for all hosts, even disabled ones.
- Changes in the host class and storage size.
- Other Managed Service for ClickHouse® maintenance tasks.

For more information, see [Maintenance](../concepts/maintenance.md).

#### How do I edit external dictionaries? {#external-dict}

To rename a dictionary, run this query:

```sql
RENAME DICTIONARY <dictionary_name> TO <new_name>
```

For other changes, use the [update](../api-ref/Cluster/update.md) API method.

#### Which ClickHouse® version does Managed Service for ClickHouse® use? {#dbms-version}

Managed Service for ClickHouse® uses multiple latest stable versions of ClickHouse®. For more information, see [ClickHouse® versioning policy](../concepts/update-policy.md).

#### Which ClickHouse® version should I choose? {#choose-version}

We recommend the latest available LTS version of ClickHouse®. For more information, see [ClickHouse® versioning policy](../concepts/update-policy.md).

#### What happens when a new DBMS version is released? {#new-version}

When new minor versions are released, the cluster software is automatically updated after a short testing period. 

Owners of affected database clusters get advance notice of the upcoming maintenance schedule and database availability. 

#### What happens when a DBMS version becomes deprecated? {#dbms-deprecated}

When a DBMS version becomes deprecated, Managed Service for ClickHouse® automatically sends email notifications to the owners of database clusters created with this version.

For clusters with a deprecated DBMS version, there is no option to create new hosts or restore from backups. Clusters running a deprecated ClickHouse® version are updated according to the [versioning policy](../concepts/update-policy.md).

Owners of affected database clusters get advance notice of upcoming maintenance and database availability.

#### How do you calculate usage cost for a database host? {#db-cost}

In Managed Service for ClickHouse®, the usage cost is calculated based on the following:

- Selected host class.
- Reserved storage capacity for the database host.
- Size of database cluster backups. You are not charged for storing backups up to your storage size. Backup storage exceeding this limit is charged according to our [pricing policy](../pricing.md).
- Database host uptime in hours. Partial hours are rounded to the nearest whole hour. For the cost per hour of operation for each host class, see our [pricing policy](../pricing.md).

#### How much does it cost to use my cluster? {#cluster-cost}

In the [management console](https://console.yandex.cloud), navigate to the folder dashboard, select **Managed Service for&nbsp;ClickHouse**, and click the cluster you need. On the right side of the screen, you will see the cluster usage cost per month. For more information, see the [pricing policy](../pricing.md).

#### How can I change the computing resources and storage size for a database cluster? {#resources-change}

You can scale your computing resources and storage size directly in the management console by selecting a different host class for your cluster.

The cluster settings will update within 30 minutes. This window may also be used for other maintenance activities, such as installing updates.

#### How can I fix the no permission error when attaching a service account to a cluster? {#attach-service-account}

#### How can I fix the no permission error when connecting a service account to the cluster? {#attach-service-account}

Error message:

```text
ERROR: rpc error: code = PermissionDenied desc = you do not have permission to access the requested service account or service account does not exist
```

The error occurs in the following cases:

* You are creating or modifying a cluster and linking it to a service account.
* You are restoring a cluster linked to a service account from its backup.

To fix this error, [assign](../../iam/operations/roles/grant.md) your Yandex Cloud account the [iam.serviceAccounts.user](../../iam/security/index.md#iam-serviceAccounts-user) role or higher.

#### What block size is used on the cluster disks? {#block-size}

[Block](https://en.wikipedia.org/wiki/Block_(data_storage)) size for all disk types is 4 KB.

#### Does the service meet the requirements of the Russian Federation Federal Law 152-FZ on personal data? {#fz-152}

Yes, it does. You can read the full security audit conclusion [here](https://storage.yandexcloud.net/yc-compliance/conformance_en_pdp.pdf).

#### Can I get logs of my operations in Yandex Cloud? {#logs}

Yes, you can request information about operations with your resources from Yandex Cloud logs. Do it by contacting [support](https://center.yandex.cloud/support).

## Questions about ClickHouse® {#clickhouse}

#### Why should I use ClickHouse® in Managed Service for ClickHouse® rather than my own VM-based installation? {#clickhouse-advantages-vm}

Managed Service for ClickHouse® automates routine database maintenance:

* Quick DB deployment with the required available resources.

* Data backup.

* Regular software updates.

* Ensuring [high availability](../concepts/high-availability.md) of database clusters.

* Database usage monitoring and statistics.

#### When should I use ClickHouse® rather than PostgreSQL? {#clickhouse-advantages-pg}

ClickHouse® only supports adding and reading data since it is primarily designed for analytics (OLAP). For other purposes, you might want to use PostgreSQL.

#### How do I load data into ClickHouse®? {#load-data}

Use the `INSERT` statement described in [this ClickHouse® guide](https://clickhouse.com/docs/enen/sql-reference/statements/insert-into).

#### How do I load a large data volume into ClickHouse®? {#loadalot}

Use the [CLI](https://clickhouse.com/docs/enen/interfaces/cli) to efficiently compress data when transferring it (we recommend issuing no more than one `INSERT` command per second).

Currently, data transfer from physical media is not supported.

#### What will happen to my cluster if one of its nodes fails? {#node-out}

DB clusters consist of at least two replicas, so if one node is down, the cluster will keep running.

You may lose data only if a node with a [non-replicated table](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/replication) fails.

#### Can I deploy a ClickHouse® database cluster in multiple availability zones? {#multiple-az}

Yes. A database cluster may consist of hosts residing in different availability [zones](../../overview/concepts/geo-scope.md) or even regions.

#### How does replication work for ClickHouse®? {#zookeeper-access}

Managed Service for ClickHouse® clusters use ClickHouse® Keeper or ZooKeeper for replication. In both cases, to ensure replication and [high availability](../concepts/high-availability.md), a minimum of three ClickHouse® Keeper or ZooKeeper hosts are created in the cluster.

#### Why does my ClickHouse® cluster use three extra hosts? {#why-does-a-cluster-take-up-3-hosts-more-than-it-should}

When you create a ClickHouse® cluster of two or more hosts, Managed Service for ClickHouse® automatically creates three hosts for the selected coordination service,ClickHouse® Keeper or ZooKeeper, to manage replication and high availability. These hosts are counted towards both the cloud [resource quota](https://console.yandex.cloud/cloud?section=quotas) and the cluster cost. By default, ClickHouse® Keeper or ZooKeeper hosts come with the minimum [host class](../concepts/instance-types.md).

For more information on using ZooKeeper, see [this ClickHouse® guide](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/replication).

#### How does ClickHouse® handles data deletion based on TTL? {#how-ttl-data-processing-works}

With [TTL](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl), data is deleted in [parts](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes) or during merges rather than in rows.

Deleting entire data parts is more efficient and uses less server resources, but requires the TTL expression and [partitioning key](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/custom-partitioning-key) to match or be of the same granularity for all rows in a data part.

Deleting data during merges uses more resources and takes place either along with regular background merges or during unscheduled merges. Merge frequency is defined by the `merge_with_ttl_timeout` parameter, which indicates the minimum time in seconds before a repeat merge to process data with expired TTL. You set this parameter when [creating](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-creating-a-table) the table. The default value is 14,400 seconds (4 hours).

We recommend managing data with TTL so that old data is always deleted in data parts. To do this, set [ttl_only_drop_parts](https://clickhouse.com/docs/enen/operations/settings/settings#ttl_only_drop_parts) to `true` when creating tables.

#### Can I use JSON data for tables in ClickHouse®? {#how-to-use-json}

Yes, you can. However, JSON is currently an experimental data type in ClickHouse®. To allow creating tables of this type, run this query:

```sql
SET allow_experimental_object_type=1;
```

{% note info %}

The `SET` queries are [not supported](../operations/web-sql-query.md#query-restrictions-in-the-management-console) when connecting to a cluster via the management console. To run such a query, use a different cluster connection method, e.g., [via clickhouse-client](../operations/connect/clients.md#clickhouse-client).

Make sure you have the latest client version installed.

{% endnote %}

For more information, see [this ClickHouse® guide](https://clickhouse.com/docs/enen/sql-reference/data-types/newjson).

#### Why is my cluster slow even though the computing resources are not fully utilized? {#throttling}

Your storage may have insufficient maximum [IOPS and bandwidth](../../compute/concepts/storage-read-write.md) to process the current number of requests. In this case, [throttling](../../compute/concepts/storage-read-write.md#throttling) occurs, which degrades the entire cluster performance.

The maximum IOPS and bandwidth values increase by a fixed value when the storage size increases by a certain step. The step and increment values depend on the disk type:

| Disk type                  | Step, GB | Max IOPS increase (read/write) | Max bandwidth increase (read/write), MB/s |
|-----------------------------|---------|------------------------------------|-----------------------------------------------|
| `network-hdd`               | 256     | 300/300                            | 30/30                                         |
| `network-ssd`               | 32      | 1,000/1,000                          | 15/15                                         |
| `network-ssd-nonreplicated`, `network-ssd-io-m3` | 93      | 28,000/5,600                         | 110/82                                        |

To increase the maximum IOPS and bandwidth values and make throttling less likely, expand the storage when [updating your cluster](../operations/update.md#change-disk-size).

If you are using the `network-hdd` storage, consider switching to `network-ssd` or `network-ssd-nonreplicated` by [restoring the cluster](../operations/cluster-backups.md#restore) from a backup.

## Connection {#connection}

#### Can I connect to individual ClickHouse® hosts? {#connect-node}

Yes. You can connect to ClickHouse® cluster hosts:

* Using the [HTTPS interface](https://clickhouse.com/docs/enen/interfaces/http):
    * Via an encrypted SSL connection on port 8443.
    * Without encryption on port 8123.

* Using the [command-line client](https://clickhouse.com/docs/enen/interfaces/cli):
    * Via an encrypted SSL connection on port 9440.
    * Without encryption on port 9000.

SSH connections are not supported.

#### Can I specify a custom port for inter-server communication when running distributed queries? {#connect-port}

Managed Service for ClickHouse® uses the native/TLS protocol on port 9440 for inter-server communication when running distributed queries. There is no option to change the protocol or port.

#### Why cannot I connect to a host from the internet? {#fail-connection}

Most likely, no public access is enabled for your cluster, so you can only connect to it from a VM in Yandex Cloud. You can only request public access when [creating a new host](../concepts/network.md#public-access-to-a-host) in your cluster.

#### How do I connect to a non-public host in Yandex Cloud? {#private-host}

[Connect](../operations/connect/clients.md) to a host from a Yandex Cloud VM residing in the same cloud network, or [add](../operations/hosts.md#add-host) a new publicly accessible host to the cluster and use it to connect to the non-public host.

#### Can I connect to a public cluster without SSL? {#without-ssl}

No. You can only connect to public hosts over SSL. For more information, see [this guide](../operations/connect/index.md).

#### Why do I get an `UNEXPECTED_PACKET_FROM_SERVER` error when trying to connect? {#unexpected-packet}

Here is the full text of the error:

```text
Code: 102. DB::NetException:
Unexpected packet from server <host_FQDN>.mdb.yandexcloud.net:9440
(expected Hello or Exception, got Unknown packet)
```

This error occurs when you try to connect to a ClickHouse® host on port 9440 without encryption. You can only connect on port 9440 over an encrypted SSL connection.

Make sure to specify the `--secure` parameter when connecting on port 9440.

To learn more about connection methods, see [Connecting to a ClickHouse® cluster](../operations/connect/clients.md).

#### Can I connect to cluster hosts over SSH or get superuser privileges on them? {#connect-ssh}

You cannot connect to hosts via SSH. This is done for the sake of security and user cluster fault tolerance because direct changes inside a host can render it completely inoperable.

#### What should I do if I get a revocation check error when obtaining an SSL certificate via PowerShell? {#get-ssl-error}

Complete error message:

```text
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012)
The revocation function was unable to check revocation for the certificate
```
This means that, when connecting to the website, the function was unable to check if its certificate was listed as revoked.

To fix this error:

* Make sure your corporate network policies are not blocking the verification.
* Run the following command with the `--ssl-no-revoke` parameter:

    ```powershell
    mkdir -Force $HOME\.yandex; `
    curl.exe https://storage.yandexcloud.net/cloud-certs/RootCA.pem `
      --ssl-no-revoke `
      --output $HOME\.yandex\RootCA.crt; `
    curl.exe https://storage.yandexcloud.net/cloud-certs/IntermediateCA.pem `
      --ssl-no-revoke `
      --output $HOME\.yandex\IntermediateCA.crt; `
    Import-Certificate `
      -FilePath $HOME\.yandex\RootCA.crt `
      -CertStoreLocation cert:\CurrentUser\Root; `
    Import-Certificate `
      -FilePath $HOME\.yandex\IntermediateCA.crt `
      -CertStoreLocation cert:\CurrentUser\Root
    ```

## Updating a cluster {#cluster-update}

#### How do I add a host to a cluster? {#add-host}

To add a host, follow [this guide](../operations/hosts.md#add-host). You can also add new hosts to a cluster when [creating a shard](../operations/shards.md#add-shard).

#### Can I set join_use_nulls to 1 using the CLI? {#join-use-nulls}

Yes. To do this, when creating a user or updating user settings, provide the required `join_use_nulls` value in `--settings`. Here is an example:

```bash
yc managed-clickhouse user update <username> \
  --cluster-name=<cluster_name> \
  --settings="join_use_nulls=1"
```

For more information, see [this guide](../operations/cluster-users.md#update-settings).

#### Will my cluster be unavailable during an update? {#update-availability}

If your cluster has more than one host, there is no downtime while updating it, since the hosts are updated one by one. Only individual hosts are unavailable when the cluster is being restarted.

#### How do I change the time zone? {#timezone}

Change the ClickHouse® [timezone](https://clickhouse.com/docs/enen/operations/server-configuration-parameters/settings#server_configuration_parameters-timezone) or [session_timezone](https://clickhouse.com/docs/enen/operations/settings/settings#session_timezone) setting. Learn how to do this in [this guide](../operations/change-server-level-settings.md#yandex-cloud-interfaces).

#### Will my cluster be unavailable when adding replicas? {#add-replica-availability}

Yes, the cluster will experience a short downtime during restart.

#### How do I grant read-only permissions to a user? {#readonly}

To do this, when creating or editing a user via the CLI, specify `readonly=1` in `--settings`. Here is an example:

```bash
yc managed-clickhouse user update <username> \
  --cluster-name=<cluster_name> \
  --settings="readonly=1"
```

For more information, see [this guide](../operations/cluster-users.md#update-settings).

#### How do I increase the memory limit? {#memory-limit}

[Update the user settings](../operations/cluster-users.md#update-settings) and set the required `Max memory usage` value.

#### Can I change a network and subnets? {#network}

No, you can only select a network and subnets for hosts when creating a cluster or [restoring it](../operations/cluster-backups.md#restore) from a backup.

#### How do I change the distribution of data across shards in a cluster? {#resharding}

In an existing cluster, you cannot change the location of data in shards.

## Cluster settings {#cluster-settings}

#### How do I create a user to access a cluster from DataLens with read-only permissions? {#datalens-readonly}

Follow [this guide](../operations/cluster-users.md#example-create-readonly-user) to create a user with read-only permissions. With **DataLens access** [enabled](../operations/update.md#change-additional-settings) in the cluster settings, the service will be able to [connect](../operations/datalens-connect.md#create-connector) to the cluster using this user.

#### How do I grant a user permissions to create and delete tables or databases? {#create-delete-role}

[Enable managing users via SQL](../operations/update.md#SQL-management) and grant the user the required permissions using the `GRANT` command.

For more information about the `GRANT` command, see [this ClickHouse® guide](https://clickhouse.com/docs/enen/sql-reference/statements/grant).

#### How do I find out the internal_replication setting value? {#internal-replication}

The `internal_replication` setting information is not available in Yandex Cloud interfaces or ClickHouse® system tables. The default setting value is `true`.

#### How do I increase the maximum amount of RAM to run a query? {#max-memory-usage}

If you do not have enough RAM to run a query, you will see the following error:

```text
DB::Exception: Memory limit (total) exceeded:
would use 14.10 GiB (attempt to allocate chunk of 4219924 bytes), maximum: 14.10 GiB.
(MEMORY_LIMIT_EXCEEDED), Stack trace (when copying this message, always include the lines below)
```

To [increase](../operations/cluster-users.md#update-settings) the maximum amount of RAM, use the [Max memory usage](../concepts/settings-list.md#setting-max-memory-usage) parameter.

If [user management via SQL](../concepts/user-access-rights.md#sql-user-management) is enabled for the cluster, you can set the `Max memory usage` parameter:

* For the current user session by running this query:

    ```sql
    SET max_memory_usage = <value_in_bytes>;
    ```

* For all default users by creating a [settings profile](https://clickhouse.com/docs/enen/operations/access-rights#settings-profiles-management).

#### Why must a highly available Managed Service for ClickHouse® cluster have three or five ZooKeeper hosts? {#zookeeper-hosts-number}

ZooKeeper uses the consensus algorithm: it keeps on running as long as most ZooKeeper hosts are healthy.

For example, if a cluster has two ZooKeeper hosts, then, should one of them stop, the remaining host will not form the majority, so the service will become unavailable. Which means a cluster with two ZooKeeper hosts is not [highly available](../concepts/high-availability.md).

A cluster with three ZooKeeper hosts, however, is highly available. When one of its hosts is under maintenance or down, the cluster remains operational. Therefore, three is the minimum recommended number of ZooKeeper hosts per Managed Service for ClickHouse® cluster.

A cluster with four ZooKeeper hosts has no advantages over a three-host cluster: it will also remain operational if only one of its hosts fails. With two hosts down, the consensus is not met, so the service becomes unavailable.

A cluster with five ZooKeeper hosts is resilient enough to keep running without two of its hosts, three hosts out of five still forming the majority. This is why this cluster is easier to maintain than a three-host cluster. Even if one host out of five is [under maintenance](../concepts/maintenance.md) or restarting, the cluster remains highly available, i.e., it can lose one more host and still be operational.

Adding more than five ZooKeeper hosts to a cluster is not supported.

Thus, we recommend creating three or five ZooKeeper hosts per Managed Service for ClickHouse® cluster.

## Moving and restoring a cluster {#cluster-backups}

#### How are ClickHouse® databases backed up? {#backup-overview}

Backups are created every 24 hours and retained for seven days. You can only restore data as of the backup creation time.

#### Are database host backups enabled by default? {#default-backup}

Yes, backups are enabled by default. For ClickHouse®, a full backup is performed once a day with the possibility to restore it to any saved backup.

#### When does a backup run? Is a database cluster available during backups? {#backup-window}

When [creating](../operations/cluster-create.md) or [updating](../operations/update.md#change-additional-settings) a cluster, you can set the backup start window. The default value is `22:00 - 23:00` UTC (Coordinated Universal Time).

Clusters remain fully available during the backup window.

#### How many backups does Managed Service for ClickHouse® store? For how long? {#how-many-backups}

The size and number of backups are not limited. Automatically created backups are retained for seven days, while manually created ones, indefinitely.

#### Can I delete a backup? {#delete-backup}

Yes, if you created it manually. To delete a backup, [follow this guide](../operations/cluster-backups.md#delete-backup).

#### Can I change the automatic backup retention period? {#backup-retain-days}

You can set the retention period for automatic backups when [creating](../operations/cluster-create.md) or [updating](../operations/update.md#change-additional-settings) a cluster.

#### What does a daily backup include? {#daily-backups}

Backups contain data solely for the `MergeTree` engine family. For other engines, backups only contain table schemas. For more information, see [Backups](../concepts/backup.md).

#### Why does it take a long time to restore a cluster from a backup? {#long-restore}

The approximate average speed of restoring a cluster from a backup is 100 Mbps. The recovery time may vary significantly depending on the host class and nature of the database data.

#### How do I move an existing ClickHouse® cluster to Yandex Cloud? {#migration}

Use [Yandex Data Transfer](../../data-transfer/quickstart.md).

#### Can I restore a shard from a backup into a shard in an existing cluster? {#shard-to-shard}

This option is not currently supported.

However, you can [restore your shard](../operations/cluster-backups.md#restore) from a backup to a new ClickHouse® cluster and transfer data from that cluster into an existing one. To do this, explore the options below:

* [Data Transfer](../tutorials/ch-to-mch-migration.md) enables you to transfer a database or individual tables to a Managed Service for ClickHouse® cluster.
* [ClickHouse® built-in `remote` function](../tutorials/data-migration.md#transfer-remote) allows you to transfer individual tables to a Managed Service for ClickHouse® cluster.
* [ClickHouse® `BACKUP` and `RESTORE` commands](../tutorials/data-migration.md#backup-objstorage) help you back up a database or individual table to a [Yandex Object Storage](../../storage/index.md) bucket and then restore your data from the bucket to a Managed Service for ClickHouse® cluster.

## Monitoring and logs {#monitoring}

#### What metrics and processes can be monitored? {#monitoring-metrics}

For all DBMS types, you can monitor:

- CPU, memory, network, and disk utilization, in absolute terms.
- Memory, network, and disk utilization as a percentage of the set limits for the cluster’s host class.
- Total cluster data size and available storage space remaining.

For all database hosts, you can monitor metrics specific to their DBMS type. For example, for PostgreSQL, you can monitor:
- Average query execution time.
- Number of queries per second.
- Number of errors in logs, and more.

You can monitor metrics with a minimum granularity of five seconds.

#### How is log storage billed? {#logging-pricing}

Logs of any level are written to a disk's system partition (with 20 GB allocated) and are not charged separately. The size of the logs only affects the frequency of their rotation.

#### What is the retention period for logs? {#log-keeping}

Cluster logs are stored for 45 days.

#### How do I monitor free storage space on ZooKeeper hosts? {#zookeeper-storage}

Follow the steps in [this guide](../operations/monitoring.md) to monitor the host state or set up alerts.

#### How do I monitor space taken up by data in hybrid storage? {#hybrid}

Use the `ch_s3_disk_parts_size` metric in Yandex Monitoring. It shows the amount of space used by [MergeTree](https://clickhouse.com/docs/enen/engines/table-engines/mergetree-family/mergetree) table parts in Object Storage. The metric is only available for Managed Service for ClickHouse® clusters with [hybrid storage](../concepts/storage.md#hybrid-storage-features) configured. For more on how to run a query with a metric, see [this tutorial](../tutorials/hybrid-storage.md#metrics).

#### How can I configure an alert for when disk usage reaches a certain percentage? {#disk-space-percentage}

[Create an alert](../operations/monitoring.md#monitoring-integration) for the `disk.used_bytes` metric in Yandex Monitoring. This metric shows the disk space usage in the Managed Service for ClickHouse® cluster.

For `disk.used_bytes`, use notification thresholds. Their recommended values are as follows:

* `Alarm`: 95% of disk space
* `Warning`: 80% of disk space

Thresholds are set in bytes only. For example, the recommended values for a 100 GB disk are as follows:

* `Alarm`: `102,005,473,280` bytes (95%)
* `Warning`: `85,899,345,920` bytes (80%)

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._