ClickHouse High Availability Setup
New Deployment with ClickHouse HA
clickhouse:
enabled: true
nameOverride: "clickhouse"
fullnameOverride: "clickhouse"
zookeeper:
enabled: true
shards: 1
replicaCount: 3 # Three replicas for HA
persistence:
size: 5Gi
auth:
username: default
password: your_password
startdbScripts:
create_pattern_tables.sh: |
#!/bin/bash
clickhouse-client --multiquery --host "127.0.0.1" -u "$CLICKHOUSE_ADMIN_USER" --password "$CLICKHOUSE_ADMIN_PASSWORD" < /docker-entrypoint-startdb.d/create_pattern_tables.sql
create_pattern_tables.sql: |
CREATE DATABASE IF NOT EXISTS patterns ON CLUSTER 'default';
CREATE TABLE IF NOT EXISTS patterns.patterns ON CLUSTER 'default'
(
`template` String,
`regex` String,
`count` UInt64,
`tags` Map(String, String),
`id` String,
`start` DateTime,
`end` DateTime,
`modelName` String,
`sourceId` String
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/patterns.patterns', '{replica}')
ORDER BY (sourceId, start)
TTL end + INTERVAL 1 MONTH DELETE;
CREATE TABLE IF NOT EXISTS patterns.tags ON CLUSTER 'default'
(
`sourceId` String,
`tagName` String,
`tagValue` String,
`count` UInt64,
`start` DateTime,
`end` DateTime
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/patterns.tags', '{replica}')
ORDER BY (sourceId, tagName, start)
TTL end + INTERVAL 1 MONTH DELETE;Verify New HA Deployment
1. Check pod status:
2. Verify cluster configuration:
Migrating Existing Standalone to HA
1. Backup Existing Data
2. Update values.yaml
3. Apply the Update
4. Restart Original ClickHouse Pod
5. Verify Deployment
6. Restore Data and Verify Replication
Resource Requirements
Total Suggested Resources for HA Setup
Last updated
Was this helpful?

