Skip to content

Commit

Permalink
Merge pull request #30 from nl2go/shard-support
Browse files Browse the repository at this point in the history
Add shard and cluster support
  • Loading branch information
stephanepham-sib authored Feb 17, 2021
2 parents 8ebdf26 + 46011c2 commit 1eb02a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 139 deletions.
120 changes: 13 additions & 107 deletions templates/instances.xml.j2
Original file line number Diff line number Diff line change
@@ -1,118 +1,24 @@

<?xml version="1.0"?>
<!-- {{ ansible_managed }} -->
<yandex>
<remote_servers>
<distributed_cluster>
{% for clusters_name, shards_name in clickhouse_clusters.items() | list %}
<{{ clusters_name }}>
{% for shard_name, replicas in shards_name.items() %}
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard01'] %}
{% for replica in replicas %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<host>{{ replica['host'] }}</host>
<port>{{ replica['port'] }}</port>
<user>{{ clickhouse_distributed_user }}</user>
<password></password>
</replica>
{% endfor %}
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard02'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard03'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard04'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard05'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard06'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard07'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard08'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard09'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
<shard>
<internal_replication>true</internal_replication>
{% for node_hostname in groups['clickhouse_ip-shard10'] %}
<replica>
<host>{{ node_hostname }}</host>
<port>{{ clickhouse_tcp_port }}</port>
<user>app_sib</user>
<password></password>
</replica>
{% endfor %}
</shard>
</distributed_cluster>
{% endfor %}
</{{ clusters_name }}>
{% endfor %}
</remote_servers>
</yandex>
35 changes: 3 additions & 32 deletions templates/macros.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,9 @@
<!-- {{ ansible_managed }} -->
<yandex>
<macros>
<cluster>{{ clickhouse_display_name | default('clickhouse') }}</cluster>
{% if inventory_hostname in groups['clickhouse_shard01'] %}
<shard>01</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard02'] %}
<shard>02</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard03'] %}
<shard>03</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard04'] %}
<shard>04</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard05'] %}
<shard>05</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard06'] %}
<shard>06</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard07'] %}
<shard>07</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard08'] %}
<shard>08</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard09'] %}
<shard>09</shard>
{% endif %}
{% if inventory_hostname in groups['clickhouse_shard10'] %}
<shard>10</shard>
{% endif %}
<cluster>{{ cluster }}</cluster>
<shard>{{ shard }}</shard>
<replica>{{ inventory_hostname }}</replica>
<distributed_clusters>distributed_cluster</distributed_clusters>
<distributed_clusters>{{ distributed_cluster }}</distributed_clusters>
</macros>
</yandex>

0 comments on commit 1eb02a6

Please sign in to comment.