Clickhouse | How to add a new shard to the clickhouse cluster?
andriisvitelskyi
FREEOP

2 months ago

Hi!
I am using Brody 's template for the deployment.
https://github.com/railwayapp-templates/clickhouse-cluster
https://railway.com/deploy/clickhouse-cluster

How can I easily add a new shard with a replica? Do you have some guide or recommendations?

Solved$10 Bounty

Pinned Solution

diogoribeirodev
FREETop 10% Contributor

2 months ago

You have 2 options.

Fork the template repo and add the new shard with a replica, and then when deploying the project on railway, use it.

Deploy the project with the original template, then follow this guide:
https://docs.railway.com/guides/deploy#eject-from-template-repository

Where, you will eject from the original template repo, fork it to your github account and then attach it to your project, then you would just go to the new repo and update it ( basically the step 1 )

You need to edit this file:
https://github.com/railwayapp-templates/clickhouse-cluster/blob/main/clickhouse/config.d/remote_servers.xml

and add a new shard, you can just copy paste it inside the <local_cluster> tags

<shard>

<weight>1</weight>

<internal_replication>false</internal_replication>

<replica>

<host from_env="CLICKHOUSE_04_01_HOST"></host>

<port>9000</port>

<user from_env="CH_USER"></user>

<password from_env="CH_PASSWORD"></password>

</replica>

<replica>

<host from_env="CLICKHOUSE_04_02_HOST"></host>

<port>9000</port>

<user from_env="CH_USER"></user>

<password from_env="CH_PASSWORD"></password>

</replica>

</shard>

2 Replies

diogoribeirodev
FREETop 10% Contributor

2 months ago

You have 2 options.

Fork the template repo and add the new shard with a replica, and then when deploying the project on railway, use it.

Deploy the project with the original template, then follow this guide:
https://docs.railway.com/guides/deploy#eject-from-template-repository

Where, you will eject from the original template repo, fork it to your github account and then attach it to your project, then you would just go to the new repo and update it ( basically the step 1 )

You need to edit this file:
https://github.com/railwayapp-templates/clickhouse-cluster/blob/main/clickhouse/config.d/remote_servers.xml

and add a new shard, you can just copy paste it inside the <local_cluster> tags

<shard>

<weight>1</weight>

<internal_replication>false</internal_replication>

<replica>

<host from_env="CLICKHOUSE_04_01_HOST"></host>

<port>9000</port>

<user from_env="CH_USER"></user>

<password from_env="CH_PASSWORD"></password>

</replica>

<replica>

<host from_env="CLICKHOUSE_04_02_HOST"></host>

<port>9000</port>

<user from_env="CH_USER"></user>

<password from_env="CH_PASSWORD"></password>

</replica>

</shard>


diogoribeirodev
FREETop 10% Contributor

2 months ago

and if you want to remove replicas you just delete <replica><replica/>


Status changed to Solved noahd 2 months ago


Loading...