Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for ClickHouse
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Connecting to databases
    • Stop and start the cluster
    • SQL queries in the management console
    • Changing cluster and database settings
    • Connecting to DataLens
    • Connecting external dictionaries
    • Adding your own geobase
    • Enabling machine learning models
    • Changing ClickHouse versions
    • Managing ClickHouse hosts
    • Adding ZooKeeper hosts
    • Database management
    • Managing database users
    • Managing backups
    • How to manage shards
    • Deleting clusters
  • Solutions
    • Adding data to the database
    • Sharding tables
  • Concepts
    • Relationship between service resources
    • Host classes
    • Network in Yandex Managed Service for ClickHouse
    • Quotas and limits
    • Storage types
    • Backups
    • Replication
    • Dictionaries
    • Sharding
    • Supported clients
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • BackupService
      • ClusterService
      • DatabaseService
      • FormatSchemaService
      • MlModelService
      • ResourcePresetService
      • UserService
      • VersionsService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • addZookeeper
        • backup
        • create
        • createExternalDictionary
        • createShardGroup
        • delete
        • deleteExternalDictionary
        • deleteHosts
        • deleteShard
        • deleteShardGroup
        • get
        • getShard
        • getShardGroup
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShardGroups
        • listShards
        • move
        • rescheduleMaintenance
        • restore
        • start
        • stop
        • streamLogs
        • update
        • updateShard
        • updateShardGroup
      • Database
        • Overview
        • create
        • delete
        • get
        • list
      • FormatSchema
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • MlModel
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Versions
        • Overview
        • list
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about ClickHouse
    • All questions on the same page
  1. Concepts
  2. Replication

Replication ClickHouse

    Managed Service for ClickHouse helps enable replication for ClickHouse clusters consisting of 2 or more hosts by using Apache ZooKeeper. You just need to create tables of the required type. ZooKeeper hosts will be created and configured automatically.

    Note

    If you created a ClickHouse cluster with two or more hosts, you can't reduce the number of hosts to one.

    Due to limited resources, the b1.nano, b1.micro, b2.nano, and b2.micro class hosts are not replicated.

    Replicated tables

    ClickHouse only supports automatic replication for ReplicatedMergeTree tables (see Data replication in the ClickHouse documentation). To enable replication, you can create the tables on each host separately or use a distributed DDL query.

    To create a ReplicatedMergeTree table on a specific ClickHouse host, send the following query:

    CREATE TABLE db_01.table_01 (log_date Date, user_name String) \
     ENGINE = ReplicatedMergeTree('/table_01', '{replica}') PARTITION BY log_date ORDER BY (log_date, user_name);
    

    Where:

    • db_01 is the DB name.

    • table_01 is the table name.

    • /table_01 is the path to the table in ZooKeeper, which must start with a forward slash /.

    • {replica} is the host ID macro.

    To create replicated tables on every host in the cluster, send a distributed DDL query (as described in the ClickHouse documentation):

    CREATE TABLE db_01.table_01 ON CLUSTER '{cluster}' (log_date Date, user_name String) \
     ENGINE = ReplicatedMergeTree('/table_01', '{replica}') PARTITION BY log_date ORDER BY (log_date, user_name);
    

    The '{cluster}' argument is automatically resolved to the ClickHouse cluster ID.

    ZooKeeper hosts

    For each ClickHouse cluster consisting of 2 or more hosts, Managed Service for ClickHouse creates a cluster of 3 ZooKeeper hosts. ZooKeeper hosts are taken into account when calculating resource consumption and the cost of the cluster.

    How ZooKeeper hosts are managed:

    • By default, ZooKeeper hosts are created with a minimal host class. You can specify the necessary host class when creating a cluster via the API.

    • Managed Service for ClickHouse does not enable you to connect to ZopKeeper servers and configure them. However, you can change the resources allocated to ZooKeeper hosts by changing the host class.

    • If you didn't specify any subnets for the ZooKeeper hosts, Managed Service for ClickHouse automatically distributes them among the subnets of the network that the ClickHouse cluster is connected to.

    For more information about using ZooKeeper to manage replication in ClickHouse, see the ClickHouse documentation.

    Language
    Careers
    Privacy policy
    Terms of use
    © 2021 Yandex.Cloud LLC