521 lines
17 KiB
YAML
521 lines
17 KiB
YAML
name: clickhouse
|
||
service_id: 120
|
||
service_display_name: ClickHouse
|
||
service_short_name: clickhouse
|
||
service_man: '# Инструкция по управлению кластерами и пользователями ClickHouse<br/><br/>---<br/><br/>## Общая информация<br/><br/>ClickHouse — это колоночная система управления базами данных, предназначенная
|
||
для обработки аналитических запросов в реальном времени. Платформа позволяет создавать, удалять, приостанавливать и возобновлять кластеры ClickHouse, а также управлять базами данных и пользователями.<br/><br/>Кластер
|
||
создаётся через оператор Altinity (`https://github.com/Altinity/clickhouse-operator`) в ресурсной платформе типа `k8s`<br/><br/>Кластеры могут создаваться шардированными с произвольным количеством реплик.
|
||
Для обеспечения отказоустойчивости и координации обязательно включение параметра `Создать ClickHouse-Keeper`.<br/><br/>Кластера создаются с обязательным бекапом. Для этого необходимо предварительно создать
|
||
услугу `S3 Object Storage`.<br/>---<br/><br/>## Доступные операции<br/><br/>* **create** — Создание кластера<br/>* **delete** — Удаление кластера<br/>* **suspend** — Приостановка работы кластера<br/>*
|
||
**resume** — Возобновление работы кластера<br/>* **create_database** — Создание базы данных<br/>* **delete_database** — Удаление базы данных<br/>* **create_user** — Создание пользователя и настройка
|
||
прав доступа к базе данных<br/>* **delete_user** — Удаление пользователя<br/><br/>## Процесс создания и первого подключения<br/><br/>1. Выполнить операцию `create` - будет создан кластер<br/>2. Выполнить
|
||
операцию `create_database` - будет создана база данных<br/>3. Выполнить операцию `create_user` - будет создан пользователь (выбрать доступ подключения к БД, созданной в п.2)<br/><br/>## Примеры подключения<br/><br/>###
|
||
Подключение через HTTP-интерфейс<br/><br/>```bash<br/># Проверка доступности кластера<br/>curl "http://<username>:<password>@<host>:8123/" -d "SELECT 1"<br/><br/># Выполнение запроса<br/>curl "http://<username>:<password>@<host>:8123/"
|
||
-d "SHOW DATABASES"<br/>```<br/><br/>## Простые кейсы<br/>*Создать БД и обычной таблицы*<br/>```clickhouse<br/>CREATE TABLE database.table<br/>(<br/> id UInt64,<br/> value String<br/>)<br/>ENGINE
|
||
= MergeTree()<br/>ORDER BY id;<br/><br/>INSERT INTO database.table SELECT number, toString(number) FROM numbers(10000000);<br/><br/>SELECT count() FROM database.table;<br/>```<br/>Базы и таблицы не реплицируются
|
||
без специального ключа (`ON CLUSTER ''clickhousek8s''`)<br/>В случае создания в стиле, описанным выше, необходимо будет выполнять действия на всех шардах/репликах<br/><br/><br/>*Создание БД и шардированной
|
||
таблицы*<br/>```clickhouse<br/>CREATE TABLE database.localUsers<br/>(<br/> id UInt64,<br/> value String<br/>)<br/>ENGINE = MergeTree()<br/>ORDER BY id;<br/><br/>CREATE TABLE database.shardedTable<br/>AS
|
||
localUsers<br/>ENGINE = Distributed(''clickhousek8s'', ''database'', ''localUsers'', id);<br/><br/>INSERT INTO shardedTable SELECT number, toString(number) FROM numbers(10000000);<br/><br/>SELECT count()
|
||
FROM shardedTable;<br/>```<br/>Важный момент - в данном примере таблицы придётся также выполнять на всех нодах ClickHouse<br/><br/>*Создание реплицируемой и шардированной таблицы*<br/>```clickhouse<br/>CREATE
|
||
TABLE IF NOT EXISTS database.localUsers ON cluster ''clickhousek8s''<br/>(<br/> user_id UInt64,<br/> name String,<br/> email String<br/>)<br/>ENGINE = ReplicatedMergeTree(<br/> ''/clickhouse/tables/{shard}/localUsers'',<br/> ''{replica}''<br/>)<br/>ORDER
|
||
BY user_id;<br/><br/>CREATE TABLE IF NOT EXISTS database.users ON cluster ''clickhousek8s''<br/>AS database.localUsers<br/>ENGINE = Distributed(''clickhousek8s'', ''database'', ''localUsers'', rand());<br/><br/>INSERT
|
||
INTO database.users VALUES (1, ''Alice'', ''alice@example.com'');<br/>INSERT INTO database.users VALUES (2, ''Bob'', ''bob@example.com'');<br/>INSERT INTO database.users VALUES (3, ''Charlie'', ''charlie@example.com'');<br/>INSERT
|
||
INTO database.users VALUES (4, ''David'', ''david@example.com'');<br/>INSERT INTO database.users VALUES (5, ''Gosha'', ''gosha@example.com'');<br/>INSERT INTO database.users VALUES (6, ''Eve'', ''eve@example.com'');<br/>INSERT
|
||
INTO database.users VALUES (7, ''Frank'', ''frank@example.com'');<br/>INSERT INTO database.users VALUES (8, ''Grace'', ''grace@example.com'');<br/>INSERT INTO database.users VALUES (9, ''Hannah'', ''hannah@example.com'');<br/>INSERT
|
||
INTO database.users VALUES (10, ''Ivan'', ''ivan@example.com'');<br/><br/>SELECT * FROM database.localUsers;<br/>SELECT * FROM database.users;<br/><br/>SELECT COUNT(*) AS total_users FROM database.users;<br/>SELECT
|
||
COUNT(*) AS total_users_local FROM database.localUsers;<br/>```'
|
||
lifecycle:
|
||
suspendOnDestroyDefault: true
|
||
adoptExistingOnCreateDefault: false
|
||
operations:
|
||
- svcOperationId: 181
|
||
operation: create
|
||
kind: instance
|
||
action: create
|
||
- svcOperationId: 186
|
||
operation: create_database
|
||
kind: subresource
|
||
action: create
|
||
- svcOperationId: 185
|
||
operation: create_user
|
||
kind: subresource
|
||
action: create
|
||
- svcOperationId: 184
|
||
operation: delete
|
||
kind: instance
|
||
action: delete
|
||
- svcOperationId: 188
|
||
operation: delete_database
|
||
kind: subresource
|
||
action: delete
|
||
- svcOperationId: 187
|
||
operation: delete_user
|
||
kind: subresource
|
||
action: delete
|
||
- svcOperationId: 189
|
||
operation: modify
|
||
kind: instance
|
||
action: modify
|
||
- svcOperationId: 276
|
||
operation: reconcile
|
||
kind: action
|
||
action: reconcile
|
||
- svcOperationId: 183
|
||
operation: resume
|
||
kind: instance
|
||
action: resume
|
||
- svcOperationId: 182
|
||
operation: suspend
|
||
kind: instance
|
||
action: suspend
|
||
stateOut:
|
||
databases: {}
|
||
users: {}
|
||
cfsParams:
|
||
- svcOperationCfsParamId: 837
|
||
svcOperationCfsParam: startupConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: false
|
||
dataDescriptor:
|
||
resourceRealm:
|
||
dataType: string
|
||
defaultValue: k8s-4-ext-nubes-ru
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- k8s-4-ext-nubes-ru
|
||
- svcOperationCfsParamId: 838
|
||
svcOperationCfsParam: clusterConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
shards:
|
||
dataType: integer > 0
|
||
defaultValue: '1'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '1'
|
||
- '2'
|
||
- '3'
|
||
disk:
|
||
dataType: integer > 0
|
||
defaultValue: '10'
|
||
isRequired: true
|
||
isModifiable: false
|
||
cpu:
|
||
dataType: integer > 0
|
||
defaultValue: '1000'
|
||
isRequired: true
|
||
isModifiable: false
|
||
memory:
|
||
dataType: integer > 0
|
||
defaultValue: '2048'
|
||
isRequired: true
|
||
isModifiable: false
|
||
replicas:
|
||
dataType: integer > 0
|
||
defaultValue: '1'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '1'
|
||
- '3'
|
||
- '5'
|
||
- '7'
|
||
- svcOperationCfsParamId: 839
|
||
svcOperationCfsParam: accessConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
masterAccessList:
|
||
dataType: json
|
||
defaultValue: '[]'
|
||
isRequired: true
|
||
isModifiable: false
|
||
masterIpSpace:
|
||
dataType: string
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 840
|
||
svcOperationCfsParam: clickhouseKeeperConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
cpu:
|
||
dataType: integer > 0
|
||
defaultValue: '500'
|
||
isRequired: true
|
||
isModifiable: false
|
||
memory:
|
||
dataType: integer > 0
|
||
defaultValue: '512'
|
||
isRequired: true
|
||
isModifiable: false
|
||
replicas:
|
||
dataType: integer >= 0
|
||
defaultValue: '0'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '0'
|
||
- '1'
|
||
- '3'
|
||
- svcOperationCfsParamId: 841
|
||
svcOperationCfsParam: clickhouseConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
version:
|
||
dataType: string
|
||
defaultValue: '25.10'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '25.10'
|
||
- svcOperationCfsParamId: 842
|
||
svcOperationCfsParam: backupConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
s3Uid:
|
||
dataType: uuid
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
retain:
|
||
dataType: integer > 0
|
||
defaultValue: '7'
|
||
isRequired: true
|
||
isModifiable: false
|
||
schedule:
|
||
dataType: string
|
||
defaultValue: 0 0 * * *
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 843
|
||
svcOperationCfsParam: autoscaleConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
quota:
|
||
dataType: integer > 0
|
||
defaultValue: '100'
|
||
isRequired: true
|
||
isModifiable: false
|
||
percent:
|
||
dataType: integer > 0
|
||
defaultValue: '10'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '10'
|
||
- '15'
|
||
- '20'
|
||
enabled:
|
||
dataType: boolean
|
||
defaultValue: 'false'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- 'false'
|
||
- 'true'
|
||
schedule:
|
||
dataType: integer >= 0
|
||
defaultValue: '0'
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '0'
|
||
- '5'
|
||
- '12'
|
||
- '23'
|
||
- svcOperationCfsParamId: 851
|
||
svcOperationCfsParam: clickhouseFilesConfiguration
|
||
dataType: array-map-fixed
|
||
isRequired: false
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
path:
|
||
dataType: string
|
||
defaultValue: something.xml
|
||
isRequired: true
|
||
isModifiable: false
|
||
xmlConfig:
|
||
dataType: string
|
||
defaultValue: <clickhouse></clickhouse>
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 600
|
||
svcOperationCfsParam: dbName
|
||
dataType: string
|
||
isRequired: true
|
||
defaultValue: db01
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 596
|
||
svcOperationCfsParam: username
|
||
dataType: string
|
||
isRequired: true
|
||
defaultValue: myusername
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 598
|
||
svcOperationCfsParam: dbName
|
||
dataType: array-map-fixed
|
||
isRequired: true
|
||
defaultValue: '[{}]'
|
||
isModifiable: false
|
||
dataDescriptor:
|
||
dbName:
|
||
dataType: string
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 599
|
||
svcOperationCfsParam: accessHosts
|
||
dataType: string
|
||
isRequired: true
|
||
defaultValue: ::/0
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 602
|
||
svcOperationCfsParam: dbName
|
||
dataType: string
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
- svcOperationCfsParamId: 601
|
||
svcOperationCfsParam: username
|
||
dataType: string
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
- svcOperationCfsParamId: 844
|
||
svcOperationCfsParam: clusterConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
replicas:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '1'
|
||
- '3'
|
||
- '5'
|
||
- '7'
|
||
shards:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '1'
|
||
- '2'
|
||
- '3'
|
||
disk:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
cpu:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
memory:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 845
|
||
svcOperationCfsParam: clickhouseKeeperConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
cpu:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
memory:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
replicas:
|
||
dataType: integer >= 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '0'
|
||
- '1'
|
||
- '3'
|
||
- svcOperationCfsParamId: 846
|
||
svcOperationCfsParam: accessConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
masterIpSpace:
|
||
dataType: string
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
masterAccessList:
|
||
dataType: json
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 847
|
||
svcOperationCfsParam: clickhouseConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
version:
|
||
dataType: string
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '25.10'
|
||
- svcOperationCfsParamId: 848
|
||
svcOperationCfsParam: backupConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
s3Uid:
|
||
dataType: uuid
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
retain:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
schedule:
|
||
dataType: string
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 849
|
||
svcOperationCfsParam: autoscaleConfiguration
|
||
dataType: map-fixed
|
||
isRequired: true
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
percent:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '10'
|
||
- '15'
|
||
- '20'
|
||
enabled:
|
||
dataType: boolean
|
||
defaultValue: false,true
|
||
isRequired: true
|
||
isModifiable: false
|
||
schedule:
|
||
dataType: integer >= 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
valueList:
|
||
- '0'
|
||
- '5'
|
||
- '12'
|
||
- '23'
|
||
quota:
|
||
dataType: integer > 0
|
||
defaultValue: ''
|
||
isRequired: true
|
||
isModifiable: false
|
||
- svcOperationCfsParamId: 850
|
||
svcOperationCfsParam: clickhouseFilesConfiguration
|
||
dataType: array-map-fixed
|
||
isRequired: false
|
||
defaultValue: ''
|
||
isModifiable: true
|
||
dataDescriptor:
|
||
path:
|
||
dataType: string
|
||
defaultValue: something.xml
|
||
isRequired: true
|
||
isModifiable: false
|
||
xmlConfig:
|
||
dataType: string
|
||
defaultValue: <clickhouse></clickhouse>
|
||
isRequired: true
|
||
isModifiable: false
|
||
cfsParamsByOp:
|
||
181:
|
||
- 837
|
||
- 838
|
||
- 839
|
||
- 840
|
||
- 841
|
||
- 842
|
||
- 843
|
||
- 851
|
||
186:
|
||
- 600
|
||
185:
|
||
- 596
|
||
- 598
|
||
- 599
|
||
184: []
|
||
188:
|
||
- 602
|
||
187:
|
||
- 601
|
||
189:
|
||
- 844
|
||
- 845
|
||
- 846
|
||
- 847
|
||
- 848
|
||
- 849
|
||
- 850
|
||
276: []
|
||
183: []
|
||
182: []
|
||
stateParams:
|
||
startupConfiguration: '{"resourceRealm": "k8s-4-ext-nubes-ru"}'
|
||
clusterConfiguration: '{"shards": 1, "disk": 10, "cpu": 1000, "memory": 2048, "replicas": 1}'
|
||
accessConfiguration: '{"masterAccessList": "[]", "masterIpSpace": ""}'
|
||
clickhouseKeeperConfiguration: '{"cpu": 500, "memory": 512, "replicas": 0}'
|
||
clickhouseConfiguration: '{"version": "25.10"}'
|
||
backupConfiguration: '{"s3Uid": "", "retain": 7, "schedule": "0 0 * * *"}'
|
||
autoscaleConfiguration: '{"quota": 100, "percent": 10, "enabled": false, "schedule": 0}'
|
||
clickhouseFilesConfiguration: '{"path": "something.xml", "xmlConfig": "<clickhouse></clickhouse>"}'
|