Skip to content

Add clickhouse cluster for db #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions connect/clickhouse/clickhouse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ This is a document on setting a Clickhouse peer for PeerDB. PeerDB supports Clic
```sql
CREATE DATABASE peerdb;
```
Or if you have a ClickHouse cluster
```sql
CREATE DATABASE peerdb ON CLUSTER '{cluster}' ENGINE = Replicated('/clickhouse/databases/peerdb/{uuid}/', '{replica}');
```
2. Create a Clickhouse user for PeerDB with the following permissions:
```sql
-- We recommend creating a separate user for PeerDB
Expand All @@ -35,7 +39,25 @@ GRANT CREATE TEMPORARY TABLE, s3 on *.* to peerdb_user;
-- For automatic column-addition on the tables in the mirror
GRANT ALTER ADD COLUMN ON peerdb.* to peerdb_user;
```

on ClickHouse cluster
```sql
CREATE USER peerdb_user IDENTIFIED BY '<password>' ON CLUSTER '{cluster}';
GRANT INSERT, SELECT, DROP, CREATE TABLE ON peerdb.* to peerdb_user ON CLUSTER '{cluster}';
GRANT CREATE TEMPORARY TABLE, s3 on *.* to peerdb_user ON CLUSTER '{cluster}';
GRANT ALTER ADD COLUMN ON peerdb.* to peerdb_user ON CLUSTER '{cluster}';
```
<Note>
When selecting the ReplicatedReplacingMergeTree/ReplicatedMergeTree table engine you need change [default settings](https://clickhouse.com/docs/operations/settings/settings#database_replicated_allow_replicated_engine_arguments).
```
<clickhouse>
<profiles>
<default>
<database_replicated_allow_replicated_engine_arguments>2</database_replicated_allow_replicated_engine_arguments>
</default>
</profiles>
</clickhouse>
```
</Note>
<Note>
If you need to whitelist PeerDB IPs in Clickhouse Cloud, you can find the IPs of your PeerDB instance [here](/peerdb-cloud/ip-table).
</Note>
Expand Down Expand Up @@ -76,4 +98,4 @@ Please try the following:

**Stuck on Validating...**

This means the port entered is incorrect. Please ensure that the port is correct and the ClickHouse server is reachable from the PeerDB server.
This means the port entered is incorrect. Please ensure that the port is correct and the ClickHouse server is reachable from the PeerDB server.