Skip to content

Commit 15cdaaf

Browse files
authored
Merge pull request #4300 from ClickHouse/planetscale-postgres-init
add ClickPipes docs for planetscale for postgres source
2 parents 89d4313 + 36402de commit 15cdaaf

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
sidebar_label: 'Planetscale for Postgres'
3+
description: 'Set up Planetscale for Postgres as a source for ClickPipes'
4+
slug: /integrations/clickpipes/postgres/source/planetscale
5+
title: 'PlanetScale for Postgres Source Setup Guide'
6+
---
7+
8+
import planetscale_wal_level_logical from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/planetscale/planetscale_wal_level_logical.png';
9+
import planetscale_max_slot_wal_keep_size from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/planetscale/planetscale_max_slot_wal_keep_size.png';
10+
import Image from '@theme/IdealImage';
11+
12+
# PlanetScale for Postgres source setup guide
13+
14+
:::info
15+
PlanetScale for Postgres is currently in [early access](https://planetscale.com/postgres).
16+
:::
17+
18+
## Supported Postgres versions {#supported-postgres-versions}
19+
20+
ClickPipes supports Postgres version 12 and later.
21+
22+
## Enable logical replication {#enable-logical-replication}
23+
24+
1. To enable replication on your Postgres instance, we need to make sure that the following settings are set:
25+
26+
```sql
27+
wal_level = logical
28+
```
29+
To check the same, you can run the following SQL command:
30+
```sql
31+
SHOW wal_level;
32+
```
33+
34+
The output should be `logical` by default. If not, please log into the PlanetScale console and go to `Cluster configuration->Parameters` and scroll down to `Write-ahead log` to change it.
35+
36+
<Image img={planetscale_wal_level_logical} alt="Adjusting wal_level in PlanetScale console" size="md" border/>
37+
38+
:::warning
39+
Changing this in the PlanetScale console WILL trigger a restart.
40+
:::
41+
42+
2. Additionally, it is recommended to increase the setting `max_slot_wal_keep_size` from its default of 4GB. This is also done via the PlanetScale console by going to `Cluster configuration->Parameters` and then scroll down to `Write-ahead log`. To help determine the new value, please take a look [here](../faq#recommended-max_slot_wal_keep_size-settings).
43+
44+
<Image img={planetscale_max_slot_wal_keep_size} alt="Adjusting max_slot_wal_keep_size in PlanetScale console" size="md" border/>
45+
46+
## Creating a user with permissions and publication {#creating-a-user-with-permissions-and-publication}
47+
48+
Let's create a new user for ClickPipes with the necessary permissions suitable for CDC,
49+
and also create a publication that we'll use for replication.
50+
51+
For this, you can connect to your PlanetScale Postgres instance using the default `postgres.<...>` user and run the following SQL commands:
52+
```sql
53+
CREATE USER clickpipes_user PASSWORD 'clickpipes_password';
54+
GRANT USAGE ON SCHEMA "public" TO clickpipes_user;
55+
-- You may need to grant these permissions on more schemas depending on the tables you're moving
56+
GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user;
57+
ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user;
58+
59+
-- Give replication permission to the USER
60+
ALTER USER clickpipes_user REPLICATION;
61+
62+
-- Create a publication. We will use this when creating the pipe
63+
-- When adding new tables to the ClickPipe, you'll need to manually add them to the publication as well.
64+
CREATE PUBLICATION clickpipes_publication FOR TABLE <...>, <...>, <...>;
65+
```
66+
:::note
67+
Make sure to replace `clickpipes_user` and `clickpipes_password` with your desired username and password.
68+
:::
69+
70+
## Caveats {#caveats}
71+
1. To connect to PlanetScale Postgres, the current branch needs to be appended to the username created above. For example, if the created user was named `clickpipes_user`, the actual user provided during the ClickPipe creation needs to be `clickpipes_user`.`branch` where `branch` refers to the "id" of the current PlanetScale Postgres [branch](https://planetscale.com/docs/postgres/branching). To quickly determine this, you can refer to the username of the `postgres` user you used to create the user earlier, the part after the period would be the branch id.
72+
2. Do not use the `PSBouncer` port (currently `6432`) for CDC pipes connecting to PlanetScale Postgres, the normal port `5432` must be used. Either port may be used for initial-load only pipes.
73+
3. Please ensure you're connecting only to the primary instance, [connecting to replica instances](https://planetscale.com/docs/postgres/scaling/replicas#how-to-query-postgres-replicas) is currently not supported.
74+
75+
## What's next? {#whats-next}
76+
77+
You can now [create your ClickPipe](../index.md) and start ingesting data from your Postgres instance into ClickHouse Cloud.
78+
Make sure to note down the connection details you used while setting up your Postgres instance as you will need them during the ClickPipe creation process.

scripts/aspell-ignore/en/aspell-dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ Percona
947947
PerfEventInfo
948948
PhpStorm
949949
PlantUML
950+
PlanetScale
950951
Poess
951952
PointDistKm
952953
PointDistM

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ const sidebars = {
761761
"integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres",
762762
"integrations/data-ingestion/clickpipes/postgres/source/generic",
763763
"integrations/data-ingestion/clickpipes/postgres/source/timescale",
764+
"integrations/data-ingestion/clickpipes/postgres/source/planetscale",
764765
],
765766
},
766767
],
35.7 KB
Loading
23 KB
Loading

0 commit comments

Comments
 (0)