From b1058ec6898697e98cf3a48f23735cc8bc66b63d Mon Sep 17 00:00:00 2001 From: da2001 Date: Tue, 5 Mar 2024 12:25:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- allow_replicated.xml | 7 ++++ clickhouse.yaml | 81 ++++++++++++++++++++++++++++++++++++++++++++ cluster.xml.j2 | 20 +++++++++++ hosts.ini | 9 +++++ keeper.xml.j2 | 45 ++++++++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 allow_replicated.xml create mode 100644 clickhouse.yaml create mode 100644 cluster.xml.j2 create mode 100644 hosts.ini create mode 100644 keeper.xml.j2 diff --git a/allow_replicated.xml b/allow_replicated.xml new file mode 100644 index 0000000..5719ba2 --- /dev/null +++ b/allow_replicated.xml @@ -0,0 +1,7 @@ + + + + 1 + + + \ No newline at end of file diff --git a/clickhouse.yaml b/clickhouse.yaml new file mode 100644 index 0000000..ebe8be4 --- /dev/null +++ b/clickhouse.yaml @@ -0,0 +1,81 @@ +--- +- name: Preconfig + hosts: bd + tasks: + + - name: Установка и настройка ClickHouse + vars: + cluster_name: testcluster + + block: + - name: Установка дополнительных пакетов + apt: + name: + - apt-transport-https + - ca-certificates + - dirmngr + update_cache: true + + - name: Добавление ключа ClickHouse + apt_key: + id: "E0C56BD4" + url: "http://repo.yandex.ru/clickhouse/CLICKHOUSE-KEY.GPG" + + - name: Добавление репозитория ClickHouse + apt_repository: + repo: deb https://repo.clickhouse.com/deb/stable/ main/ + state: present + + - name: Установка ClickHouse + apt: + name: + - clickhouse-server + - clickhouse-client + update_cache: true + + - name: Копирование конфига keeper.xml + template: + src: keeper.xml.j2 + dest: /etc/clickhouse-server/config.d/keeper.xml + owner: clickhouse + group: clickhouse + mode: 0400 + + - name: Копирование конфига cluster.xml + template: + src: cluster.xml.j2 + dest: /etc/clickhouse-server/config.d/cluster.xml + owner: clickhouse + group: clickhouse + mode: 0400 + + - name: Копирование конфига macros.xml + template: + src: macros.xml.j2 + dest: /etc/clickhouse-server/config.d/macros.xml + owner: clickhouse + group: clickhouse + mode: 0400 + + - name: Копирование конфига allow_replicated.xml + copy: + src: allow_replicated.xml + dest: /etc/clickhouse-server/users.d/allow_replicated.xml + owner: clickhouse + group: clickhouse + mode: 0400 + + - name: Копирование конфига listenhost.xml + copy: + src: listenhost.xml + dest: /etc/clickhouse-server/config.d/listenhost.xml + owner: clickhouse + group: clickhouse + mode: 0400 + + - name: Проверка корректности установки ClickHouse + service: + name: clickhouse-server + state: restarted + enabled: true + become: true diff --git a/cluster.xml.j2 b/cluster.xml.j2 new file mode 100644 index 0000000..5d604ae --- /dev/null +++ b/cluster.xml.j2 @@ -0,0 +1,20 @@ + + + + + + {{ hostvars['server1'].ansible_host }} + 9000 + + + {{ hostvars['server2'].ansible_host }} + 9000 + + + {{ hostvars['server3'].ansible_host }} + 9000 + + + + + \ No newline at end of file diff --git a/hosts.ini b/hosts.ini new file mode 100644 index 0000000..d91e129 --- /dev/null +++ b/hosts.ini @@ -0,0 +1,9 @@ +[bd] +server1 ansible_host=192.168.13.201 server_id=1 +server2 ansible_host=192.168.13.202 server_id=2 +server3 ansible_host=192.168.13.203 server_id=3 + +[all:vars] +ansible_user=vagrant +ansible_port=22 +ansible_ssh_private_key_file=~/.ssh/id_rsa.pub \ No newline at end of file diff --git a/keeper.xml.j2 b/keeper.xml.j2 new file mode 100644 index 0000000..bf6a9a4 --- /dev/null +++ b/keeper.xml.j2 @@ -0,0 +1,45 @@ + + + 2181 + {{ server_id }} + /var/lib/clickhouse/coordination/log + /var/lib/clickhouse/coordination/snapshots + + + 10000 + 30000 + trace + 10000 + + + + + 1 + {{ hostvars['server1'].ansible_host }} + 9444 + + + 2 + {{ hostvars['server2'].ansible_host }} + 9444 + + + 3 + {{ hostvars['server3'].ansible_host }} + 9444 + + + + + + + + localhost + 2181 + + + + + /clickhouse/{{ cluster_name }}/task_queue/ddl + +