jneo8 / clickhouse-setup

Tutorial for setup clickhouse server.
148 stars 56 forks source link

Support for on cluster '{cluster}' #1

Open kushagra391 opened 3 years ago

kushagra391 commented 3 years ago

Thanks for creating this repo !

While creating replicated tables / DBs with something like,

CREATE DATABASE trails on cluster '{cluster}';

I get a missing macro warning.

Code: 62. DB::Exception: Received from clickhouse-server:9000. 
DB::Exception: No macro 'cluster' in config while processing substitutions in '{cluster}' at '1' 
or macro is not supported here.

This goes away if I add <cluster>cluster_1</cluster> to all the macros

<yandex>
    <macros>
        <cluster>cluster_1</cluster>       -- << specify cluster macro
        <replica>clickhouse-06</replica>
        <shard>01</shard>
        <layer>01</layer>
    </macros>
</yandex>

and the command now works,

clickhouse-01 :) CREATE DATABASE trails on cluster '{cluster}';

CREATE DATABASE trails ON CLUSTER `{cluster}`

Query id: 97728a04-2f0e-49c3-8a66-49b25e891c1f

┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ clickhouse-06 │ 9000 │      0 │       │                   5 │                0 │
│ clickhouse-02 │ 9000 │      0 │       │                   4 │                0 │
│ clickhouse-03 │ 9000 │      0 │       │                   3 │                0 │
│ clickhouse-05 │ 9000 │      0 │       │                   2 │                0 │
│ clickhouse-04 │ 9000 │      0 │       │                   1 │                0 │
│ clickhouse-01 │ 9000 │      0 │       │                   0 │                0 │
└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘

6 rows in set. Elapsed: 0.177 sec.
jneo8 commented 2 years ago

This is great!!

Can you send a PR for this fix?